From ae8eec5d1ba5c798dceee813503d5821af172984 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 8 Mar 2015 11:01:13 -0700 Subject: [PATCH] Add arg to exerciser "af" Updated the NuAddFile command to take an extra argument that identifies the source as coming from a resource fork. You can't actually use this to create a forked entry without some behind- the-scenes renaming, because the exerciser uses the disk filename as the storage filename, and the "add file" code won't be able to match the entries up. --- nufxlib/samples/Exerciser.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/nufxlib/samples/Exerciser.c b/nufxlib/samples/Exerciser.c index 18b72dc..79229f3 100644 --- a/nufxlib/samples/Exerciser.c +++ b/nufxlib/samples/Exerciser.c @@ -364,13 +364,25 @@ static NuError AbortFunc(ExerciserState* pState, int argc, char** argv) static NuError AddFileFunc(ExerciserState* pState, int argc, char** argv) { NuFileDetails nuFileDetails; + int fromRsrc = false; (void) pState, (void) argc, (void) argv; /* shut up, gcc */ assert(ExerciserState_GetNuArchive(pState) != NULL); - assert(argc == 2); + assert(argc == 3); + + if (strcasecmp(argv[2], "true") == 0) { + fromRsrc = true; + } else if (strcasecmp(argv[2], "false") != 0) { + fprintf(stderr, "WARNING: fromRsrc should be 'true' or 'false'\n"); + /* ignore */ + } memset(&nuFileDetails, 0, sizeof(nuFileDetails)); - nuFileDetails.threadID = kNuThreadIDDataFork; + if (fromRsrc) { + nuFileDetails.threadID = kNuThreadIDRsrcFork; + } else { + nuFileDetails.threadID = kNuThreadIDDataFork; + } nuFileDetails.storageNameMOR = argv[1]; nuFileDetails.fileSysID = kNuFileSysUnknown; nuFileDetails.fileSysInfo = (short) kFssep; @@ -378,7 +390,7 @@ static NuError AddFileFunc(ExerciserState* pState, int argc, char** argv) /* fileType, extraType, storageType, dates */ return NuAddFile(ExerciserState_GetNuArchive(pState), argv[1], - &nuFileDetails, false, NULL); + &nuFileDetails, fromRsrc, NULL); } /* @@ -1039,7 +1051,7 @@ static const struct { { "ab", AbortFunc, 0, "", kFlagArchiveReq, "Abort current changes" }, - { "af", AddFileFunc, 1, "filename", kFlagArchiveReq, + { "af", AddFileFunc, 2, "filename fromRsrc", kFlagArchiveReq, "Add file" }, { "ar", AddRecordFunc, 1, "storageName", kFlagArchiveReq, "Add record" },