mirror of
https://github.com/fadden/nulib2.git
synced 2025-02-05 20:30:57 +00:00
Added NuTestRecord().
This commit is contained in:
parent
a55cfee11f
commit
e546f96f9a
@ -168,6 +168,20 @@ NuTest(NuArchive* pArchive)
|
||||
return err;
|
||||
}
|
||||
|
||||
NUFXLIB_API NuError
|
||||
NuTestRecord(NuArchive* pArchive, NuRecordIdx recordIdx)
|
||||
{
|
||||
NuError err;
|
||||
|
||||
if ((err = Nu_ValidateNuArchive(pArchive)) == kNuErrNone) {
|
||||
Nu_SetBusy(pArchive);
|
||||
err = Nu_TestRecord(pArchive, recordIdx);
|
||||
Nu_ClearBusy(pArchive);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ===========================================================================
|
||||
|
@ -161,9 +161,9 @@ typedef unsigned long NuThreadIdx;
|
||||
*/
|
||||
typedef unsigned long NuThreadID;
|
||||
#define NuMakeThreadID(class, kind) /* construct a NuThreadID */ \
|
||||
((unsigned long)class << 16 | (unsigned long)kind)
|
||||
((unsigned long)(class) << 16 | (unsigned long)(kind))
|
||||
#define NuGetThreadID(pThread) /* pull NuThreadID out of NuThread */ \
|
||||
(NuMakeThreadID(pThread->thThreadClass, pThread->thThreadKind))
|
||||
(NuMakeThreadID((pThread)->thThreadClass, (pThread)->thThreadKind))
|
||||
#define NuThreadIDGetClass(threadID) /* get threadClass from NuThreadID */ \
|
||||
((unsigned short) ((unsigned long)(threadID) >> 16))
|
||||
#define NuThreadIDGetKind(threadID) /* get threadKind from NuThreadID */ \
|
||||
@ -386,6 +386,9 @@ typedef struct NuDateTime {
|
||||
|
||||
/*
|
||||
* NuFX "thread" definition.
|
||||
*
|
||||
* Guaranteed not to have pointers in it. Can be copied with memcpy or
|
||||
* assignment.
|
||||
*/
|
||||
typedef struct NuThread {
|
||||
/* from the archive */
|
||||
@ -399,7 +402,7 @@ typedef struct NuThread {
|
||||
/* extra goodies */
|
||||
NuThreadIdx threadIdx;
|
||||
unsigned long actualThreadEOF; /* disk images might be off */
|
||||
long fileOffset; /* fseek offset to data in file */
|
||||
long fileOffset; /* fseek offset to data in shk */
|
||||
|
||||
/* internal use only */
|
||||
unsigned short used; /* mark as uninteresting */
|
||||
@ -712,6 +715,7 @@ NUFXLIB_API NuError NuStreamOpenRO(FILE* infp, NuArchive** ppArchive);
|
||||
NUFXLIB_API NuError NuContents(NuArchive* pArchive, NuCallback contentFunc);
|
||||
NUFXLIB_API NuError NuExtract(NuArchive* pArchive);
|
||||
NUFXLIB_API NuError NuTest(NuArchive* pArchive);
|
||||
NUFXLIB_API NuError NuTestRecord(NuArchive* pArchive, NuRecordIdx recordIdx);
|
||||
|
||||
/* strictly non-streaming read-only interfaces */
|
||||
NUFXLIB_API NuError NuOpenRO(const char* archivePathname,NuArchive** ppArchive);
|
||||
@ -733,7 +737,7 @@ NUFXLIB_API NuError NuFlush(NuArchive* pArchive, long* pStatusFlags);
|
||||
NUFXLIB_API NuError NuAddRecord(NuArchive* pArchive,
|
||||
const NuFileDetails* pFileDetails, NuRecordIdx* pRecordIdx);
|
||||
NUFXLIB_API NuError NuAddThread(NuArchive* pArchive, NuRecordIdx recordIdx,
|
||||
NuThreadIdx threadID, NuDataSource* pDataSource,
|
||||
NuThreadID threadID, NuDataSource* pDataSource,
|
||||
NuThreadIdx* pThreadIdx);
|
||||
NUFXLIB_API NuError NuAddFile(NuArchive* pArchive, const char* pathname,
|
||||
const NuFileDetails* pFileDetails, short fromRsrcFork,
|
||||
@ -746,7 +750,7 @@ NUFXLIB_API NuError NuUpdatePresizedThread(NuArchive* pArchive,
|
||||
NuThreadIdx threadIdx, NuDataSource* pDataSource, long* pMaxLen);
|
||||
NUFXLIB_API NuError NuDelete(NuArchive* pArchive);
|
||||
NUFXLIB_API NuError NuDeleteRecord(NuArchive* pArchive, NuRecordIdx recordIdx);
|
||||
NUFXLIB_API NuError NuDeleteThread(NuArchive* pArchive, NuRecordIdx threadIdx);
|
||||
NUFXLIB_API NuError NuDeleteThread(NuArchive* pArchive, NuThreadIdx threadIdx);
|
||||
|
||||
/* general interfaces */
|
||||
NUFXLIB_API NuError NuClose(NuArchive* pArchive);
|
||||
|
@ -724,6 +724,7 @@ NuError Nu_Contents(NuArchive* pArchive, NuCallback contentFunc);
|
||||
NuError Nu_Extract(NuArchive* pArchive);
|
||||
NuError Nu_ExtractRecord(NuArchive* pArchive, NuRecordIdx recIdx);
|
||||
NuError Nu_Test(NuArchive* pArchive);
|
||||
NuError Nu_TestRecord(NuArchive* pArchive, NuRecordIdx recIdx);
|
||||
NuError Nu_GetRecord(NuArchive* pArchive, NuRecordIdx recordIdx,
|
||||
const NuRecord** ppRecord);
|
||||
NuError Nu_GetRecordIdxByName(NuArchive* pArchive, const char* name,
|
||||
|
@ -553,7 +553,8 @@ Nu_RecordSet_MoveAllRecords(NuArchive* pArchive, NuRecordSet* pDstSet,
|
||||
pDstSet->loaded = true;
|
||||
} else {
|
||||
/* append to dst list */
|
||||
Assert(pDstSet->loaded);
|
||||
Assert(pDstSet->loaded);
|
||||
Assert(pDstSet->nuRecordTail != nil);
|
||||
pDstSet->nuRecordTail->pNext = pSrcSet->nuRecordHead;
|
||||
pDstSet->nuRecordTail = pSrcSet->nuRecordTail;
|
||||
pDstSet->numRecords += pSrcSet->numRecords;
|
||||
@ -1837,6 +1838,35 @@ Nu_Test(NuArchive* pArchive)
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test a single record.
|
||||
*/
|
||||
NuError
|
||||
Nu_TestRecord(NuArchive* pArchive, NuRecordIdx recIdx)
|
||||
{
|
||||
NuError err;
|
||||
NuRecord* pRecord;
|
||||
|
||||
if (Nu_IsStreaming(pArchive))
|
||||
return kNuErrUsage;
|
||||
err = Nu_GetTOCIfNeeded(pArchive);
|
||||
BailError(err);
|
||||
|
||||
/* find the correct record by index */
|
||||
err = Nu_RecordSet_FindByIdx(&pArchive->origRecordSet, recIdx, &pRecord);
|
||||
BailError(err);
|
||||
Assert(pRecord != nil);
|
||||
|
||||
/* extract whatever looks promising */
|
||||
pArchive->testMode = true;
|
||||
err = Nu_ExtractRecordByPtr(pArchive, pRecord);
|
||||
pArchive->testMode = false;
|
||||
BailError(err);
|
||||
|
||||
bail:
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return a pointer to a NuRecord.
|
||||
@ -2475,7 +2505,14 @@ bail:
|
||||
* We don't actually check to see if the filename is changing. If you
|
||||
* want to rename something to the same thing, go right ahead. (This
|
||||
* provides a way for applications to "filter" records that have filenames
|
||||
* in the headers.)
|
||||
* in the headers instead of a thread.)
|
||||
*
|
||||
* BUG: we shouldn't allow a disk image to be renamed to have a complex
|
||||
* path name (e.g. "dir1:dir2:foo"). However, we may not be able to catch
|
||||
* that here depending on pending operations.
|
||||
*
|
||||
* We might also want to screen out trailing fssep chars, though the NuFX
|
||||
* spec doesn't say they're illegal.
|
||||
*/
|
||||
NuError
|
||||
Nu_Rename(NuArchive* pArchive, NuRecordIdx recIdx, const char* pathname,
|
||||
|
Loading…
x
Reference in New Issue
Block a user