From 56a96dc7eb174f00f02073737923f397b15855a4 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 18 Feb 2003 21:43:46 +0000 Subject: [PATCH] Added "original pathname" fields to NuFileDetails and NuErrorStatus. Changed callback setters to return NuCallback instead of NuError. --- nufxlib-0/ChangeLog.txt | 4 ++++ nufxlib-0/Deferred.c | 19 +++++++++++++++++-- nufxlib-0/FileIO.c | 2 ++ nufxlib-0/NufxLib.h | 32 ++++++++++++++++++++------------ nufxlib-0/Record.c | 2 ++ 5 files changed, 45 insertions(+), 14 deletions(-) diff --git a/nufxlib-0/ChangeLog.txt b/nufxlib-0/ChangeLog.txt index 0ed372f..3e4aca8 100644 --- a/nufxlib-0/ChangeLog.txt +++ b/nufxlib-0/ChangeLog.txt @@ -1,3 +1,7 @@ +2003/02/18 fadden + - Added "original pathname" fields to NuFileDetails and NuErrorStatus. + - Changed callback setters to return NuCallback instead of NuError. + 2003/02/08 fadden - Upped version to v2.0.0. - Changed DataSource API. Removed "doClose" and added an optional diff --git a/nufxlib-0/Deferred.c b/nufxlib-0/Deferred.c index 74a5d76..62563f2 100644 --- a/nufxlib-0/Deferred.c +++ b/nufxlib-0/Deferred.c @@ -750,9 +750,24 @@ Nu_HandleAddThreadMods(NuArchive* pArchive, NuRecord* pRecord, * reading the data out of. We could do this differently * for a "file" data source, but we might as well be * consistent. + * + * [Actually, the above remark is bogus. During a bulk add + * there's no other way to recover the original filename. + * Do something different here for data sinks with + * filenames attached. ++ATM 2003/02/17] */ - err = Nu_ProgressDataInit_Compress(pArchive, &progressData, - pRecord, pRecord->filename); + if (Nu_DataSourceGetType(pThreadMod->entry.add.pDataSource) + == kNuDataSourceFromFile) + { + /* use on-disk filename */ + err = Nu_ProgressDataInit_Compress(pArchive, &progressData, + pRecord, Nu_DataSourceFile_GetPathname( + pThreadMod->entry.add.pDataSource)); + } else { + /* use archive filename for both */ + err = Nu_ProgressDataInit_Compress(pArchive, &progressData, + pRecord, pRecord->filename); + } BailError(err); /* send initial progress so they see name if "open" fails */ diff --git a/nufxlib-0/FileIO.c b/nufxlib-0/FileIO.c index c614d47..e3007f6 100644 --- a/nufxlib-0/FileIO.c +++ b/nufxlib-0/FileIO.c @@ -719,6 +719,7 @@ Nu_OpenOutputFile(NuArchive* pArchive, const NuRecord* pRecord, errorStatus.message = nil; errorStatus.pRecord = pRecord; errorStatus.pathname = newPathname; + errorStatus.origPathname = nil; errorStatus.filenameSeparator = newFssep; /*errorStatus.origArchiveTouched = false;*/ errorStatus.canAbort = true; @@ -1021,6 +1022,7 @@ retry: errorStatus.message = nil; errorStatus.pRecord = nil; errorStatus.pathname = pathname; + errorStatus.origPathname = nil; errorStatus.filenameSeparator = '\0'; /*errorStatus.origArchiveTouched = false;*/ errorStatus.canAbort = true; diff --git a/nufxlib-0/NufxLib.h b/nufxlib-0/NufxLib.h index 105e318..6be75e0 100644 --- a/nufxlib-0/NufxLib.h +++ b/nufxlib-0/NufxLib.h @@ -222,15 +222,18 @@ typedef enum NuFileSysID { /* simplified definition of storage types */ typedef enum NuStorageType { - kNuStorageUnknown = 0, + kNuStorageUnknown = 0, /* (used by ProDOS for deleted files) */ kNuStorageSeedling = 1, /* <= 512 bytes */ kNuStorageSapling = 2, /* < 128KB */ kNuStorageTree = 3, /* < 16MB */ + kNuStoragePascalVol = 4, /* (embedded pascal volume; rare) */ kNuStorageExtended = 5, /* forked (any size) */ - kNuStorageDirectory = 0x0d + kNuStorageDirectory = 13, /* directory */ + kNuStorageSubdirHeader = 14, /* (only used in subdir headers) */ + kNuStorageVolumeHeader = 15, /* (only used in volume dir header) */ } NuStorageType; -/* flags for NuOpenRW */ +/* bit flags for NuOpenRW */ enum { kNuOpenCreat = 0x0001, kNuOpenExcl = 0x0002 @@ -514,6 +517,7 @@ typedef struct NuRecordAttr { typedef struct NuFileDetails { /* used during AddFile call */ NuThreadID threadID; /* data, rsrc, disk img? */ + const char* origName; /* these go straight into the NuRecord */ const char* storageName; @@ -634,8 +638,9 @@ typedef struct NuErrorStatus { int sysErr; /* system error code, if applicable */ const char* message; /* (optional) message to user */ const NuRecord* pRecord; /* relevant record, if any */ - const char* pathname; /* relevant pathname, if any */ - char filenameSeparator; /* fssep for this path, if any */ + const char* pathname; /* problematic pathname, if any */ + const char* origPathname; /* original pathname, if any */ + char filenameSeparator; /* fssep for pathname, if any */ /*char origArchiveTouched;*/ char canAbort; /* give option to abort */ @@ -803,17 +808,20 @@ NUFXLIB_API short NuIsPresizedThreadID(NuThreadID threadID); /* callback setters */ -NUFXLIB_API NuError NuSetSelectionFilter(NuArchive* pArchive, +#define kNuInvalidCallback ((NuCallback) 1) +NUFXLIB_API NuCallback NuSetSelectionFilter(NuArchive* pArchive, NuCallback filterFunc); -NUFXLIB_API NuError NuSetOutputPathnameFilter(NuArchive* pArchive, +NUFXLIB_API NuCallback NuSetOutputPathnameFilter(NuArchive* pArchive, NuCallback filterFunc); -NUFXLIB_API NuError NuSetProgressUpdater(NuArchive* pArchive, +NUFXLIB_API NuCallback NuSetProgressUpdater(NuArchive* pArchive, NuCallback updateFunc); -NUFXLIB_API NuError NuSetFreeHandler(NuArchive* pArchive, NuCallback freeFunc); -NUFXLIB_API NuError NuSetErrorHandler(NuArchive* pArchive,NuCallback errorFunc); -NUFXLIB_API NuError NuSetErrorMessageHandler(NuArchive* pArchive, +NUFXLIB_API NuCallback NuSetFreeHandler(NuArchive* pArchive, + NuCallback freeFunc); +NUFXLIB_API NuCallback NuSetErrorHandler(NuArchive* pArchive, + NuCallback errorFunc); +NUFXLIB_API NuCallback NuSetErrorMessageHandler(NuArchive* pArchive, NuCallback messageHandlerFunc); -NUFXLIB_API NuError NuSetGlobalErrorMessageHandler(NuCallback messageHandlerFunc); +NUFXLIB_API NuCallback NuSetGlobalErrorMessageHandler(NuCallback messageHandlerFunc); #ifdef __cplusplus diff --git a/nufxlib-0/Record.c b/nufxlib-0/Record.c index 0d49e1a..851e076 100644 --- a/nufxlib-0/Record.c +++ b/nufxlib-0/Record.c @@ -810,6 +810,7 @@ Nu_ShouldIgnoreBadCRC(NuArchive* pArchive, const NuRecord* pRecord, NuError err) errorStatus.message = nil; errorStatus.pRecord = pRecord; errorStatus.pathname = nil; + errorStatus.origPathname = nil; errorStatus.filenameSeparator = 0; if (pRecord != nil) { errorStatus.pathname = pRecord->filename; @@ -2044,6 +2045,7 @@ Nu_HandleAddDuplicateRecord(NuArchive* pArchive, NuRecordSet* pRecordSet, errorStatus.message = nil; errorStatus.pRecord = pRecord; errorStatus.pathname = pFileDetails->storageName; + errorStatus.origPathname = pFileDetails->origName; errorStatus.filenameSeparator = NuGetSepFromSysInfo(pFileDetails->fileSysInfo); /*errorStatus.origArchiveTouched = false;*/