mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-06 07:58:44 +02:00
Add functionality to preserve nanosecond timestamps
file copy doesn't preserve nanosecond timestamps Closes #369
This commit is contained in:
committed by
Philip Withnall
parent
7ad6b05458
commit
b33ef610de
@@ -241,6 +241,10 @@ ensure_attribute_hash (void)
|
||||
REGISTER_ATTRIBUTE (TIME_CHANGED_USEC);
|
||||
REGISTER_ATTRIBUTE (TIME_CREATED);
|
||||
REGISTER_ATTRIBUTE (TIME_CREATED_USEC);
|
||||
REGISTER_ATTRIBUTE (TIME_MODIFIED_NSEC);
|
||||
REGISTER_ATTRIBUTE (TIME_ACCESS_NSEC);
|
||||
REGISTER_ATTRIBUTE (TIME_CREATED_NSEC);
|
||||
REGISTER_ATTRIBUTE (TIME_CHANGED_NSEC);
|
||||
REGISTER_ATTRIBUTE (UNIX_DEVICE);
|
||||
REGISTER_ATTRIBUTE (UNIX_INODE);
|
||||
REGISTER_ATTRIBUTE (UNIX_MODE);
|
||||
@@ -1820,6 +1824,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
* %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC is provided, the resulting #GDateTime
|
||||
* will have microsecond precision.
|
||||
*
|
||||
* If nanosecond precision is needed, %G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC must
|
||||
* be queried separately using g_file_info_get_attribute_uint32().
|
||||
*
|
||||
* Returns: (transfer full) (nullable): modification time, or %NULL if unknown
|
||||
* Since: 2.62
|
||||
*/
|
||||
@@ -1865,6 +1872,9 @@ g_file_info_get_modification_date_time (GFileInfo *info)
|
||||
* %G_FILE_ATTRIBUTE_TIME_ACCESS_USEC is provided, the resulting #GDateTime
|
||||
* will have microsecond precision.
|
||||
*
|
||||
* If nanosecond precision is needed, %G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC must
|
||||
* be queried separately using g_file_info_get_attribute_uint32().
|
||||
*
|
||||
* Returns: (transfer full) (nullable): access time, or %NULL if unknown
|
||||
* Since: 2.70
|
||||
*/
|
||||
@@ -1910,6 +1920,9 @@ g_file_info_get_access_date_time (GFileInfo *info)
|
||||
* %G_FILE_ATTRIBUTE_TIME_CREATED_USEC is provided, the resulting #GDateTime
|
||||
* will have microsecond precision.
|
||||
*
|
||||
* If nanosecond precision is needed, %G_FILE_ATTRIBUTE_TIME_CREATED_NSEC must
|
||||
* be queried separately using g_file_info_get_attribute_uint32().
|
||||
*
|
||||
* Returns: (transfer full) (nullable): creation time, or %NULL if unknown
|
||||
* Since: 2.70
|
||||
*/
|
||||
@@ -2283,6 +2296,8 @@ g_file_info_set_size (GFileInfo *info,
|
||||
* %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the
|
||||
* given time value.
|
||||
*
|
||||
* %G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC will be cleared.
|
||||
*
|
||||
* Deprecated: 2.62: Use g_file_info_set_modification_date_time() instead, as
|
||||
* #GTimeVal is deprecated due to the year 2038 problem.
|
||||
**/
|
||||
@@ -2291,7 +2306,7 @@ void
|
||||
g_file_info_set_modification_time (GFileInfo *info,
|
||||
GTimeVal *mtime)
|
||||
{
|
||||
static guint32 attr_mtime = 0, attr_mtime_usec;
|
||||
static guint32 attr_mtime = 0, attr_mtime_usec = 0, attr_mtime_nsec = 0;
|
||||
GFileAttributeValue *value;
|
||||
|
||||
g_return_if_fail (G_IS_FILE_INFO (info));
|
||||
@@ -2301,6 +2316,7 @@ g_file_info_set_modification_time (GFileInfo *info,
|
||||
{
|
||||
attr_mtime = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||
attr_mtime_usec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
|
||||
attr_mtime_nsec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC);
|
||||
}
|
||||
|
||||
value = g_file_info_create_value (info, attr_mtime);
|
||||
@@ -2309,6 +2325,9 @@ g_file_info_set_modification_time (GFileInfo *info,
|
||||
value = g_file_info_create_value (info, attr_mtime_usec);
|
||||
if (value)
|
||||
_g_file_attribute_value_set_uint32 (value, mtime->tv_usec);
|
||||
|
||||
/* nsecs can’t be known from a #GTimeVal, so remove them */
|
||||
g_file_info_remove_value (info, attr_mtime_nsec);
|
||||
}
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
@@ -2321,13 +2340,15 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
* %G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC attributes in the file info to the
|
||||
* given date/time value.
|
||||
*
|
||||
* %G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC will be cleared.
|
||||
*
|
||||
* Since: 2.62
|
||||
*/
|
||||
void
|
||||
g_file_info_set_modification_date_time (GFileInfo *info,
|
||||
GDateTime *mtime)
|
||||
{
|
||||
static guint32 attr_mtime = 0, attr_mtime_usec;
|
||||
static guint32 attr_mtime = 0, attr_mtime_usec = 0, attr_mtime_nsec = 0;
|
||||
GFileAttributeValue *value;
|
||||
|
||||
g_return_if_fail (G_IS_FILE_INFO (info));
|
||||
@@ -2337,6 +2358,7 @@ g_file_info_set_modification_date_time (GFileInfo *info,
|
||||
{
|
||||
attr_mtime = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED);
|
||||
attr_mtime_usec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC);
|
||||
attr_mtime_nsec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC);
|
||||
}
|
||||
|
||||
value = g_file_info_create_value (info, attr_mtime);
|
||||
@@ -2345,6 +2367,9 @@ g_file_info_set_modification_date_time (GFileInfo *info,
|
||||
value = g_file_info_create_value (info, attr_mtime_usec);
|
||||
if (value)
|
||||
_g_file_attribute_value_set_uint32 (value, g_date_time_get_microsecond (mtime));
|
||||
|
||||
/* nsecs can’t be known from a #GDateTime, so remove them */
|
||||
g_file_info_remove_value (info, attr_mtime_nsec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2356,13 +2381,15 @@ g_file_info_set_modification_date_time (GFileInfo *info,
|
||||
* %G_FILE_ATTRIBUTE_TIME_ACCESS_USEC attributes in the file info to the
|
||||
* given date/time value.
|
||||
*
|
||||
* %G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC will be cleared.
|
||||
*
|
||||
* Since: 2.70
|
||||
*/
|
||||
void
|
||||
g_file_info_set_access_date_time (GFileInfo *info,
|
||||
GDateTime *atime)
|
||||
{
|
||||
static guint32 attr_atime = 0, attr_atime_usec;
|
||||
static guint32 attr_atime = 0, attr_atime_usec = 0, attr_atime_nsec = 0;
|
||||
GFileAttributeValue *value;
|
||||
|
||||
g_return_if_fail (G_IS_FILE_INFO (info));
|
||||
@@ -2372,6 +2399,7 @@ g_file_info_set_access_date_time (GFileInfo *info,
|
||||
{
|
||||
attr_atime = lookup_attribute (G_FILE_ATTRIBUTE_TIME_ACCESS);
|
||||
attr_atime_usec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_ACCESS_USEC);
|
||||
attr_atime_nsec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC);
|
||||
}
|
||||
|
||||
value = g_file_info_create_value (info, attr_atime);
|
||||
@@ -2380,6 +2408,9 @@ g_file_info_set_access_date_time (GFileInfo *info,
|
||||
value = g_file_info_create_value (info, attr_atime_usec);
|
||||
if (value)
|
||||
_g_file_attribute_value_set_uint32 (value, g_date_time_get_microsecond (atime));
|
||||
|
||||
/* nsecs can’t be known from a #GDateTime, so remove them */
|
||||
g_file_info_remove_value (info, attr_atime_nsec);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2391,13 +2422,15 @@ g_file_info_set_access_date_time (GFileInfo *info,
|
||||
* %G_FILE_ATTRIBUTE_TIME_CREATED_USEC attributes in the file info to the
|
||||
* given date/time value.
|
||||
*
|
||||
* %G_FILE_ATTRIBUTE_TIME_CREATED_NSEC will be cleared.
|
||||
*
|
||||
* Since: 2.70
|
||||
*/
|
||||
void
|
||||
g_file_info_set_creation_date_time (GFileInfo *info,
|
||||
GDateTime *creation_time)
|
||||
{
|
||||
static guint32 attr_ctime = 0, attr_ctime_usec;
|
||||
static guint32 attr_ctime = 0, attr_ctime_usec = 0, attr_ctime_nsec = 0;
|
||||
GFileAttributeValue *value;
|
||||
|
||||
g_return_if_fail (G_IS_FILE_INFO (info));
|
||||
@@ -2407,6 +2440,7 @@ g_file_info_set_creation_date_time (GFileInfo *info,
|
||||
{
|
||||
attr_ctime = lookup_attribute (G_FILE_ATTRIBUTE_TIME_CREATED);
|
||||
attr_ctime_usec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_CREATED_USEC);
|
||||
attr_ctime_nsec = lookup_attribute (G_FILE_ATTRIBUTE_TIME_CREATED_NSEC);
|
||||
}
|
||||
|
||||
value = g_file_info_create_value (info, attr_ctime);
|
||||
@@ -2415,6 +2449,9 @@ g_file_info_set_creation_date_time (GFileInfo *info,
|
||||
value = g_file_info_create_value (info, attr_ctime_usec);
|
||||
if (value)
|
||||
_g_file_attribute_value_set_uint32 (value, g_date_time_get_microsecond (creation_time));
|
||||
|
||||
/* nsecs can’t be known from a #GDateTime, so remove them */
|
||||
g_file_info_remove_value (info, attr_ctime_nsec);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user