Minor cleanup

This commit is contained in:
Andy McFadden 2015-01-11 16:11:44 -08:00
parent 0d5bfa593f
commit 84ba460957
4 changed files with 48 additions and 40 deletions

View File

@ -212,9 +212,7 @@ int AcuEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
SET_PROGRESS_BEGIN();
/*
* Generally speaking, anything in a BNY file is going to be small. The
* major exception is a BXY file, which could be huge. However, the
* SHK embedded in a BXY is never squeezed.
* Generally speaking, anything in an ACU file is going to be small.
*
* To make life easy, we either unsqueeze the entire thing into a buffer
* and then write that, or we do a file-to-file copy of the specified
@ -383,7 +381,7 @@ GenericArchive::OpenResult AcuArchive::Open(const WCHAR* filename,
{
CString errMsg;
fIsReadOnly = true; // ignore "readOnly"
//fIsReadOnly = true; // ignore "readOnly"
errno = 0;
fFp = _wfopen(filename, L"rb");
@ -740,6 +738,9 @@ void AcuArchive::AcuConvertDateTime(uint16_t prodosDate,
bool AcuArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{
// TODO: this is essentially copy & paste from NufxArchive::TestSelection().
// We can move the implementation to GenericArchive and just have an
// archive-specific TestEntry() function.
NuError nerr;
AcuEntry* pEntry;
CString errMsg;

View File

@ -4,7 +4,7 @@
* See the file LICENSE for distribution terms.
*/
/*
* AppleLink Compression Utility archive support.
* AppleLink Compression Utility archive support (read-only).
*/
#ifndef APP_ACUARCHIVE_H
#define APP_ACUARCHIVE_H
@ -33,11 +33,14 @@ public:
virtual long GetSelectionSerial(void) const override { return -1; }
virtual bool GetFeatureFlag(Feature feature) const override {
if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes ||
feature == kFeatureHasSimpleAccess)
return false;
else
if (feature == kFeatureHasFullAccess ||
feature == kFeatureCanChangeType ||
feature == kFeatureHasInvisibleFlag)
{
return true;
} else {
return false;
}
}
/*
@ -60,7 +63,6 @@ private:
*/
NuError CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const;
//NuError BNYUnSqueeze(ExpandBuffer* outExp) const;
AcuArchive* fpArchive; // holds FILE* for archive
bool fIsSqueezed;
@ -73,8 +75,7 @@ private:
*/
class AcuArchive : public GenericArchive {
public:
AcuArchive(void) : fIsReadOnly(false), fFp(NULL)
{}
AcuArchive(void) : fFp(NULL) {}
virtual ~AcuArchive(void) { (void) Close(); }
/*
@ -102,7 +103,7 @@ public:
virtual CString Flush(void) override { return ""; }
virtual CString Reload(void) override;
virtual bool IsReadOnly(void) const override { return fIsReadOnly; };
virtual bool IsReadOnly(void) const override { return true; };
virtual bool IsModified(void) const override { return false; }
virtual void GetDescription(CString* pStr) const override
{ *pStr = "AppleLink ACU"; }
@ -158,7 +159,7 @@ private:
fclose(fFp);
fFp = NULL;
}
return "";
return L"";
}
virtual void XferPrepare(const XferFileOptions* pXferOpts) override
{ ASSERT(false); }
@ -185,12 +186,12 @@ private:
/*
* The header at the front of an ACU archive.
*/
typedef struct AcuMasterHeader {
struct AcuMasterHeader {
uint16_t fileCount;
uint16_t unknown1; // 0x01 00 -- might be "version 1?"
uint8_t fZink[6]; // "fZink", low ASCII
uint8_t unknown2[11]; // 0x01 36 00 00 00 00 00 00 00 00 dd
} AcuMasterHeader;
};
/*
* An entry in an ACU archive. Each archive is essentially a stream
@ -200,9 +201,9 @@ private:
* We read this from the archive and then unpack the interesting parts
* into GenericEntry fields in an AcuEntry.
*/
struct AcuFileEntry;
friend struct AcuFileEntry;
typedef struct AcuFileEntry {
//struct AcuFileEntry;
//friend struct AcuFileEntry;
struct AcuFileEntry {
uint8_t compressionType;
uint16_t dataChecksum; // ??
uint16_t blockCount; // total blocks req'd to hold file
@ -225,7 +226,7 @@ private:
// possibilities for mystery fields:
// - OS type (note ProDOS is $00)
// - forked file support
} AcuFileEntry;
};
/* known compression types */
enum CompressionType {
@ -291,7 +292,7 @@ private:
uint16_t prodosTime, NuDateTime* pWhen);
FILE* fFp;
bool fIsReadOnly;
//bool fIsReadOnly;
};
#endif /*APP_ACUARCHIVE_H*/

View File

@ -39,13 +39,13 @@ const int kFileTypeBAS = 0xfc;
/*
* Set of data allowed in file property "set file info" calls.
*/
typedef struct FileProps {
struct FileProps {
uint32_t fileType;
uint32_t auxType;
uint32_t access;
time_t createWhen;
time_t modWhen;
} FileProps;
};
/*
* Options for converting between file archives and disk archives.
@ -117,16 +117,16 @@ public:
kAllowDamaged = 0x80,
};
/* EOL conversion mode for threads being extracted */
typedef enum ConvertEOL {
enum ConvertEOL {
kConvertUnknown = 0, kConvertEOLOff, kConvertEOLOn, kConvertEOLAuto
} ConvertEOL;
typedef enum EOLType {
};
enum EOLType {
kEOLUnknown = 0, kEOLCR, kEOLLF, kEOLCRLF
};
/* high ASCII conversion mode for threads being extracted */
typedef enum ConvertHighASCII {
enum ConvertHighASCII {
kConvertHAUnknown = 0, kConvertHAOff, kConvertHAOn, kConvertHAAuto
} ConvertHighASCII;
};
/* ProDOS access flags, used for all filesystems */
enum {
@ -138,8 +138,12 @@ public:
kAccessDelete = 0x80
};
/* features supported by underlying archive */
typedef enum Feature {
/*
* Features supported by underlying archive. Primarily of interest
* to EditPropsDialog, which needs to know what sort of attributes can
* be altered in the file type and access flags.
*/
enum Feature {
kFeatureCanChangeType,
kFeaturePascalTypes,
kFeatureDOSTypes,
@ -147,7 +151,7 @@ public:
kFeatureHasFullAccess,
kFeatureHasSimpleAccess, // mutually exclusive with FullAccess
kFeatureHasInvisibleFlag,
} Feature;
};
/*
* Extract data from an archive (NuFX, disk image, etc).
@ -384,13 +388,13 @@ public:
return fNumEntries;
}
typedef enum {
enum OpenResult {
kResultUnknown = 0,
kResultSuccess, // open succeeded
kResultFailure, // open failed
kResultCancel, // open was cancelled by user
kResultFileArchive, // found a file archive rather than disk image
} OpenResult;
};
// Open an archive and do fun things with the innards.
virtual OpenResult Open(const WCHAR* filename, bool readOnly,
@ -410,13 +414,13 @@ public:
virtual void ClearReloadFlag(void) { fReloadFlag = false; }
// One of these for every sub-class.
typedef enum {
enum ArchiveKind {
kArchiveUnknown = 0,
kArchiveNuFX,
kArchiveBNY,
kArchiveACU,
kArchiveDiskImage,
} ArchiveKind;
};
// Returns the kind of archive this is (disk image, NuFX, BNY, etc).
virtual ArchiveKind GetArchiveKind(void) = 0;
@ -465,9 +469,9 @@ public:
const RecompressOptionsDialog* pRecompOpts) = 0;
// return result from XferSelection()
typedef enum {
enum XferStatus {
kXferOK = 0, kXferFailed = 1, kXferCancelled = 2, kXferOutOfSpace = 3
} XferStatus;
};
// Transfer selected files out of this archive and into another.
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
@ -495,7 +499,7 @@ public:
// Determine an archive's capabilities. This is specific to the object
// instance, so this must not be made a static function.
typedef enum {
enum Capability {
kCapUnknown = 0,
kCapCanTest, // NuFX, BNY
@ -506,7 +510,7 @@ public:
kCapCanConvEOLOnAdd, // Disk
kCapCanCreateSubdir, // Disk
kCapCanRenameVolume, // Disk
} Capability;
};
virtual long GetCapability(Capability cap) = 0;
// Get the pathname of the file we opened.

View File

@ -35,9 +35,11 @@ public:
virtual bool GetFeatureFlag(Feature feature) const override {
if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes ||
feature == kFeatureHasSimpleAccess)
{
return false;
else
} else {
return true;
}
}
/*