diff --git a/include/cdio/udf_time.h b/include/cdio/udf_time.h index dbf5e93b..74bb6719 100644 --- a/include/cdio/udf_time.h +++ b/include/cdio/udf_time.h @@ -1,5 +1,5 @@ /* - $Id: udf_time.h,v 1.2 2005/10/27 11:18:56 rocky Exp $ + $Id: udf_time.h,v 1.3 2005/10/30 14:10:44 rocky Exp $ Copyright (C) 2005 Rocky Bernstein This program is free software; you can redistribute it and/or modify @@ -33,44 +33,45 @@ extern "C" { #endif /* __cplusplus */ -/*! - Return the access time of the file. - */ -time_t udf_get_access_time(const udf_file_t *p_udf_file); + /*! + Return the access time of the file. + */ + time_t udf_get_access_time(const udf_file_t *p_udf_file); -/*! - Return the attribute (most recent create or access) time of the file - */ -time_t udf_get_attribute_time(const udf_file_t *p_udf_file); + /*! + Return the attribute (most recent create or access) time of the file + */ + time_t udf_get_attribute_time(const udf_file_t *p_udf_file); -/*! - Return the modification time of the file. - */ -time_t udf_get_modification_time(const udf_file_t *p_udf_file); + /*! + Return the modification time of the file. + */ + time_t udf_get_modification_time(const udf_file_t *p_udf_file); -/*! - Return the access timestamp of the file - */ -udf_timestamp_t *udf_get_access_timestamp(const udf_file_t *p_udf_file); + /*! + Return the access timestamp of the file + */ + udf_timestamp_t *udf_get_access_timestamp(const udf_file_t *p_udf_file); -/*! - Return the modification timestamp of the file - */ -udf_timestamp_t *udf_get_modification_timestamp(const udf_file_t *p_udf_file); + /*! + Return the modification timestamp of the file + */ + udf_timestamp_t *udf_get_modification_timestamp(const udf_file_t + *p_udf_file); -/*! - Return the attr timestamp of the file - */ -udf_timestamp_t *udf_get_attr_timestamp(const udf_file_t *p_udf_file); + /*! + Return the attr timestamp of the file + */ + udf_timestamp_t *udf_get_attr_timestamp(const udf_file_t *p_udf_file); -/*! - Convert a UDF timestamp to a time_t. If microseconds are desired, - use dest_usec. The return value is the same as dest. */ -time_t *udf_stamp_to_time(time_t *dest, long int *dest_usec, + /*! + Convert a UDF timestamp to a time_t. If microseconds are desired, + use dest_usec. The return value is the same as dest. */ + time_t *udf_stamp_to_time(time_t *dest, long int *dest_usec, const udf_timestamp_t src); -udf_timestamp_t *udf_time_to_stamp(udf_timestamp_t *dest, - const struct timespec ts); + udf_timestamp_t *udf_timespec_to_stamp(const struct timespec ts, + udf_timestamp_t *dest); #ifdef __cplusplus } diff --git a/lib/udf/udf_time.c b/lib/udf/udf_time.c index 2a137ff6..aa5e1d0d 100644 --- a/lib/udf/udf_time.c +++ b/lib/udf/udf_time.c @@ -30,7 +30,7 @@ blf 09/27/99: ripped out all the old code and inserted new table from John Brockmeyer (without leap second corrections) rewrote udf_stamp_to_time and fixed timezone - accounting in udf_time_to_stamp. + accounting in udf_timespec_to_stamp. */ /* @@ -148,25 +148,29 @@ udf_stamp_to_time(time_t *dest, long int *dest_usec, } +/*! + Convert a UDF timestamp to a time_t. If microseconds are desired, + use dest_usec. The return value is the same as dest. */ udf_timestamp_t * -udf_time_to_stamp(udf_timestamp_t *dest, struct timespec ts) +udf_timespec_to_stamp(const struct timespec ts, udf_timestamp_t *dest) { long int days, rem, y; const unsigned short int *ip; int16_t offset; + int16_t tv_sec; #ifdef HAVE_TIMEZONE_VAR offset = -timezone; #endif if (!dest) - return NULL; + return dest; dest->type_tz = 0x1000 | (offset & 0x0FFF); - ts.tv_sec += offset * SECS_PER_MINUTE; - days = ts.tv_sec / SECS_PER_DAY; - rem = ts.tv_sec % SECS_PER_DAY; + tv_sec = ts.tv_sec + (offset * SECS_PER_MINUTE); + days = tv_sec / SECS_PER_DAY; + rem = tv_sec % SECS_PER_DAY; dest->hour = rem / SECS_PER_HOUR; rem %= SECS_PER_HOUR; dest->minute = rem / SECS_PER_MINUTE;