diff options
author | Adam Spragg <adam@spra.gg> | 2022-05-17 12:47:32 +0100 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2022-05-18 17:19:47 +0100 |
commit | b3c08670f56d7c5ee85dffa1a2faa5e03d2df5a1 (patch) | |
tree | 135f7cef180c195c060b5a3d9061d81292d57828 /src/metaentry.c | |
parent | 588b3e780fef14631f7ec5c369bff07efdc5e013 (diff) |
Add ability to write Format 1 metadata files
Diffstat (limited to 'src/metaentry.c')
-rw-r--r-- | src/metaentry.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/metaentry.c b/src/metaentry.c index 1eeed5b..6e27f11 100644 --- a/src/metaentry.c +++ b/src/metaentry.c @@ -432,6 +432,52 @@ mentries_tofile_v0(const struct metahash *mhash, FILE * to) } } +/* Stores metaentries to a Format 1 file */ +static void +mentries_tofile_v1(const struct metahash *mhash, FILE * to) +{ + const struct metaentry *mentry; + int key; + struct tm tm; + char tmbuf[20]; + unsigned i; + + fputc('\n', to); + + for (key = 0; key < HASH_INDEXES; key++) { + for (mentry = mhash->bucket[key]; mentry; mentry = mentry->next) { + write_string_url(mentry->path, to); + + fputc('\t', to); + write_string_url(mentry->owner, to); + + fputc('\t', to); + write_string_url(mentry->group, to); + + fputc('\t', to); + fprintf(to, "%.6o", mentry->mode); + + fputc('\t', to); + gmtime_r(&mentry->mtime, &tm); + strftime(tmbuf, sizeof(tmbuf), "%Y-%m-%dT%H:%M:%S", &tm); + fputs(tmbuf, to); + + fputc('.', to); + fprintf(to, "%.9ldZ", mentry->mtimensec); + + for (i = 0; i < mentry->xattrs; i++) { + fputc('\t', to); + write_string_url(mentry->xattr_names[i], to); + fputc('\t', to); + write_binary_url(mentry->xattr_values[i], + mentry->xattr_lvalues[i], to); + } + + fputc('\n', to); + } + } +} + /* Stores metaentries to a file */ void mentries_tofile(const struct metahash *mhash, const char *path, int format) @@ -442,6 +488,7 @@ mentries_tofile(const struct metahash *mhash, const char *path, int format) switch (format) { case 0: formatstr = VERSION_0; tofile = mentries_tofile_v0; break; + case 1: formatstr = VERSION_1; tofile = mentries_tofile_v1; break; default: msg(MSG_CRITICAL, "Unknown format %d\n", format); exit(EXIT_FAILURE); |