From: Michihiro NAKAJIMA Date: Thu, 29 Jan 2009 09:20:44 +0000 (-0500) Subject: In mtree format, add nano second entry to the time keyword output. X-Git-Tag: v2.7.0~382 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddfb3dee28059a0acf11f9479caaeb4753ab9fe7;p=thirdparty%2Flibarchive.git In mtree format, add nano second entry to the time keyword output. It is the same as mtree(8). SVN-Revision: 511 --- diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index de801056e..f83fe5d33 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -882,8 +882,17 @@ parse_keyword(struct archive_read *a, struct mtree *mtree, break; } if (strcmp(key, "time") == 0) { + time_t m; + long ns; + *parsed_kws |= MTREE_HAS_MTIME; - archive_entry_set_mtime(entry, mtree_atol10(&val), 0); + m = (time_t)mtree_atol10(&val); + if (*val == '.') { + ++val; + ns = (long)mtree_atol10(&val); + } else + ns = 0; + archive_entry_set_mtime(entry, m, ns); break; } if (strcmp(key, "type") == 0) { diff --git a/libarchive/archive_write_set_format_mtree.c b/libarchive/archive_write_set_format_mtree.c index b05715502..d7f604b32 100644 --- a/libarchive/archive_write_set_format_mtree.c +++ b/libarchive/archive_write_set_format_mtree.c @@ -355,8 +355,9 @@ archive_write_mtree_finish_entry(struct archive_write *a) mtree_quote(mtree, name); } if ((mtree->keys & F_TIME) != 0) - archive_string_sprintf(&mtree->buf, " time=%jd", - (intmax_t)archive_entry_mtime(entry)); + archive_string_sprintf(&mtree->buf, " time=%jd.%jd", + (intmax_t)archive_entry_mtime(entry), + (intmax_t)archive_entry_mtime_nsec(entry)); if ((mtree->keys & F_MODE) != 0) archive_string_sprintf(&mtree->buf, " mode=%o", archive_entry_mode(entry) & 07777);