Relocate method comments

This moves method comments from the .cpp file to the .h file,
where users of the methods can find them.  This also makes it
possible for the IDE to show the comments when you mouse-hover over
the method name, though Visual Studio is a bit weak in this regard.

Also, added "override" keywords on overridden methods.  Reasonably
current versions of popular compilers seem to support this.

Also, don't have the return type on a separate line in the .cpp file.
The motivation for the practice -- quickly finding a method definition
with "^name" -- is less useful in C++ than C, and modern IDEs provide
more convenient ways to do the same thing.

Also, do some more conversion from unsigned types to uintXX_t.

This commit is primarily for the "app" directory.
This commit is contained in:
Andy McFadden 2014-11-21 13:18:20 -08:00
parent 30b44d98eb
commit d8223dbcfd
115 changed files with 4078 additions and 5588 deletions

View File

@ -58,24 +58,7 @@
* =========================================================================== * ===========================================================================
*/ */
/* int AcuEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
* Extract data from an entry.
*
* If "*ppText" is non-NULL, the data will be read into the pointed-to buffer
* so long as it's shorter than *pLength bytes. The value in "*pLength"
* will be set to the actual length used.
*
* If "*ppText" is NULL, the uncompressed data will be placed into a buffer
* allocated with "new[]".
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pErrMsg" holds an error
* message.
*
* "which" is an anonymous GenericArchive enum (e.g. "kDataThread").
*/
int
AcuEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const CString* pErrMsg) const
{ {
NuError nerr; NuError nerr;
@ -199,16 +182,7 @@ bail:
return result; return result;
} }
/* int AcuEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
* Extract data from a thread to a file. Since we're not copying to memory,
* we can't assume that we're able to hold the entire file all at once.
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pMsg" holds an
* error message.
*/
int
AcuEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const ConvertHighASCII convHA, CString* pErrMsg) const
{ {
NuError nerr; NuError nerr;
@ -297,12 +271,7 @@ bail:
return result; return result;
} }
/* NuError AcuEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError
AcuEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const CString* pMsg) const
{ {
NuError nerr = kNuErrNone; NuError nerr = kNuErrNone;
@ -351,14 +320,7 @@ bail:
} }
/* NuError AcuEntry::TestEntry(CWnd* pMsgWnd)
* Test this entry by extracting it.
*
* If the file isn't compressed, just make sure the file is big enough. If
* it's squeezed, invoke the un-squeeze function with a "NULL" buffer pointer.
*/
NuError
AcuEntry::TestEntry(CWnd* pMsgWnd)
{ {
NuError nerr = kNuErrNone; NuError nerr = kNuErrNone;
CString errMsg; CString errMsg;
@ -411,24 +373,13 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* /*static*/ CString AcuArchive::AppInit(void)
* Perform one-time initialization. There really isn't any for us.
*
* Returns 0 on success, nonzero on error.
*/
/*static*/ CString
AcuArchive::AppInit(void)
{ {
return ""; return "";
} }
/* GenericArchive::OpenResult AcuArchive::Open(const WCHAR* filename,
* Open an ACU archive. bool readOnly, CString* pErrMsg)
*
* Returns an error string on failure, or "" on success.
*/
GenericArchive::OpenResult
AcuArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
{ {
CString errMsg; CString errMsg;
@ -465,23 +416,13 @@ bail:
return kResultSuccess; return kResultSuccess;
} }
/* CString AcuArchive::New(const WCHAR* /*filename*/, const void* /*options*/)
* Finish instantiating an AcuArchive object by creating a new archive.
*
* Returns an error string on failure, or "" on success.
*/
CString
AcuArchive::New(const WCHAR* /*filename*/, const void* /*options*/)
{ {
return L"Sorry, AppleLink Compression Utility files can't be created."; return L"Sorry, AppleLink Compression Utility files can't be created.";
} }
/* long AcuArchive::GetCapability(Capability cap)
* Our capabilities.
*/
long
AcuArchive::GetCapability(Capability cap)
{ {
switch (cap) { switch (cap) {
case kCapCanTest: case kCapCanTest:
@ -515,15 +456,7 @@ AcuArchive::GetCapability(Capability cap)
} }
} }
int AcuArchive::LoadContents(void)
/*
* Load the contents of the archive.
*
* Returns 0 on success, < 0 if this is not an ACU archive > 0 if this appears
* to be an ACU archive but it's damaged.
*/
int
AcuArchive::LoadContents(void)
{ {
NuError nerr; NuError nerr;
int numEntries; int numEntries;
@ -561,11 +494,7 @@ AcuArchive::LoadContents(void)
return 0; return 0;
} }
/* CString AcuArchive::Reload(void)
* Reload the contents of the archive.
*/
CString
AcuArchive::Reload(void)
{ {
fReloadFlag = true; // tell everybody that cached data is invalid fReloadFlag = true; // tell everybody that cached data is invalid
@ -577,15 +506,7 @@ AcuArchive::Reload(void)
return ""; return "";
} }
/* int AcuArchive::ReadMasterHeader(int* pNumEntries)
* Read the archive header. The archive file is left seeked to the point
* at the end of the header.
*
* Returns 0 on success, -1 on failure. Sets *pNumEntries to the number of
* entries in the archive.
*/
int
AcuArchive::ReadMasterHeader(int* pNumEntries)
{ {
AcuMasterHeader header; AcuMasterHeader header;
unsigned char buf[kAcuMasterHeaderLen]; unsigned char buf[kAcuMasterHeaderLen];
@ -615,12 +536,7 @@ AcuArchive::ReadMasterHeader(int* pNumEntries)
return 0; return 0;
} }
/* NuError AcuArchive::ReadFileHeader(AcuFileEntry* pEntry)
* Read and decode an AppleLink Compression Utility file entry header.
* This leaves the file seeked to the point immediately past the filename.
*/
NuError
AcuArchive::ReadFileHeader(AcuFileEntry* pEntry)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
unsigned char buf[kAcuEntryHeaderLen]; unsigned char buf[kAcuEntryHeaderLen];
@ -688,11 +604,7 @@ bail:
return err; return err;
} }
/* void AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry)
* Dump the contents of an AcuFileEntry struct.
*/
void
AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry)
{ {
time_t createWhen, modWhen; time_t createWhen, modWhen;
CString createStr, modStr; CString createStr, modStr;
@ -714,12 +626,7 @@ AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry)
pEntry->fileNameLen, pEntry->headerChecksum); pEntry->fileNameLen, pEntry->headerChecksum);
} }
int AcuArchive::CreateEntry(const AcuFileEntry* pEntry)
/*
* Given an AcuFileEntry structure, add an appropriate entry to the list.
*/
int
AcuArchive::CreateEntry(const AcuFileEntry* pEntry)
{ {
const int kAcuFssep = '/'; const int kAcuFssep = '/';
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -776,21 +683,12 @@ AcuArchive::CreateEntry(const AcuFileEntry* pEntry)
* =========================================================================== * ===========================================================================
*/ */
/* bool AcuArchive::IsDir(const AcuFileEntry* pEntry)
* Test if this entry is a directory.
*/
bool
AcuArchive::IsDir(const AcuFileEntry* pEntry)
{ {
return (pEntry->storageType == 0x0d); return (pEntry->storageType == 0x0d);
} }
/* NuError AcuArchive::AcuRead(void* buf, size_t nbyte)
* Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S).
*/
NuError
AcuArchive::AcuRead(void* buf, size_t nbyte)
{ {
size_t result; size_t result;
@ -805,13 +703,7 @@ AcuArchive::AcuRead(void* buf, size_t nbyte)
return kNuErrNone; return kNuErrNone;
} }
/* NuError AcuArchive::AcuSeek(long offset)
* Seek within an archive. Because we need to handle streaming archives,
* and don't need to special-case anything, we only allow relative
* forward seeks.
*/
NuError
AcuArchive::AcuSeek(long offset)
{ {
ASSERT(fFp != NULL); ASSERT(fFp != NULL);
ASSERT(offset > 0); ASSERT(offset > 0);
@ -825,12 +717,8 @@ AcuArchive::AcuSeek(long offset)
} }
/* void AcuArchive::AcuConvertDateTime(uint16_t prodosDate,
* Convert from ProDOS compact date format to the expanded DateTime format. uint16_t prodosTime, NuDateTime* pWhen)
*/
void
AcuArchive::AcuConvertDateTime(unsigned short prodosDate,
unsigned short prodosTime, NuDateTime* pWhen)
{ {
pWhen->second = 0; pWhen->second = 0;
pWhen->minute = prodosTime & 0x3f; pWhen->minute = prodosTime & 0x3f;
@ -851,11 +739,7 @@ AcuArchive::AcuConvertDateTime(unsigned short prodosDate,
* =========================================================================== * ===========================================================================
*/ */
/* bool AcuArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
* Test the records represented in the selection set.
*/
bool
AcuArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{ {
NuError nerr; NuError nerr;
AcuEntry* pEntry; AcuEntry* pEntry;

View File

@ -24,14 +24,15 @@ public:
{} {}
virtual ~AcuEntry(void) {} virtual ~AcuEntry(void) {}
// retrieve thread data
virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength, virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const; CString* pErrMsg) const override;
virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv, virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const; ConvertHighASCII convHA, CString* pErrMsg) const override;
virtual long GetSelectionSerial(void) const { return -1; } // doesn't matter
virtual bool GetFeatureFlag(Feature feature) const { // doesn't matter
virtual long GetSelectionSerial(void) const override { return -1; }
virtual bool GetFeatureFlag(Feature feature) const override {
if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes || if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes ||
feature == kFeatureHasSimpleAccess) feature == kFeatureHasSimpleAccess)
return false; return false;
@ -39,6 +40,12 @@ public:
return true; return true;
} }
/*
* Test this entry by extracting it.
*
* If the file isn't compressed, just make sure the file is big enough. If
* it's squeezed, invoke the un-squeeze function with a "NULL" buffer pointer.
*/
NuError TestEntry(CWnd* pMsgWnd); NuError TestEntry(CWnd* pMsgWnd);
bool GetSqueezed(void) const { return fIsSqueezed; } bool GetSqueezed(void) const { return fIsSqueezed; }
@ -47,6 +54,10 @@ public:
void SetOffset(long offset) { fOffset = offset; } void SetOffset(long offset) { fOffset = offset; }
private: private:
/*
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA, NuError CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const; CString* pMsg) const;
//NuError BNYUnSqueeze(ExpandBuffer* outExp) const; //NuError BNYUnSqueeze(ExpandBuffer* outExp) const;
@ -66,59 +77,78 @@ public:
{} {}
virtual ~AcuArchive(void) { (void) Close(); } virtual ~AcuArchive(void) { (void) Close(); }
// One-time initialization; returns an error string. /*
* Perform one-time initialization. There really isn't any for us.
*
* Returns 0 on success, nonzero on error.
*/
static CString AppInit(void); static CString AppInit(void);
/*
* Open an ACU archive.
*
* Returns an error string on failure, or "" on success.
*/
virtual OpenResult Open(const WCHAR* filename, bool readOnly, virtual OpenResult Open(const WCHAR* filename, bool readOnly,
CString* pErrMsg); CString* pErrMsg) override;
virtual CString New(const WCHAR* filename, const void* options);
virtual CString Flush(void) { return ""; } /*
virtual CString Reload(void); * Finish instantiating an AcuArchive object by creating a new archive.
virtual bool IsReadOnly(void) const { return fIsReadOnly; }; *
virtual bool IsModified(void) const { return false; } * Returns an error string on failure, or "" on success.
virtual void GetDescription(CString* pStr) const { *pStr = "AppleLink ACU"; } */
virtual CString New(const WCHAR* filename, const void* options) override;
virtual CString Flush(void) override { return ""; }
virtual CString Reload(void) override;
virtual bool IsReadOnly(void) const override { return fIsReadOnly; };
virtual bool IsModified(void) const override { return false; }
virtual void GetDescription(CString* pStr) const override
{ *pStr = "AppleLink ACU"; }
virtual bool BulkAdd(ActionProgressDialog* pActionProgress, virtual bool BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool AddDisk(ActionProgressDialog* pActionProgress, virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry, virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName) const WCHAR* newName) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet); virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS, virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName) const WCHAR* newName) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual CString TestVolumeName(const DiskFS* pDiskFS, virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const const WCHAR* newName) const override
{ ASSERT(false); return "!"; } { ASSERT(false); return "!"; }
virtual CString TestPathName(const GenericEntry* pGenericEntry, virtual CString TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const const CString& basePath, const CString& newName, char newFssep) const override
{ ASSERT(false); return "!"; } { ASSERT(false); return "!"; }
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts) const RecompressOptionsDialog* pRecompOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts) ActionProgressDialog* pActionProgress,
const XferFileOptions* pXferOpts) override
{ ASSERT(false); return kXferFailed; } { ASSERT(false); return kXferFailed; }
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry, virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr) CString* pStr) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str) const CString& str) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps) const FileProps* pProps) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual void PreferencesChanged(void) {} virtual void PreferencesChanged(void) override {}
virtual long GetCapability(Capability cap); virtual long GetCapability(Capability cap) override;
friend class AcuEntry; friend class AcuEntry;
@ -130,19 +160,19 @@ private:
} }
return ""; return "";
} }
virtual void XferPrepare(const XferFileOptions* pXferOpts) virtual void XferPrepare(const XferFileOptions* pXferOpts) override
{ ASSERT(false); } { ASSERT(false); }
virtual CString XferFile(FileDetails* pDetails, unsigned char** pDataBuf, virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen) long dataLen, uint8_t** pRsrcBuf, long rsrcLen) override
{ ASSERT(false); return "!"; } { ASSERT(false); return "!"; }
virtual void XferAbort(CWnd* pMsgWnd) virtual void XferAbort(CWnd* pMsgWnd) override
{ ASSERT(false); } { ASSERT(false); }
virtual void XferFinish(CWnd* pMsgWnd) virtual void XferFinish(CWnd* pMsgWnd) override
{ ASSERT(false); } { ASSERT(false); }
virtual ArchiveKind GetArchiveKind(void) { return kArchiveACU; } virtual ArchiveKind GetArchiveKind(void) override { return kArchiveACU; }
virtual NuError DoAddFile(const AddFilesDialog* pAddOpts, virtual NuError DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails) FileDetails* pDetails) override
{ ASSERT(false); return kNuErrGeneric; } { ASSERT(false); return kNuErrGeneric; }
enum { enum {
@ -203,17 +233,62 @@ private:
kAcuCompSqueeze = 3, kAcuCompSqueeze = 3,
}; };
/*
* Load the contents of the archive.
*
* Returns 0 on success, < 0 if this is not an ACU archive > 0 if this appears
* to be an ACU archive but it's damaged.
*/
int LoadContents(void); int LoadContents(void);
/*
* Read the archive header. The archive file is left seeked to the point
* at the end of the header.
*
* Returns 0 on success, -1 on failure. Sets *pNumEntries to the number of
* entries in the archive.
*/
int ReadMasterHeader(int* pNumEntries); int ReadMasterHeader(int* pNumEntries);
/*
* Read and decode an AppleLink Compression Utility file entry header.
* This leaves the file seeked to the point immediately past the filename.
*/
NuError ReadFileHeader(AcuFileEntry* pEntry); NuError ReadFileHeader(AcuFileEntry* pEntry);
/*
* Dump the contents of an AcuFileEntry struct.
*/
void DumpFileHeader(const AcuFileEntry* pEntry); void DumpFileHeader(const AcuFileEntry* pEntry);
/*
* Given an AcuFileEntry structure, add an appropriate entry to the list.
*/
int CreateEntry(const AcuFileEntry* pEntry); int CreateEntry(const AcuFileEntry* pEntry);
/*
* Test if this entry is a directory.
*/
bool IsDir(const AcuFileEntry* pEntry); bool IsDir(const AcuFileEntry* pEntry);
/*
* Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S).
*/
NuError AcuRead(void* buf, size_t nbyte); NuError AcuRead(void* buf, size_t nbyte);
/*
* Seek within an archive. Because we need to handle streaming archives,
* and don't need to special-case anything, we only allow relative
* forward seeks.
*/
NuError AcuSeek(long offset); NuError AcuSeek(long offset);
void AcuConvertDateTime(unsigned short prodosDate,
unsigned short prodosTime, NuDateTime* pWhen); /*
* Convert from ProDOS compact date format to the expanded DateTime format.
*/
void AcuConvertDateTime(uint16_t prodosDate,
uint16_t prodosTime, NuDateTime* pWhen);
FILE* fFp; FILE* fFp;
bool fIsReadOnly; bool fIsReadOnly;

View File

@ -27,19 +27,10 @@ static const WCHAR kVersionExtra[] =
L" _DEBUG" L" _DEBUG"
#else #else
L"" L""
#endif
#ifdef _DEBUG_LOG
L" _LOG"
#else
L""
#endif #endif
; ;
/* BOOL AboutDialog::OnInitDialog(void)
* Update the static strings with DLL version numbers.
*/
BOOL
AboutDialog::OnInitDialog(void)
{ {
NuError nerr; NuError nerr;
long major, minor, bug; long major, minor, bug;
@ -120,8 +111,7 @@ AboutDialog::OnInitDialog(void)
* This is called during initialization and after new registration data is * This is called during initialization and after new registration data is
* entered successfully. * entered successfully.
*/ */
void void AboutDialog::ShowRegistrationInfo(void)
AboutDialog::ShowRegistrationInfo(void)
{ {
/* /*
* Pull out the registration info. We shouldn't need to do much in the * Pull out the registration info. We shouldn't need to do much in the
@ -185,11 +175,7 @@ AboutDialog::ShowRegistrationInfo(void)
#endif #endif
/* void AboutDialog::OnAboutCredits(void)
* User hit the "Credits" button.
*/
void
AboutDialog::OnAboutCredits(void)
{ {
WinHelp(HELP_TOPIC_CREDITS, HELP_CONTEXT /*HELP_CONTEXTPOPUP*/); WinHelp(HELP_TOPIC_CREDITS, HELP_CONTEXT /*HELP_CONTEXTPOPUP*/);
} }

View File

@ -9,7 +9,6 @@
#ifndef APP_ABOUTDIALOG_H #ifndef APP_ABOUTDIALOG_H
#define APP_ABOUTDIALOG_H #define APP_ABOUTDIALOG_H
//#include <afxwin.h>
#include "resource.h" #include "resource.h"
/* /*
@ -23,12 +22,17 @@ public:
{} {}
protected: protected:
// overrides /*
virtual BOOL OnInitDialog(void); * Update the static strings with DLL version numbers.
*/
virtual BOOL OnInitDialog(void) override;
/*
* User hit the "Credits" button.
*/
afx_msg void OnAboutCredits(void); afx_msg void OnAboutCredits(void);
afx_msg void OnEnterReg(void);
//afx_msg void OnEnterReg(void);
//void ShowRegistrationInfo(void); //void ShowRegistrationInfo(void);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()

View File

@ -15,11 +15,7 @@ BEGIN_MESSAGE_MAP(ActionProgressDialog, ProgressCancelDialog)
//ON_MESSAGE(WMU_START, OnStart) //ON_MESSAGE(WMU_START, OnStart)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL ActionProgressDialog::OnInitDialog(void)
* Initialize the static text controls to say something reasonable.
*/
BOOL
ActionProgressDialog::OnInitDialog(void)
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
@ -96,11 +92,7 @@ ActionProgressDialog::OnInitDialog(void)
return FALSE; return FALSE;
} }
/* void ActionProgressDialog::SetArcName(const WCHAR* str)
* Set the name of the file as it appears in the archive.
*/
void
ActionProgressDialog::SetArcName(const WCHAR* str)
{ {
CString oldStr; CString oldStr;
@ -111,8 +103,7 @@ ActionProgressDialog::SetArcName(const WCHAR* str)
pWnd->SetWindowText(str); pWnd->SetWindowText(str);
} }
const CString const CString ActionProgressDialog::GetFileName(void)
ActionProgressDialog::GetFileName(void)
{ {
CString str; CString str;
@ -123,11 +114,7 @@ ActionProgressDialog::GetFileName(void)
return str; return str;
} }
/* void ActionProgressDialog::SetFileName(const WCHAR* str)
* Set the name of the file as it appears under Windows.
*/
void
ActionProgressDialog::SetFileName(const WCHAR* str)
{ {
CString oldStr; CString oldStr;
@ -138,13 +125,7 @@ ActionProgressDialog::SetFileName(const WCHAR* str)
pWnd->SetWindowText(str); pWnd->SetWindowText(str);
} }
/* int ActionProgressDialog::SetProgress(int perc)
* Update the progress meter.
*
* We take a percentage, but the underlying control uses 1000ths.
*/
int
ActionProgressDialog::SetProgress(int perc)
{ {
ASSERT(perc >= 0 && perc <= 100); ASSERT(perc >= 0 && perc <= 100);
MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd(); MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd();

View File

@ -48,13 +48,33 @@ public:
DestroyWindow(); DestroyWindow();
} }
/*
* Set the name of the file as it appears in the archive.
*/
void SetArcName(const WCHAR* str); void SetArcName(const WCHAR* str);
/*
* Set the name of the file as it appears under Windows.
*/
void SetFileName(const WCHAR* str); void SetFileName(const WCHAR* str);
/*
* Get the name of the file as it appears under Windows.
*/
const CString GetFileName(void); const CString GetFileName(void);
/*
* Update the progress meter.
*
* We take a percentage, but the underlying control uses 1000ths.
*/
int SetProgress(int perc); int SetProgress(int perc);
private: private:
virtual BOOL OnInitDialog(void); /*
* Initialize the static text controls to say something reasonable.
*/
virtual BOOL OnInitDialog(void) override;
Action fAction; Action fAction;
bool fCancel; bool fCancel;

View File

@ -10,7 +10,6 @@
#include "stdafx.h" #include "stdafx.h"
#include "Main.h" #include "Main.h"
#include "ViewFilesDialog.h" #include "ViewFilesDialog.h"
//#include "ViewOptionsDialog.h"
#include "ChooseDirDialog.h" #include "ChooseDirDialog.h"
#include "AddFilesDialog.h" #include "AddFilesDialog.h"
#include "CreateSubdirDialog.h" #include "CreateSubdirDialog.h"
@ -31,7 +30,6 @@
#include "ChooseAddTargetDialog.h" #include "ChooseAddTargetDialog.h"
#include "CassetteDialog.h" #include "CassetteDialog.h"
#include "BasicImport.h" #include "BasicImport.h"
//#include "../util/UtilLib.h"
#include "../diskimg/TwoImg.h" #include "../diskimg/TwoImg.h"
#include <errno.h> #include <errno.h>
@ -42,36 +40,17 @@
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsView(void)
* View a file stored in the archive.
*
* Control bounces back through Get*FileText() to get the actual
* data to view.
*/
void
MainWindow::OnActionsView(void)
{ {
HandleView(); HandleView();
} }
void void MainWindow::OnUpdateActionsView(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsView(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && pCmdUI->Enable(fpContentList != NULL &&
fpContentList->GetSelectedCount() > 0); fpContentList->GetSelectedCount() > 0);
} }
void MainWindow::HandleView(void)
/*
* Handle a request to view stuff.
*
* If "query" is set, we ask the user to confirm some choices. If not, we
* just go with the defaults.
*
* We include "damaged" files so that we can show the user a nice message
* about how the file is damaged.
*/
void
MainWindow::HandleView(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
@ -87,8 +66,6 @@ MainWindow::HandleView(void)
return; return;
} }
//fpSelSet = &selSet;
ViewFilesDialog vfd(this); ViewFilesDialog vfd(this);
vfd.SetSelectionSet(&selSet); vfd.SetSelectionSet(&selSet);
vfd.SetTextTypeFace(fPreferences.GetPrefString(kPrViewTextTypeFace)); vfd.SetTextTypeFace(fPreferences.GetPrefString(kPrViewTextTypeFace));
@ -96,8 +73,6 @@ MainWindow::HandleView(void)
vfd.SetNoWrapText(fPreferences.GetPrefBool(kPrNoWrapText)); vfd.SetNoWrapText(fPreferences.GetPrefBool(kPrNoWrapText));
vfd.DoModal(); vfd.DoModal();
//fpSelSet = NULL;
// remember which font they used (sticky pref, not in registry) // remember which font they used (sticky pref, not in registry)
fPreferences.SetPrefString(kPrViewTextTypeFace, vfd.GetTextTypeFace()); fPreferences.SetPrefString(kPrViewTextTypeFace, vfd.GetTextTypeFace());
fPreferences.SetPrefLong(kPrViewTextPointSize, vfd.GetTextPointSize()); fPreferences.SetPrefLong(kPrViewTextPointSize, vfd.GetTextPointSize());
@ -113,14 +88,7 @@ MainWindow::HandleView(void)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsOpenAsDisk(void)
* View a file stored in the archive.
*
* Control bounces back through Get*FileText() to get the actual
* data to view.
*/
void
MainWindow::OnActionsOpenAsDisk(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpContentList->GetSelectedCount() == 1); ASSERT(fpContentList->GetSelectedCount() == 1);
@ -131,8 +99,7 @@ MainWindow::OnActionsOpenAsDisk(void)
else else
TmpExtractAndOpen(pEntry, GenericEntry::kDataThread, kModeDiskImage); TmpExtractAndOpen(pEntry, GenericEntry::kDataThread, kModeDiskImage);
} }
void void MainWindow::OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI)
{ {
const int kMinLen = 512 * 7; const int kMinLen = 512 * 7;
bool allow = false; bool allow = false;
@ -157,11 +124,7 @@ MainWindow::OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsAddFiles(void)
* Add files to an archive.
*/
void
MainWindow::OnActionsAddFiles(void)
{ {
LOGI("Add files!"); LOGI("Add files!");
AddFilesDialog addFiles(this); AddFilesDialog addFiles(this);
@ -266,21 +229,12 @@ MainWindow::OnActionsAddFiles(void)
LOGI("SFD bailed with Cancel"); LOGI("SFD bailed with Cancel");
} }
} }
void void MainWindow::OnUpdateActionsAddFiles(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsAddFiles(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly()); pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly());
} }
bool MainWindow::ChooseAddTarget(DiskImgLib::A2File** ppTargetSubdir,
/*
* Figure out where they want to add files.
*
* If the volume directory of a disk is chosen, "*ppTargetSubdir" will
* be set to NULL.
*/
bool
MainWindow::ChooseAddTarget(DiskImgLib::A2File** ppTargetSubdir,
DiskImgLib::DiskFS** ppTargetDiskFS) DiskImgLib::DiskFS** ppTargetDiskFS)
{ {
ASSERT(ppTargetSubdir != NULL); ASSERT(ppTargetSubdir != NULL);
@ -341,15 +295,7 @@ MainWindow::ChooseAddTarget(DiskImgLib::A2File** ppTargetSubdir,
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsAddDisks(void)
* Add a disk to an archive. Not all archive formats support disk images.
*
* We open a single disk archive file as a DiskImg, get the format
* figured out, then write it block-by-block into a file chosen by the user.
* Standard open/save dialogs work fine here.
*/
void
MainWindow::OnActionsAddDisks(void)
{ {
DIError dierr; DIError dierr;
DiskImg img; DiskImg img;
@ -489,8 +435,7 @@ MainWindow::OnActionsAddDisks(void)
bail: bail:
return; return;
} }
void void MainWindow::OnUpdateActionsAddDisks(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsAddDisks(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() && pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpOpenArchive->GetCapability(GenericArchive::kCapCanAddDisk)); fpOpenArchive->GetCapability(GenericArchive::kCapCanAddDisk));
@ -503,16 +448,7 @@ MainWindow::OnUpdateActionsAddDisks(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsCreateSubdir(void)
* Create a subdirectory inside another subdirectory (or volume directory).
*
* Simply asserting that an existing subdir be selected in the list does
* away with all sorts of testing. Creating subdirs on DOS disks and NuFX
* archives is impossible because neither has subdirs. Nested volumes are
* selected for us by the user.
*/
void
MainWindow::OnActionsCreateSubdir(void)
{ {
CreateSubdirDialog csDialog; CreateSubdirDialog csDialog;
@ -549,8 +485,7 @@ MainWindow::OnActionsCreateSubdir(void)
fpOpenArchive->CreateSubdir(this, pEntry, csDialog.fNewName); fpOpenArchive->CreateSubdir(this, pEntry, csDialog.fNewName);
fpContentList->Reload(); fpContentList->Reload();
} }
void void MainWindow::OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI)
{ {
bool enable = fpContentList != NULL && !fpOpenArchive->IsReadOnly() && bool enable = fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpContentList->GetSelectedCount() == 1 && fpContentList->GetSelectedCount() == 1 &&
@ -580,11 +515,7 @@ MainWindow::OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsExtract(void)
* Extract files.
*/
void
MainWindow::OnActionsExtract(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
@ -666,25 +597,21 @@ MainWindow::OnActionsExtract(void)
fpActionProgress->Cleanup(this); fpActionProgress->Cleanup(this);
fpActionProgress = NULL; fpActionProgress = NULL;
} }
void void MainWindow::OnUpdateActionsExtract(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsExtract(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL); pCmdUI->Enable(fpContentList != NULL);
} }
/* void MainWindow::DoBulkExtract(SelectionSet* pSelSet,
* Handle a bulk extraction.
*
* IMPORTANT: since the pActionProgress dialog has the foreground, it's
* vital that any MessageBox calls go through that. Otherwise the
* progress dialog message handler won't get disabled by MessageBox and
* we can end up permanently hiding the dialog. (Could also use
* ::MessageBox or ::AfxMessageBox instead.)
*/
void
MainWindow::DoBulkExtract(SelectionSet* pSelSet,
const ExtractOptionsDialog* pExtOpts) const ExtractOptionsDialog* pExtOpts)
{ {
/*
* IMPORTANT: since the pActionProgress dialog has the foreground, it's
* vital that any MessageBox calls go through that. Otherwise the
* progress dialog message handler won't get disabled by MessageBox and
* we can end up permanently hiding the dialog. (Could also use
* ::MessageBox or ::AfxMessageBox instead.)
*/
ReformatHolder* pHolder = NULL; ReformatHolder* pHolder = NULL;
bool overwriteExisting, ovwrForAll; bool overwriteExisting, ovwrForAll;
@ -790,17 +717,7 @@ MainWindow::DoBulkExtract(SelectionSet* pSelSet,
delete pHolder; delete pHolder;
} }
/* bool MainWindow::ExtractEntry(GenericEntry* pEntry, int thread,
* Extract a single entry.
*
* If "pHolder" is non-NULL, it holds the data from the file, and can be
* used for formatted or non-formatted output. If it's NULL, we need to
* extract the data ourselves.
*
* Returns "true" on success, "false" on failure.
*/
bool
MainWindow::ExtractEntry(GenericEntry* pEntry, int thread,
ReformatHolder* pHolder, const ExtractOptionsDialog* pExtOpts, ReformatHolder* pHolder, const ExtractOptionsDialog* pExtOpts,
bool* pOverwriteExisting, bool* pOvwrForAll) bool* pOverwriteExisting, bool* pOvwrForAll)
{ {
@ -1272,26 +1189,7 @@ open_file_fail:
return true; return true;
} }
int MainWindow::OpenOutputFile(CString* pOutputPath, const PathProposal& pathProp,
/*
* Open an output file.
*
* "outputPath" holds the name of the file to create. "origPath" is the
* name as it was stored in the archive. "pOverwriteExisting" tells us
* if we should just go ahead and overwrite the existing file, while
* "pOvwrForAll" tells us if a "To All" button was hit previously.
*
* If the file exists, "*pOverwriteExisting" is false, and "*pOvwrForAll"
* is false, then we will put up the "do you want to overwrite?" dialog.
* One possible outcome of the dialog is renaming the output path.
*
* On success, "*pFp" will be non-NULL, and IDOK will be returned. On
* failure, IDCANCEL will be returned. The values in "*pOverwriteExisting"
* and "*pOvwrForAll" may be updated, and "*pOutputPath" will change if
* the user chose to rename the file.
*/
int
MainWindow::OpenOutputFile(CString* pOutputPath, const PathProposal& pathProp,
time_t arcFileModWhen, bool* pOverwriteExisting, bool* pOvwrForAll, time_t arcFileModWhen, bool* pOverwriteExisting, bool* pOvwrForAll,
FILE** pFp) FILE** pFp)
{ {
@ -1402,11 +1300,7 @@ bail:
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsTest(void)
* Test files.
*/
void
MainWindow::OnActionsTest(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -1480,11 +1374,7 @@ MainWindow::OnUpdateActionsTest(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsDelete(void)
* Delete archive entries.
*/
void
MainWindow::OnActionsDelete(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -1571,8 +1461,7 @@ MainWindow::OnActionsDelete(void)
if (result) if (result)
SuccessBeep(); SuccessBeep();
} }
void void MainWindow::OnUpdateActionsDelete(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsDelete(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly()
&& fpContentList->GetSelectedCount() > 0); && fpContentList->GetSelectedCount() > 0);
@ -1585,13 +1474,7 @@ MainWindow::OnUpdateActionsDelete(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsRename(void)
* Rename archive entries. Depending on the structure of the underlying
* archive, we may only allow the user to alter the filename component.
* Anything else would constitute moving the file around in the filesystem.
*/
void
MainWindow::OnActionsRename(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -1626,8 +1509,7 @@ MainWindow::OnActionsRename(void)
// user interaction on each step, so skip the SuccessBeep // user interaction on each step, so skip the SuccessBeep
} }
void void MainWindow::OnUpdateActionsRename(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsRename(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly()
&& fpContentList->GetSelectedCount() > 0); && fpContentList->GetSelectedCount() > 0);
@ -1640,11 +1522,7 @@ MainWindow::OnUpdateActionsRename(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsEditComment(void)
* Edit a comment, creating it if necessary.
*/
void
MainWindow::OnActionsEditComment(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -1688,8 +1566,7 @@ MainWindow::OnActionsEditComment(void)
fpContentList->Reload(); fpContentList->Reload();
} }
} }
void void MainWindow::OnUpdateActionsEditComment(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsEditComment(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() && pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpContentList->GetSelectedCount() == 1 && fpContentList->GetSelectedCount() == 1 &&
@ -1703,17 +1580,7 @@ MainWindow::OnUpdateActionsEditComment(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsEditProps(void)
* Edit file properties.
*
* This causes a reload of the list, which isn't really necessary. We
* do need to re-evaluate the sort order if one of the fields they modified
* is the current sort key, but it would be nice if we could at least retain
* the selection. Since we're not reloading the GenericArchive, we *can*
* remember the selection.
*/
void
MainWindow::OnActionsEditProps(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -1742,8 +1609,7 @@ MainWindow::OnActionsEditProps(void)
fpContentList->Reload(true); fpContentList->Reload(true);
} }
} }
void void MainWindow::OnUpdateActionsEditProps(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsEditProps(CCmdUI* pCmdUI)
{ {
// allow it in read-only mode, so we can view the props // allow it in read-only mode, so we can view the props
pCmdUI->Enable(fpContentList != NULL && pCmdUI->Enable(fpContentList != NULL &&
@ -1757,11 +1623,7 @@ MainWindow::OnUpdateActionsEditProps(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsRenameVolume(void)
* Change a volume name or volume number.
*/
void
MainWindow::OnActionsRenameVolume(void)
{ {
RenameVolumeDialog rvDialog; RenameVolumeDialog rvDialog;
@ -1806,8 +1668,7 @@ MainWindow::OnActionsRenameVolume(void)
fpContentList->Reload(); fpContentList->Reload();
SetCPTitle(fOpenArchivePathName, fpOpenArchive); SetCPTitle(fOpenArchivePathName, fpOpenArchive);
} }
void void MainWindow::OnUpdateActionsRenameVolume(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsRenameVolume(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() && pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpOpenArchive->GetCapability(GenericArchive::kCapCanRenameVolume)); fpOpenArchive->GetCapability(GenericArchive::kCapCanRenameVolume));
@ -1820,11 +1681,7 @@ MainWindow::OnUpdateActionsRenameVolume(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsRecompress(void)
* Recompress files.
*/
void
MainWindow::OnActionsRecompress(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -1906,19 +1763,14 @@ MainWindow::OnActionsRecompress(void)
MessageBox(msg, appName, MB_OK|MB_ICONINFORMATION); MessageBox(msg, appName, MB_OK|MB_ICONINFORMATION);
} }
} }
void void MainWindow::OnUpdateActionsRecompress(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsRecompress(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() && pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpContentList->GetItemCount() > 0 && fpContentList->GetItemCount() > 0 &&
fpOpenArchive->GetCapability(GenericArchive::kCapCanRecompress)); fpOpenArchive->GetCapability(GenericArchive::kCapCanRecompress));
} }
/* void MainWindow::CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const
* Compute the total size of all files in the GenericArchive.
*/
void
MainWindow::CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const
{ {
GenericEntry* pEntry = fpOpenArchive->GetEntries(); GenericEntry* pEntry = fpOpenArchive->GetEntries();
LONGLONG uncomp = 0, comp = 0; LONGLONG uncomp = 0, comp = 0;
@ -1940,11 +1792,7 @@ MainWindow::CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsConvDisk(void)
* Select files to convert.
*/
void
MainWindow::OnActionsConvDisk(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -2074,8 +1922,7 @@ MainWindow::OnActionsConvDisk(void)
/* clean up */ /* clean up */
delete xferOpts.fTarget; delete xferOpts.fTarget;
} }
void void MainWindow::OnUpdateActionsConvDisk(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsConvDisk(CCmdUI* pCmdUI)
{ {
/* right now, only NufxArchive has the Xfer stuff implemented */ /* right now, only NufxArchive has the Xfer stuff implemented */
pCmdUI->Enable(fpContentList != NULL && pCmdUI->Enable(fpContentList != NULL &&
@ -2090,11 +1937,7 @@ MainWindow::OnUpdateActionsConvDisk(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsConvFile(void)
* Select files to convert.
*/
void
MainWindow::OnActionsConvFile(void)
{ {
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL); ASSERT(fpOpenArchive != NULL);
@ -2219,8 +2062,7 @@ MainWindow::OnActionsConvFile(void)
/* clean up */ /* clean up */
delete xferOpts.fTarget; delete xferOpts.fTarget;
} }
void void MainWindow::OnUpdateActionsConvFile(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsConvFile(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && pCmdUI->Enable(fpContentList != NULL &&
fpContentList->GetItemCount() > 0 && fpContentList->GetItemCount() > 0 &&
@ -2234,17 +2076,12 @@ MainWindow::OnUpdateActionsConvFile(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsConvToWav(void)
* Convert BAS, INT, or BIN to a cassette-audio WAV file.
*/
void
MainWindow::OnActionsConvToWav(void)
{ {
// do this someday // do this someday
LOGI("Convert TO wav"); LOGI("Convert TO wav");
} }
void void MainWindow::OnUpdateActionsConvToWav(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsConvToWav(CCmdUI* pCmdUI)
{ {
BOOL enable = false; BOOL enable = false;
@ -2264,12 +2101,7 @@ MainWindow::OnUpdateActionsConvToWav(CCmdUI* pCmdUI)
pCmdUI->Enable(enable); pCmdUI->Enable(enable);
} }
/* void MainWindow::OnActionsConvFromWav(void)
* Convert a WAV file with a digitized Apple II cassette tape into an
* Apple II file, and add it to the current disk.
*/
void
MainWindow::OnActionsConvFromWav(void)
{ {
CassetteDialog dlg; CassetteDialog dlg;
CString fileName, saveFolder; CString fileName, saveFolder;
@ -2301,22 +2133,12 @@ MainWindow::OnActionsConvFromWav(void)
bail: bail:
return; return;
} }
void void MainWindow::OnUpdateActionsConvFromWav(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsConvFromWav(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly()); pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly());
} }
/*static*/ bool MainWindow::SaveToArchive(GenericArchive::FileDetails* pDetails,
/*
* Utility function used by cassette import.
*
* May modify contents of "pDetails".
*
* On failure, returns with an error message in "errMsg".
*/
/*static*/ bool
MainWindow::SaveToArchive(GenericArchive::FileDetails* pDetails,
const unsigned char* dataBufIn, long dataLen, const unsigned char* dataBufIn, long dataLen,
const unsigned char* rsrcBufIn, long rsrcLen, const unsigned char* rsrcBufIn, long rsrcLen,
CString& errMsg, CWnd* pDialog) CString& errMsg, CWnd* pDialog)
@ -2410,14 +2232,7 @@ bail:
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnActionsImportBAS(void)
* Import an Applesoft BASIC program from a text file.
*
* We currently allow the user to select a single file for import. Someday
* we may want to allow multi-file import.
*/
void
MainWindow::OnActionsImportBAS(void)
{ {
ImportBASDialog dlg; ImportBASDialog dlg;
CString fileName, saveFolder; CString fileName, saveFolder;
@ -2437,7 +2252,7 @@ MainWindow::OnActionsImportBAS(void)
fileName = fileDlg.GetPathName(); fileName = fileDlg.GetPathName();
LOGI("Opening TXT file '%ls'", (LPCWSTR) fileName); LOGI("Opening TXT file '%ls'", (LPCWSTR) fileName);
dlg.fFileName = fileName; dlg.SetFileName(fileName);
// pass in fpOpenArchive? // pass in fpOpenArchive?
dlg.DoModal(); dlg.DoModal();
@ -2449,8 +2264,7 @@ MainWindow::OnActionsImportBAS(void)
bail: bail:
return; return;
} }
void void MainWindow::OnUpdateActionsImportBAS(CCmdUI* pCmdUI)
MainWindow::OnUpdateActionsImportBAS(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly()); pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly());
} }
@ -2462,15 +2276,7 @@ MainWindow::OnUpdateActionsImportBAS(CCmdUI* pCmdUI)
* ========================================================================== * ==========================================================================
*/ */
/* int MainWindow::GetFileParts(const GenericEntry* pEntry,
* Extract every part of the file into "ReformatHolder". Does not try to
* reformat anything, just extracts the parts.
*
* Returns IDOK on success, IDCANCEL if the user cancelled, or -1 on error.
* On error, the reformatted text buffer gets the error message.
*/
int
MainWindow::GetFileParts(const GenericEntry* pEntry,
ReformatHolder** ppHolder) const ReformatHolder** ppHolder) const
{ {
ReformatHolder* pHolder = new ReformatHolder; ReformatHolder* pHolder = new ReformatHolder;
@ -2493,11 +2299,7 @@ MainWindow::GetFileParts(const GenericEntry* pEntry,
return 0; return 0;
} }
/* void MainWindow::GetFilePart(const GenericEntry* pEntry, int whichThread,
* Load the requested part.
*/
void
MainWindow::GetFilePart(const GenericEntry* pEntry, int whichThread,
ReformatHolder* pHolder) const ReformatHolder* pHolder) const
{ {
CString errMsg; CString errMsg;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for AddClashDialog class.
*/
#include "stdafx.h" #include "stdafx.h"
#include "ConfirmOverwriteDialog.h" #include "ConfirmOverwriteDialog.h"
#include "AddClashDialog.h" #include "AddClashDialog.h"
@ -17,10 +14,9 @@ BEGIN_MESSAGE_MAP(AddClashDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* /*
* Replace some static text fields. * Replaces some static text fields.
*/ */
BOOL BOOL AddClashDialog::OnInitDialog(void)
AddClashDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
@ -35,17 +31,13 @@ AddClashDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void AddClashDialog::OnSkip(void)
* One of the buttons was hit.
*/
void
AddClashDialog::OnSkip(void)
{ {
fDoRename = false; fDoRename = false;
CDialog::OnOK(); CDialog::OnOK();
} }
void
AddClashDialog::OnRename(void) void AddClashDialog::OnRename(void)
{ {
RenameOverwriteDialog dlg; RenameOverwriteDialog dlg;

View File

@ -3,14 +3,11 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Resolve a filename clash when adding files.
*/
#ifndef APP_ADDCLASHDIALOG_H #ifndef APP_ADDCLASHDIALOG_H
#define APP_ADDCLASHDIALOG_H #define APP_ADDCLASHDIALOG_H
/* /*
* * Dialog for resolving a filename clash.
*/ */
class AddClashDialog : public CDialog { class AddClashDialog : public CDialog {
public: public:
@ -31,7 +28,7 @@ private:
afx_msg void OnRename(void); afx_msg void OnRename(void);
afx_msg void OnSkip(void); afx_msg void OnSkip(void);
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
}; };

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for the "add files" dialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "AddFilesDialog.h" #include "AddFilesDialog.h"
#include "FileNameConv.h" #include "FileNameConv.h"
@ -23,8 +20,7 @@
* "false" indication occurs during saveAndValidate==true, and means that we * "false" indication occurs during saveAndValidate==true, and means that we
* shouldn't allow the dialog to close yet. * shouldn't allow the dialog to close yet.
*/ */
bool bool AddFilesDialog::MyDataExchange(bool saveAndValidate)
AddFilesDialog::MyDataExchange(bool saveAndValidate)
{ {
CWnd* pWnd; CWnd* pWnd;
@ -113,11 +109,7 @@ AddFilesDialog::MyDataExchange(bool saveAndValidate)
} }
} }
/* bool AddFilesDialog::ValidateStoragePrefix(void)
* Make sure the storage prefix they entered is valid.
*/
bool
AddFilesDialog::ValidateStoragePrefix(void)
{ {
if (fStoragePrefix.IsEmpty()) if (fStoragePrefix.IsEmpty())
return true; return true;
@ -135,11 +127,7 @@ AddFilesDialog::ValidateStoragePrefix(void)
} }
/* UINT AddFilesDialog::MyOnCommand(WPARAM wParam, LPARAM lParam)
* Override base class version.
*/
UINT
AddFilesDialog::MyOnCommand(WPARAM wParam, LPARAM lParam)
{ {
switch (wParam) { switch (wParam) {
case IDHELP: case IDHELP:
@ -150,14 +138,7 @@ AddFilesDialog::MyOnCommand(WPARAM wParam, LPARAM lParam)
} }
} }
/* void AddFilesDialog::ShiftControls(int deltaX, int deltaY)
* Override base class version so we can move our stuff around.
*
* It's important that the base class be called last, because it calls
* Invalidate to redraw the dialog.
*/
void
AddFilesDialog::ShiftControls(int deltaX, int deltaY)
{ {
/* /*
* These only need to be here so that the initial move puts them * These only need to be here so that the initial move puts them
@ -185,14 +166,15 @@ AddFilesDialog::ShiftControls(int deltaX, int deltaY)
*/ */
MoveControl(this, IDHELP, deltaX, deltaY, false); MoveControl(this, IDHELP, deltaX, deltaY, false);
StretchControl(this, IDC_ADDFILES_PREFIX, deltaX, 0, false); StretchControl(this, IDC_ADDFILES_PREFIX, deltaX, 0, false);
/*
* It's important that the base class be called last, because it calls
* Invalidate to redraw the dialog.
*/
SelectFilesDialog::ShiftControls(deltaX, deltaY); SelectFilesDialog::ShiftControls(deltaX, deltaY);
} }
/* void AddFilesDialog::OnIDHelp(void)
* User pressed the "Help" button.
*/
void
AddFilesDialog::OnIDHelp(void)
{ {
CWnd* pWndMain = ::AfxGetMainWnd(); CWnd* pWndMain = ::AfxGetMainWnd();
CWinApp* pAppMain = ::AfxGetApp(); CWinApp* pAppMain = ::AfxGetApp();

View File

@ -67,11 +67,22 @@ public:
DiskImgLib::DiskImg* fpDiskImg; DiskImgLib::DiskImg* fpDiskImg;
private: private:
virtual bool MyDataExchange(bool saveAndValidate); virtual bool MyDataExchange(bool saveAndValidate) override;
virtual void ShiftControls(int deltaX, int deltaY);
virtual UINT MyOnCommand(WPARAM wParam, LPARAM lParam);
/*
* Overrides base class version so we can move our stuff around.
*/
virtual void ShiftControls(int deltaX, int deltaY) override;
// Grabs OnIDHelp; otherwise forwards to base class.
virtual UINT MyOnCommand(WPARAM wParam, LPARAM lParam) override;
// User hit the Help button.
void OnIDHelp(void); void OnIDHelp(void);
/*
* Make sure the storage prefix they entered is valid.
*/
bool ValidateStoragePrefix(void); bool ValidateStoragePrefix(void);
//DECLARE_MESSAGE_MAP() //DECLARE_MESSAGE_MAP()

View File

@ -21,11 +21,7 @@ BEGIN_MESSAGE_MAP(ArchiveInfoDialog, CDialog)
ON_COMMAND(IDHELP, OnHelp) ON_COMMAND(IDHELP, OnHelp)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* void ArchiveInfoDialog::OnHelp(void)
* Show general help for the archive info dialogs.
*/
void
ArchiveInfoDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_ARCHIVE_INFO, HELP_CONTEXT); WinHelp(HELP_TOPIC_ARCHIVE_INFO, HELP_CONTEXT);
} }
@ -37,11 +33,7 @@ ArchiveInfoDialog::OnHelp(void)
* =========================================================================== * ===========================================================================
*/ */
/* BOOL NufxArchiveInfoDialog::OnInitDialog(void)
* Set up fields with NuFX archive info.
*/
BOOL
NufxArchiveInfoDialog::OnInitDialog(void)
{ {
CString notAvailable = "(not available)"; CString notAvailable = "(not available)";
NuArchive* pNuArchive; NuArchive* pNuArchive;
@ -122,11 +114,7 @@ BEGIN_MESSAGE_MAP(DiskArchiveInfoDialog, ArchiveInfoDialog)
ON_CBN_SELCHANGE(IDC_AIDISK_SUBVOLSEL, OnSubVolSelChange) ON_CBN_SELCHANGE(IDC_AIDISK_SUBVOLSEL, OnSubVolSelChange)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL DiskArchiveInfoDialog::OnInitDialog(void)
* Set up fields with disk archive info.
*/
BOOL
DiskArchiveInfoDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString tmpStr; CString tmpStr;
@ -192,12 +180,8 @@ DiskArchiveInfoDialog::OnInitDialog(void)
return ArchiveInfoDialog::OnInitDialog(); return ArchiveInfoDialog::OnInitDialog();
} }
/* void DiskArchiveInfoDialog::AddSubVolumes(const DiskFS* pDiskFS,
* Recursively add sub-volumes to the list. const WCHAR* prefix, int* pIdx)
*/
void
DiskArchiveInfoDialog::AddSubVolumes(const DiskFS* pDiskFS, const WCHAR* prefix,
int* pIdx)
{ {
CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_AIDISK_SUBVOLSEL); CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_AIDISK_SUBVOLSEL);
CString tmpStr; CString tmpStr;
@ -225,11 +209,7 @@ DiskArchiveInfoDialog::AddSubVolumes(const DiskFS* pDiskFS, const WCHAR* prefix,
} }
} }
/* void DiskArchiveInfoDialog::OnSubVolSelChange(void)
* The user has changed their selection in the sub-volume pulldown menu.
*/
void
DiskArchiveInfoDialog::OnSubVolSelChange(void)
{ {
CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_AIDISK_SUBVOLSEL); CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_AIDISK_SUBVOLSEL);
ASSERT(pCombo != NULL); ASSERT(pCombo != NULL);
@ -241,11 +221,7 @@ DiskArchiveInfoDialog::OnSubVolSelChange(void)
FillInVolumeInfo(pDiskFS); FillInVolumeInfo(pDiskFS);
} }
/* void DiskArchiveInfoDialog::FillInVolumeInfo(const DiskFS* pDiskFS)
* Fill in the volume-specific info fields.
*/
void
DiskArchiveInfoDialog::FillInVolumeInfo(const DiskFS* pDiskFS)
{ {
const DiskImg* pDiskImg = pDiskFS->GetDiskImg(); const DiskImg* pDiskImg = pDiskFS->GetDiskImg();
CString unknown = L"(unknown)"; CString unknown = L"(unknown)";
@ -356,11 +332,7 @@ DiskArchiveInfoDialog::FillInVolumeInfo(const DiskFS* pDiskFS)
pWnd->SetWindowText(tmpStr); pWnd->SetWindowText(tmpStr);
} }
/* void DiskArchiveInfoDialog::GetReducedSize(long numUnits, int unitSize,
* Reduce a size to something meaningful (KB, MB, GB).
*/
void
DiskArchiveInfoDialog::GetReducedSize(long numUnits, int unitSize,
CString* pOut) const CString* pOut) const
{ {
LONGLONG sizeInBytes = numUnits; LONGLONG sizeInBytes = numUnits;
@ -391,13 +363,7 @@ DiskArchiveInfoDialog::GetReducedSize(long numUnits, int unitSize,
* =========================================================================== * ===========================================================================
*/ */
/* BOOL BnyArchiveInfoDialog::OnInitDialog(void)
* Set up fields with Binary II info.
*
* Binary II files are pretty dull.
*/
BOOL
BnyArchiveInfoDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString tmpStr; CString tmpStr;
@ -420,11 +386,7 @@ BnyArchiveInfoDialog::OnInitDialog(void)
* =========================================================================== * ===========================================================================
*/ */
/* BOOL AcuArchiveInfoDialog::OnInitDialog(void)
* Set up fields with ACU info.
*/
BOOL
AcuArchiveInfoDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString tmpStr; CString tmpStr;

View File

@ -28,6 +28,9 @@ public:
virtual ~ArchiveInfoDialog(void) {} virtual ~ArchiveInfoDialog(void) {}
private: private:
/*
* Show general help for the archive info dialogs.
*/
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
@ -45,8 +48,7 @@ public:
virtual ~NufxArchiveInfoDialog(void) {} virtual ~NufxArchiveInfoDialog(void) {}
private: private:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void);
NufxArchive* fpArchive; NufxArchive* fpArchive;
}; };
@ -63,14 +65,27 @@ public:
virtual ~DiskArchiveInfoDialog(void) {} virtual ~DiskArchiveInfoDialog(void) {}
private: private:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void);
/*
* The user has changed their selection in the sub-volume pulldown menu.
*/
afx_msg void OnSubVolSelChange(void); afx_msg void OnSubVolSelChange(void);
/*
* Fill in the volume-specific info fields.
*/
void FillInVolumeInfo(const DiskFS* pDiskFS); void FillInVolumeInfo(const DiskFS* pDiskFS);
/*
* Recursively add sub-volumes to the list.
*/
void AddSubVolumes(const DiskFS* pDiskFS, const WCHAR* prefix, void AddSubVolumes(const DiskFS* pDiskFS, const WCHAR* prefix,
int* pIdx); int* pIdx);
/*
* Reduce a size to something meaningful (KB, MB, GB).
*/
void GetReducedSize(long numUnits, int unitSize, void GetReducedSize(long numUnits, int unitSize,
CString* pOut) const; CString* pOut) const;
@ -91,8 +106,7 @@ public:
virtual ~BnyArchiveInfoDialog(void) {} virtual ~BnyArchiveInfoDialog(void) {}
private: private:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void);
BnyArchive* fpArchive; BnyArchive* fpArchive;
}; };
@ -109,8 +123,7 @@ public:
virtual ~AcuArchiveInfoDialog(void) {} virtual ~AcuArchiveInfoDialog(void) {}
private: private:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void);
AcuArchive* fpArchive; AcuArchive* fpArchive;
}; };

View File

@ -21,24 +21,7 @@
* =========================================================================== * ===========================================================================
*/ */
/* int BnyEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
* Extract data from an entry.
*
* If "*ppText" is non-NULL, the data will be read into the pointed-to buffer
* so long as it's shorter than *pLength bytes. The value in "*pLength"
* will be set to the actual length used.
*
* If "*ppText" is NULL, the uncompressed data will be placed into a buffer
* allocated with "new[]".
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pErrMsg" holds an error
* message.
*
* "which" is an anonymous GenericArchive enum (e.g. "kDataThread").
*/
int
BnyEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const CString* pErrMsg) const
{ {
NuError nerr; NuError nerr;
@ -161,16 +144,7 @@ bail:
return result; return result;
} }
/* int BnyEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
* Extract data from a thread to a file. Since we're not copying to memory,
* we can't assume that we're able to hold the entire file all at once.
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pMsg" holds an
* error message.
*/
int
BnyEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const ConvertHighASCII convHA, CString* pErrMsg) const
{ {
NuError nerr; NuError nerr;
@ -259,12 +233,7 @@ bail:
return result; return result;
} }
/* NuError BnyEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError
BnyEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const CString* pMsg) const
{ {
NuError nerr = kNuErrNone; NuError nerr = kNuErrNone;
@ -312,15 +281,7 @@ bail:
return nerr; return nerr;
} }
NuError BnyEntry::TestEntry(CWnd* pMsgWnd)
/*
* Test this entry by extracting it.
*
* If the file isn't compressed, just make sure the file is big enough. If
* it's squeezed, invoke the un-squeeze function with a "NULL" buffer pointer.
*/
NuError
BnyEntry::TestEntry(CWnd* pMsgWnd)
{ {
NuError nerr = kNuErrNone; NuError nerr = kNuErrNone;
CString errMsg; CString errMsg;
@ -373,25 +334,15 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* /*static*/ CString BnyArchive::AppInit(void)
* Perform one-time initialization. There really isn't any for us. Having
* this is kind of silly, but we include it for consistency.
*
* Returns 0 on success, nonzero on error.
*/
/*static*/ CString
BnyArchive::AppInit(void)
{ {
return ""; // We don't really have anything to initialize. Having this method
// is kind of silly, but we include it for consistency.
return L"";
} }
/* GenericArchive::OpenResult BnyArchive::Open(const WCHAR* filename,
* Open a BNY archive. bool readOnly, CString* pErrMsg)
*
* Returns an error string on failure, or "" on success.
*/
GenericArchive::OpenResult
BnyArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
{ {
CString errMsg; CString errMsg;
@ -423,24 +374,14 @@ bail:
return kResultSuccess; return kResultSuccess;
} }
/* CString BnyArchive::New(const WCHAR* /*filename*/, const void* /*options*/)
* Finish instantiating a BnyArchive object by creating a new archive.
*
* Returns an error string on failure, or "" on success.
*/
CString
BnyArchive::New(const WCHAR* /*filename*/, const void* /*options*/)
{ {
CString retmsg(L"Sorry, Binary II files can't be created."); CString retmsg(L"Sorry, Binary II files can't be created.");
return retmsg; return retmsg;
} }
/* long BnyArchive::GetCapability(Capability cap)
* Our capabilities.
*/
long
BnyArchive::GetCapability(Capability cap)
{ {
switch (cap) { switch (cap) {
case kCapCanTest: case kCapCanTest:
@ -474,14 +415,7 @@ BnyArchive::GetCapability(Capability cap)
} }
} }
int BnyArchive::LoadContents(void)
/*
* Load the contents of the archive.
*
* Returns 0 on success, nonzero on failure.
*/
int
BnyArchive::LoadContents(void)
{ {
NuError nerr; NuError nerr;
@ -493,11 +427,7 @@ BnyArchive::LoadContents(void)
return (nerr != kNuErrNone); return (nerr != kNuErrNone);
} }
/* CString BnyArchive::Reload(void)
* Reload the contents of the archive.
*/
CString
BnyArchive::Reload(void)
{ {
fReloadFlag = true; // tell everybody that cached data is invalid fReloadFlag = true; // tell everybody that cached data is invalid
@ -509,13 +439,7 @@ BnyArchive::Reload(void)
return ""; return "";
} }
/* NuError BnyArchive::LoadContentsCallback(BnyFileEntry* pEntry)
* Given a BnyFileEntry structure, add an appropriate entry to the list.
*
* Note this can mangle pEntry (notably the filename).
*/
NuError
BnyArchive::LoadContentsCallback(BnyFileEntry* pEntry)
{ {
const int kBNYFssep = '/'; const int kBNYFssep = '/';
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -599,20 +523,12 @@ BnyArchive::LoadContentsCallback(BnyFileEntry* pEntry)
* included here. * included here.
*/ */
/* bool BnyArchive::IsSqueezed(uint8_t one, uint8_t two)
* Test for the magic number on a file in SQueezed format.
*/
bool
BnyArchive::IsSqueezed(uchar one, uchar two)
{ {
return (one == 0x76 && two == 0xff); return (one == 0x76 && two == 0xff);
} }
/* bool BnyArchive::IsDir(BnyFileEntry* pEntry)
* Test if this entry is a directory.
*/
bool
BnyArchive::IsDir(BnyFileEntry* pEntry)
{ {
/* /*
* NuLib and "unblu.c" compared against file type 15 (DIR), so I'm * NuLib and "unblu.c" compared against file type 15 (DIR), so I'm
@ -622,12 +538,7 @@ BnyArchive::IsDir(BnyFileEntry* pEntry)
return (pEntry->fileType == 15); return (pEntry->fileType == 15);
} }
/* NuError BnyArchive::BNYRead(void* buf, size_t nbyte)
* Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S).
*/
NuError
BnyArchive::BNYRead(void* buf, size_t nbyte)
{ {
size_t result; size_t result;
@ -642,18 +553,12 @@ BnyArchive::BNYRead(void* buf, size_t nbyte)
return kNuErrNone; return kNuErrNone;
} }
/* NuError BnyArchive::BNYSeek(long offset)
* Seek within an archive. Because we need to handle streaming archives,
* and don't need to special-case anything, we only allow relative
* forward seeks.
*/
NuError
BnyArchive::BNYSeek(long offset)
{ {
ASSERT(fFp != NULL); ASSERT(fFp != NULL);
ASSERT(offset > 0); ASSERT(offset > 0);
/*DBUG(("--- seeking forward %ld bytes\n", offset));*/ LOGV("--- seeking forward %ld bytes\n", offset);
if (fseek(fFp, offset, SEEK_CUR) < 0) if (fseek(fFp, offset, SEEK_CUR) < 0)
return kNuErrFileSeek; return kNuErrFileSeek;
@ -662,11 +567,7 @@ BnyArchive::BNYSeek(long offset)
} }
/* void BnyArchive::BNYConvertDateTime(unsigned short prodosDate,
* Convert from ProDOS compact date format to the expanded DateTime format.
*/
void
BnyArchive::BNYConvertDateTime(unsigned short prodosDate,
unsigned short prodosTime, NuDateTime* pWhen) unsigned short prodosTime, NuDateTime* pWhen)
{ {
pWhen->second = 0; pWhen->second = 0;
@ -681,17 +582,14 @@ BnyArchive::BNYConvertDateTime(unsigned short prodosDate,
pWhen->weekDay = 0; pWhen->weekDay = 0;
} }
/* NuError BnyArchive::BNYDecodeHeader(BnyFileEntry* pEntry)
* Decode a Binary II header.
*
* See the File Type Note for $e0/8000 to decipher the buffer offsets
* and meanings.
*/
NuError
BnyArchive::BNYDecodeHeader(BnyFileEntry* pEntry)
{ {
/*
* See the File Type Note for $e0/8000 to decipher the buffer offsets
* and meanings.
*/
NuError err = kNuErrNone; NuError err = kNuErrNone;
uchar* raw; uint8_t* raw;
int len; int len;
ASSERT(pEntry != NULL); ASSERT(pEntry != NULL);
@ -852,11 +750,7 @@ bail:
#endif #endif
/* NuError BnyArchive::BNYIterate(void)
* Iterate through a Binary II archive, loading the data.
*/
NuError
BnyArchive::BNYIterate(void)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
BnyFileEntry entry; BnyFileEntry entry;
@ -944,11 +838,7 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* bool BnyArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
* Test the records represented in the selection set.
*/
bool
BnyArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{ {
NuError nerr; NuError nerr;
BnyEntry* pEntry; BnyEntry* pEntry;

View File

@ -24,14 +24,15 @@ public:
{} {}
virtual ~BnyEntry(void) {} virtual ~BnyEntry(void) {}
// retrieve thread data
virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength, virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const; CString* pErrMsg) const override;
virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv, virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const; ConvertHighASCII convHA, CString* pErrMsg) const override;
virtual long GetSelectionSerial(void) const { return -1; } // doesn't matter
virtual bool GetFeatureFlag(Feature feature) const { virtual long GetSelectionSerial(void) const override
{ return -1; } // doesn't matter
virtual bool GetFeatureFlag(Feature feature) const override {
if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes || if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes ||
feature == kFeatureHasSimpleAccess) feature == kFeatureHasSimpleAccess)
return false; return false;
@ -39,6 +40,12 @@ public:
return true; return true;
} }
/*
* Test this entry by extracting it.
*
* If the file isn't compressed, just make sure the file is big enough. If
* it's squeezed, invoke the un-squeeze function with a "NULL" buffer pointer.
*/
NuError TestEntry(CWnd* pMsgWnd); NuError TestEntry(CWnd* pMsgWnd);
bool GetSqueezed(void) const { return fIsSqueezed; } bool GetSqueezed(void) const { return fIsSqueezed; }
@ -51,6 +58,10 @@ public:
}; };
private: private:
/*
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA, NuError CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const; CString* pMsg) const;
//NuError BNYUnSqueeze(ExpandBuffer* outExp) const; //NuError BNYUnSqueeze(ExpandBuffer* outExp) const;
@ -74,55 +85,57 @@ public:
static CString AppInit(void); static CString AppInit(void);
virtual OpenResult Open(const WCHAR* filename, bool readOnly, virtual OpenResult Open(const WCHAR* filename, bool readOnly,
CString* pErrMsg); CString* pErrMsg) override;
virtual CString New(const WCHAR* filename, const void* options); virtual CString New(const WCHAR* filename, const void* options) override;
virtual CString Flush(void) { return ""; } virtual CString Flush(void) override { return ""; }
virtual CString Reload(void); virtual CString Reload(void) override;
virtual bool IsReadOnly(void) const { return fIsReadOnly; }; virtual bool IsReadOnly(void) const override { return fIsReadOnly; };
virtual bool IsModified(void) const { return false; } virtual bool IsModified(void) const override { return false; }
virtual void GetDescription(CString* pStr) const { *pStr = "Binary II"; } virtual void GetDescription(CString* pStr) const override { *pStr = "Binary II"; }
virtual bool BulkAdd(ActionProgressDialog* pActionProgress, virtual bool BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool AddDisk(ActionProgressDialog* pActionProgress, virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry, virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName) const WCHAR* newName) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet); virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS, virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName) const WCHAR* newName) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual CString TestVolumeName(const DiskFS* pDiskFS, virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const const WCHAR* newName) const override
{ ASSERT(false); return "!"; } { ASSERT(false); return "!"; }
virtual CString TestPathName(const GenericEntry* pGenericEntry, virtual CString TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const const CString& basePath, const CString& newName,
char newFssep) const override
{ ASSERT(false); return "!"; } { ASSERT(false); return "!"; }
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts) const RecompressOptionsDialog* pRecompOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts) ActionProgressDialog* pActionProgress,
const XferFileOptions* pXferOpts) override
{ ASSERT(false); return kXferFailed; } { ASSERT(false); return kXferFailed; }
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry, virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr) CString* pStr) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str) const CString& str) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps) const FileProps* pProps) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual void PreferencesChanged(void) {} virtual void PreferencesChanged(void) override {}
virtual long GetCapability(Capability cap); virtual long GetCapability(Capability cap) override;
friend class BnyEntry; friend class BnyEntry;
@ -134,19 +147,19 @@ private:
} }
return ""; return "";
} }
virtual void XferPrepare(const XferFileOptions* pXferOpts) virtual void XferPrepare(const XferFileOptions* pXferOpts) override
{ ASSERT(false); } { ASSERT(false); }
virtual CString XferFile(FileDetails* pDetails, unsigned char** pDataBuf, virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen) long dataLen, uint8_t** pRsrcBuf, long rsrcLen) override
{ ASSERT(false); return "!"; } { ASSERT(false); return "!"; }
virtual void XferAbort(CWnd* pMsgWnd) virtual void XferAbort(CWnd* pMsgWnd) override
{ ASSERT(false); } { ASSERT(false); }
virtual void XferFinish(CWnd* pMsgWnd) virtual void XferFinish(CWnd* pMsgWnd) override
{ ASSERT(false); } { ASSERT(false); }
virtual ArchiveKind GetArchiveKind(void) { return kArchiveBNY; } virtual ArchiveKind GetArchiveKind(void) override { return kArchiveBNY; }
virtual NuError DoAddFile(const AddFilesDialog* pAddOpts, virtual NuError DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails) FileDetails* pDetails) override
{ ASSERT(false); return kNuErrGeneric; } { ASSERT(false); return kNuErrGeneric; }
enum { enum {
@ -158,10 +171,6 @@ private:
kBNYFlagSparse = (1), kBNYFlagSparse = (1),
}; };
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned long ulong;
/* /*
* An entry in a Binary II archive. Each archive is essentially a stream * An entry in a Binary II archive. Each archive is essentially a stream
* of files; only the "filesToFollow" value gives any indication that * of files; only the "filesToFollow" value gives any indication that
@ -170,45 +179,81 @@ private:
* We read this from the archive and then unpack it into GenericEntry * We read this from the archive and then unpack it into GenericEntry
* fields in a BnyEntry. * fields in a BnyEntry.
*/ */
struct BnyFileEntry; // VC++6 needs these to access private enums // struct BnyFileEntry; // VC++6 needs these to access private enums
friend struct BnyFileEntry; // in this class // friend struct BnyFileEntry; // in this class
typedef struct BnyFileEntry { typedef struct BnyFileEntry {
ushort access; uint16_t access;
ushort fileType; uint16_t fileType;
ulong auxType; uint32_t auxType;
uchar storageType; uint8_t storageType;
ulong fileSize; /* in 512-byte blocks */ uint32_t fileSize; /* in 512-byte blocks */
ushort prodosModDate; uint16_t prodosModDate;
ushort prodosModTime; uint16_t prodosModTime;
NuDateTime modWhen; /* computed from previous two fields */ NuDateTime modWhen; /* computed from previous two fields */
ushort prodosCreateDate; uint16_t prodosCreateDate;
ushort prodosCreateTime; uint16_t prodosCreateTime;
NuDateTime createWhen; /* computed from previous two fields */ NuDateTime createWhen; /* computed from previous two fields */
ulong eof; uint32_t eof;
ulong realEOF; /* eof is bogus for directories */ uint32_t realEOF; /* eof is bogus for directories */
char fileName[kBNYMaxFileName+1]; char fileName[kBNYMaxFileName+1];
char nativeName[kBNYMaxNativeName+1]; char nativeName[kBNYMaxNativeName+1];
ulong diskSpace; /* in 512-byte blocks */ uint32_t diskSpace; /* in 512-byte blocks */
uchar osType; /* not exactly same as NuFileSysID */ uint8_t osType; /* not exactly same as NuFileSysID */
ushort nativeFileType; uint16_t nativeFileType;
uchar phantomFlag; uint8_t phantomFlag;
uchar dataFlags; /* advisory flags */ uint8_t dataFlags; /* advisory flags */
uchar version; uint8_t version;
uchar filesToFollow; /* #of files after this one */ uint8_t filesToFollow; /* #of files after this one */
uchar blockBuf[kBNYBlockSize]; uint8_t blockBuf[kBNYBlockSize];
} BnyFileEntry; } BnyFileEntry;
int LoadContents(void); int LoadContents(void);
/*
* Given a BnyFileEntry structure, add an appropriate entry to the list.
*
* Note this can mangle pEntry (notably the filename).
*/
NuError LoadContentsCallback(BnyFileEntry* pEntry); NuError LoadContentsCallback(BnyFileEntry* pEntry);
bool IsSqueezed(uchar one, uchar two); /*
* Test for the magic number on a file in SQueezed format.
*/
bool IsSqueezed(uint8_t one, uint8_t two);
/*
* Test if this entry is a directory.
*/
bool IsDir(BnyFileEntry* pEntry); bool IsDir(BnyFileEntry* pEntry);
/*
* Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S).
*/
NuError BNYRead(void* buf, size_t nbyte); NuError BNYRead(void* buf, size_t nbyte);
/*
* Seek within an archive. Because we need to handle streaming archives,
* and don't need to special-case anything, we only allow relative
* forward seeks.
*/
NuError BNYSeek(long offset); NuError BNYSeek(long offset);
/*
* Convert from ProDOS compact date format to the expanded DateTime format.
*/
void BNYConvertDateTime(unsigned short prodosDate, void BNYConvertDateTime(unsigned short prodosDate,
unsigned short prodosTime, NuDateTime* pWhen); unsigned short prodosTime, NuDateTime* pWhen);
/*
* Decode a Binary II header.
*/
NuError BNYDecodeHeader(BnyFileEntry* pEntry); NuError BNYDecodeHeader(BnyFileEntry* pEntry);
/*
* Iterate through a Binary II archive, loading the data.
*/
NuError BNYIterate(void); NuError BNYIterate(void);
FILE* fFp; FILE* fFp;

View File

@ -21,12 +21,7 @@
* ========================================================================== * ==========================================================================
*/ */
/* void BASTokenLookup::Init(const char* tokenList, int numTokens, int tokenLen)
* Constructor. Pass in the info for the token blob.
*/
void
BASTokenLookup::Init(const char* tokenList, int numTokens,
int tokenLen)
{ {
int i; int i;
@ -49,13 +44,7 @@ BASTokenLookup::Init(const char* tokenList, int numTokens,
} }
} }
/* int BASTokenLookup::Lookup(const char* str, int len, int* pFoundLen)
* Return the index of the longest token that matches "str".
*
* Returns -1 if no match is found.
*/
int
BASTokenLookup::Lookup(const char* str, int len, int* pFoundLen)
{ {
int longestIndex, longestLen; int longestIndex, longestLen;
int i; int i;
@ -86,11 +75,7 @@ BEGIN_MESSAGE_MAP(ImportBASDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL ImportBASDialog::OnInitDialog(void)
* Set up the dialog.
*/
BOOL
ImportBASDialog::OnInitDialog(void)
{ {
CDialog::OnInitDialog(); // base class init CDialog::OnInitDialog(); // base class init
@ -119,14 +104,10 @@ ImportBASDialog::OnInitDialog(void)
return FALSE; // keep our focus return FALSE; // keep our focus
} }
static const char* kFailed = "failed.\r\n\r\n"; static const char kFailed[] = "failed.\r\n\r\n";
static const char* kSuccess = "success!\r\n\r\n"; static const char kSuccess[] = "success!\r\n\r\n";
/* bool ImportBASDialog::ImportBAS(const WCHAR* fileName)
* Import an Applesoft BASIC program from the specified file.
*/
bool
ImportBASDialog::ImportBAS(const WCHAR* fileName)
{ {
FILE* fp = NULL; FILE* fp = NULL;
ExpandBuffer msgs(1024); ExpandBuffer msgs(1024);
@ -197,11 +178,7 @@ bail:
return result; return result;
} }
/* bool ImportBASDialog::ConvertTextToBAS(const char* buf, long fileLen,
* Do the actual conversion.
*/
bool
ImportBASDialog::ConvertTextToBAS(const char* buf, long fileLen,
char** pOutBuf, long* pOutLen, ExpandBuffer* pMsgs) char** pOutBuf, long* pOutLen, ExpandBuffer* pMsgs)
{ {
ExpandBuffer output(32768); ExpandBuffer output(32768);
@ -263,13 +240,6 @@ ImportBASDialog::ConvertTextToBAS(const char* buf, long fileLen,
return true; return true;
} }
/*
* Process a line of Applesoft BASIC text.
*
* Writes output to "pOutput".
*
* On failure, writes an error message to "msg" and returns false.
*/
/* /*
From an Applesoft disassembly by Bob Sander-Cederlof: From an Applesoft disassembly by Bob Sander-Cederlof:
@ -334,8 +304,8 @@ Note the special handling for "AT" and "TO". When it examines the next
character, it does NOT skip whitespace, making spaces significant when character, it does NOT skip whitespace, making spaces significant when
differentiating between "at n"/"atn" and "at o"/"ato". differentiating between "at n"/"atn" and "at o"/"ato".
*/ */
bool
ImportBASDialog::ProcessBASLine(const char* buf, int len, bool ImportBASDialog::ProcessBASLine(const char* buf, int len,
ExpandBuffer* pOutput, CString& msg) ExpandBuffer* pOutput, CString& msg)
{ {
const int kMaxTokenLen = 7; // longest token; must also hold linenum const int kMaxTokenLen = 7; // longest token; must also hold linenum
@ -537,13 +507,10 @@ output_single:
return true; return true;
} }
/* bool ImportBASDialog::FixBASLinePointers(char* buf, long len,
* Fix up the line pointers. We left dummy nonzero values in them initially. uint16_t addr)
*/
bool
ImportBASDialog::FixBASLinePointers(char* buf, long len, unsigned short addr)
{ {
unsigned short val; uint16_t val;
char* start; char* start;
while (len >= 4) { while (len >= 4) {
@ -588,14 +555,7 @@ ImportBASDialog::FixBASLinePointers(char* buf, long len, unsigned short addr)
return true; return true;
} }
/* const char* ImportBASDialog::FindEOL(const char* buf, long max)
* Look for the end of line.
*
* Returns a pointer to the first byte *past* the EOL marker, which will point
* at unallocated space for last line in the buffer.
*/
const char*
ImportBASDialog::FindEOL(const char* buf, long max)
{ {
ASSERT(max >= 0); ASSERT(max >= 0);
if (max == 0) if (max == 0)
@ -618,15 +578,7 @@ ImportBASDialog::FindEOL(const char* buf, long max)
return buf; return buf;
} }
/* bool ImportBASDialog::GetNextNWC(const char** pBuf, int* pLen, char* pCh)
* Find the next non-whitespace character.
*
* Updates the buffer pointer and length.
*
* Returns "false" if we run off the end without finding another non-ws char.
*/
bool
ImportBASDialog::GetNextNWC(const char** pBuf, int* pLen, char* pCh)
{ {
static const char* kWhitespace = " \t\r\n"; static const char* kWhitespace = " \t\r\n";
@ -648,10 +600,6 @@ ImportBASDialog::GetNextNWC(const char** pBuf, int* pLen, char* pCh)
return false; return false;
} }
/*
* Save the imported data.
*/
void ImportBASDialog::OnOK(void) void ImportBASDialog::OnOK(void)
{ {
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_IMPORT_BAS_SAVEAS); CEdit* pEdit = (CEdit*) GetDlgItem(IDC_IMPORT_BAS_SAVEAS);
@ -705,11 +653,7 @@ bail:
return; return;
} }
/* void ImportBASDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
ImportBASDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_IMPORT_BASIC, HELP_CONTEXT); WinHelp(HELP_TOPIC_IMPORT_BASIC, HELP_CONTEXT);
} }

View File

@ -31,7 +31,7 @@ public:
delete[] fTokenLen; delete[] fTokenLen;
} }
// Initialize the array. // Initialize the array. Pass in the info for the token blob.
void Init(const char* tokenList, int numTokens, int tokenLen); void Init(const char* tokenList, int numTokens, int tokenLen);
// Return the index of the matching token, or -1 if none found. // Return the index of the matching token, or -1 if none found.
@ -64,26 +64,59 @@ public:
delete[] fOutput; delete[] fOutput;
} }
CString fFileName; // file to open
// did we add something to the archive? // did we add something to the archive?
bool IsDirty(void) const { return fDirty; } bool IsDirty(void) const { return fDirty; }
void SetFileName(const CString& fileName) { fFileName = fileName; }
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
//virtual void DoDataExchange(CDataExchange* pDX); //virtual void DoDataExchange(CDataExchange* pDX);
virtual void OnOK(void); virtual void OnOK(void) override;
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
/*
* Import an Applesoft BASIC program from the specified file.
*/
bool ImportBAS(const WCHAR* fileName); bool ImportBAS(const WCHAR* fileName);
/*
* Do the actual conversion.
*/
bool ConvertTextToBAS(const char* buf, long fileLen, bool ConvertTextToBAS(const char* buf, long fileLen,
char** pOutBuf, long* pOutLen, ExpandBuffer* pMsgs); char** pOutBuf, long* pOutLen, ExpandBuffer* pMsgs);
/*
* Process a line of Applesoft BASIC text.
*
* Writes output to "pOutput".
*
* On failure, writes an error message to "msg" and returns false.
*/
bool ProcessBASLine(const char* buf, int len, bool ProcessBASLine(const char* buf, int len,
ExpandBuffer* pOutput, CString& msg); ExpandBuffer* pOutput, CString& msg);
bool FixBASLinePointers(char* buf, long len, unsigned short addr);
/*
* Fix up the line pointers. We left dummy nonzero values in them initially.
*/
bool FixBASLinePointers(char* buf, long len, uint16_t addr);
/*
* Look for the end of line.
*
* Returns a pointer to the first byte *past* the EOL marker, which will point
* at unallocated space for last line in the buffer.
*/
const char* FindEOL(const char* buf, long max); const char* FindEOL(const char* buf, long max);
/*
* Find the next non-whitespace character.
*
* Updates the buffer pointer and length.
*
* Returns "false" if we run off the end without finding another non-ws char.
*/
bool GetNextNWC(const char** pBuf, int* pLen, char* pCh); bool GetNextNWC(const char** pBuf, int* pLen, char* pCh);
void SetOutput(char* outBuf, long outLen) { void SetOutput(char* outBuf, long outLen) {
@ -98,6 +131,8 @@ private:
char* fOutput; char* fOutput;
long fOutputLen; long fOutputLen;
CString fFileName; // file to open
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
}; };

View File

@ -18,11 +18,7 @@ BEGIN_MESSAGE_MAP(CassImpTargetDialog, CDialog)
ON_EN_CHANGE(IDC_CASSIMPTARG_BINADDR, OnAddrChange) ON_EN_CHANGE(IDC_CASSIMPTARG_BINADDR, OnAddrChange)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL CassImpTargetDialog::OnInitDialog(void)
* Set up the dialog.
*/
BOOL
CassImpTargetDialog::OnInitDialog(void)
{ {
/* substitute our replacement edit control */ /* substitute our replacement edit control */
fAddrEdit.ReplaceDlgCtrl(this, IDC_CASSIMPTARG_BINADDR); fAddrEdit.ReplaceDlgCtrl(this, IDC_CASSIMPTARG_BINADDR);
@ -45,11 +41,7 @@ CassImpTargetDialog::OnInitDialog(void)
return FALSE; // don't change the focus return FALSE; // don't change the focus
} }
/* void CassImpTargetDialog::DoDataExchange(CDataExchange* pDX)
* Copy values in and out of the dialog.
*/
void
CassImpTargetDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_Radio(pDX, IDC_CASSIMPTARG_BAS, fFileTypeIndex); DDX_Radio(pDX, IDC_CASSIMPTARG_BAS, fFileTypeIndex);
DDX_Text(pDX, IDC_CASSIMPTARG_FILENAME, fFileName); DDX_Text(pDX, IDC_CASSIMPTARG_FILENAME, fFileName);
@ -83,12 +75,7 @@ CassImpTargetDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
/* void CassImpTargetDialog::OnTypeChange(void)
* They selected a different file type. Enable or disable the address
* entry window.
*/
void
CassImpTargetDialog::OnTypeChange(void)
{ {
CButton* pButton; CButton* pButton;
CWnd* pWnd; CWnd* pWnd;
@ -99,11 +86,7 @@ CassImpTargetDialog::OnTypeChange(void)
pWnd->EnableWindow(pButton->GetCheck() == BST_CHECKED); pWnd->EnableWindow(pButton->GetCheck() == BST_CHECKED);
} }
/* void CassImpTargetDialog::OnAddrChange(void)
* If the user changes the address, update the "end of range" field.
*/
void
CassImpTargetDialog::OnAddrChange(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString tmpStr; CString tmpStr;
@ -119,14 +102,7 @@ CassImpTargetDialog::OnAddrChange(void)
pWnd->SetWindowText(tmpStr); pWnd->SetWindowText(tmpStr);
} }
/* long CassImpTargetDialog::GetStartAddr(void) const
* Get the start address (entered as a 4-digit hex value).
*
* Returns -1 if something was wrong with the string (e.g. empty or has
* invalid chars).
*/
long
CassImpTargetDialog::GetStartAddr(void) const
{ {
CWnd* pWnd = GetDlgItem(IDC_CASSIMPTARG_BINADDR); CWnd* pWnd = GetDlgItem(IDC_CASSIMPTARG_BINADDR);
ASSERT(pWnd != NULL); ASSERT(pWnd != NULL);
@ -151,11 +127,7 @@ CassImpTargetDialog::GetStartAddr(void) const
return val; return val;
} }
/* long CassImpTargetDialog::GetFileType(void) const
* Get the selected file type. Call this after the modal dialog exits.
*/
long
CassImpTargetDialog::GetFileType(void) const
{ {
switch (fFileTypeIndex) { switch (fFileTypeIndex) {
case kTypeBIN: return kFileTypeBIN; case kTypeBIN: return kFileTypeBIN;
@ -167,11 +139,7 @@ CassImpTargetDialog::GetFileType(void) const
} }
} }
/* void CassImpTargetDialog::SetFileType(long type)
* Convert a ProDOS file type into a radio button enum.
*/
void
CassImpTargetDialog::SetFileType(long type)
{ {
switch (type) { switch (type) {
case kFileTypeBIN: fFileTypeIndex = kTypeBIN; break; case kFileTypeBIN: fFileTypeIndex = kTypeBIN; break;

View File

@ -25,7 +25,14 @@ public:
{} {}
virtual ~CassImpTargetDialog(void) {} virtual ~CassImpTargetDialog(void) {}
/*
* Get the selected file type. Call this after the modal dialog exits.
*/
long GetFileType(void) const; long GetFileType(void) const;
/*
* Convert a ProDOS file type into a radio button enum.
*/
void SetFileType(long type); void SetFileType(long type);
CString fFileName; CString fFileName;
@ -33,13 +40,28 @@ public:
long fFileLength; // used for BIN display long fFileLength; // used for BIN display
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* They selected a different file type. Enable or disable the address
* entry window.
*/
afx_msg void OnTypeChange(void); afx_msg void OnTypeChange(void);
/*
* If the user changes the address, update the "end of range" field.
*/
afx_msg void OnAddrChange(void); afx_msg void OnAddrChange(void);
MyEdit fAddrEdit; // replacement edit ctrl for addr field MyEdit fAddrEdit; // replacement edit ctrl for addr field
/*
* Get the start address (entered as a 4-digit hex value).
*
* Returns -1 if something was wrong with the string (e.g. empty or has
* invalid chars).
*/
long GetStartAddr(void) const; long GetStartAddr(void) const;
/* for radio button; enum must match order of controls in dialog */ /* for radio button; enum must match order of controls in dialog */

View File

@ -268,11 +268,7 @@ BEGIN_MESSAGE_MAP(CassetteDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL CassetteDialog::OnInitDialog(void)
* Set up the dialog.
*/
BOOL
CassetteDialog::OnInitDialog(void)
{ {
CRect rect; CRect rect;
const Preferences* pPreferences = GET_PREFERENCES(); const Preferences* pPreferences = GET_PREFERENCES();
@ -360,11 +356,7 @@ CassetteDialog::OnDialogReady(UINT, LONG)
#endif #endif
/* void CassetteDialog::OnListChange(NMHDR*, LRESULT* pResult)
* Something changed in the list. Update the "OK" button.
*/
void
CassetteDialog::OnListChange(NMHDR*, LRESULT* pResult)
{ {
LOGI("List change"); LOGI("List change");
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_CASSETTE_LIST); CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_CASSETTE_LIST);
@ -375,11 +367,7 @@ CassetteDialog::OnListChange(NMHDR*, LRESULT* pResult)
} }
/* void CassetteDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
* Double click.
*/
void
CassetteDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
{ {
LOGI("Double click!"); LOGI("Double click!");
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_CASSETTE_LIST); CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_CASSETTE_LIST);
@ -390,11 +378,7 @@ CassetteDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* void CassetteDialog::OnAlgorithmChange(void)
* The volume filter drop-down box has changed.
*/
void
CassetteDialog::OnAlgorithmChange(void)
{ {
CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_CASSETTE_ALG); CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_CASSETTE_ALG);
ASSERT(pCombo != NULL); ASSERT(pCombo != NULL);
@ -403,21 +387,12 @@ CassetteDialog::OnAlgorithmChange(void)
AnalyzeWAV(); AnalyzeWAV();
} }
/* void CassetteDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
CassetteDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_IMPORT_CASSETTE, HELP_CONTEXT); WinHelp(HELP_TOPIC_IMPORT_CASSETTE, HELP_CONTEXT);
} }
/* void CassetteDialog::OnImport(void)
* User pressed "import" button. Add the selected item to the current
* archive or disk image.
*/
void
CassetteDialog::OnImport(void)
{ {
/* /*
* Figure out which item they have selected. * Figure out which item they have selected.
@ -486,14 +461,7 @@ bail:
} }
} }
bool CassetteDialog::AnalyzeWAV(void)
/*
* Analyze the contents of a WAV file.
*
* Returns "true" if it found anything at all, "false" if not.
*/
bool
CassetteDialog::AnalyzeWAV(void)
{ {
SoundFile soundFile; SoundFile soundFile;
CWaitCursor waitc; CWaitCursor waitc;
@ -546,13 +514,7 @@ CassetteDialog::AnalyzeWAV(void)
return true; return true;
} }
/* void CassetteDialog::AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType)
* Add an entry to the list.
*
* Layout: index format length checksum start-offset
*/
void
CassetteDialog::AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType)
{ {
CString tmpStr; CString tmpStr;
const CassetteData* pData = &fDataArray[idx]; const CassetteData* pData = &fDataArray[idx];
@ -605,15 +567,7 @@ CassetteDialog::AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType)
* ========================================================================== * ==========================================================================
*/ */
/* bool CassetteDialog::CassetteData::Scan(SoundFile* pSoundFile, Algorithm alg,
* Scan the WAV file, starting from the specified byte offset.
*
* Returns "true" if we found a file, "false" if not (indicating that the
* end of the input has been reached). Updates "*pStartOffset" to point
* past the end of the data we've read.
*/
bool
CassetteDialog::CassetteData::Scan(SoundFile* pSoundFile, Algorithm alg,
long* pStartOffset) long* pStartOffset)
{ {
const int kSampleChunkSize = 65536; // should be multiple of 4 const int kSampleChunkSize = 65536; // should be multiple of 4
@ -760,13 +714,7 @@ bail:
return result; return result;
} }
/* void CassetteDialog::CassetteData::ConvertSamplesToReal(const WAVEFORMATEX* pFormat,
* Convert a block of samples from PCM to float.
*
* Only the first (left) channel is converted in multi-channel formats.
*/
void
CassetteDialog::CassetteData::ConvertSamplesToReal(const WAVEFORMATEX* pFormat,
const unsigned char* buf, long chunkLen, float* sampleBuf) const unsigned char* buf, long chunkLen, float* sampleBuf)
{ {
int bps = ((pFormat->wBitsPerSample+7)/8) * pFormat->nChannels; int bps = ((pFormat->wBitsPerSample+7)/8) * pFormat->nChannels;
@ -826,13 +774,7 @@ const float kTransMinDelta = 0.02f; // 1%
const float kTransDeltaBase = 45.35f; // usec (1 sample at 22.05KHz) const float kTransDeltaBase = 45.35f; // usec (1 sample at 22.05KHz)
/* bool CassetteDialog::CassetteData::ProcessSample(float sample, long sampleIndex,
* Process one audio sample. Updates "pScanState" appropriately.
*
* If we think we found a bit, this returns "true" with 0 or 1 in "*pBitVal".
*/
bool
CassetteDialog::CassetteData::ProcessSample(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal) ScanState* pScanState, int* pBitVal)
{ {
if (pScanState->algorithm == kAlgorithmZero) if (pScanState->algorithm == kAlgorithmZero)
@ -847,18 +789,7 @@ CassetteDialog::CassetteData::ProcessSample(float sample, long sampleIndex,
} }
} }
/* bool CassetteDialog::CassetteData::ProcessSampleZero(float sample, long sampleIndex,
* Process the data by measuring the distance between zero crossings.
*
* This is very similar to the way the Apple II does it, though
* we have to scan for the 770Hz lead-in instead of simply assuming the
* the user has queued up the tape.
*
* To offset the effects of DC bias, we examine full cycles instead of
* half cycles.
*/
bool
CassetteDialog::CassetteData::ProcessSampleZero(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal) ScanState* pScanState, int* pBitVal)
{ {
long timeDelta; long timeDelta;
@ -920,11 +851,7 @@ CassetteDialog::CassetteData::ProcessSampleZero(float sample, long sampleIndex,
return emitBit; return emitBit;
} }
/* bool CassetteDialog::CassetteData::ProcessSamplePeak(float sample, long sampleIndex,
* Process the data by finding and measuring the distance between peaks.
*/
bool
CassetteDialog::CassetteData::ProcessSamplePeak(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal) ScanState* pScanState, int* pBitVal)
{ {
/* values range from [-1.0,1.0), so range is 2.0 total */ /* values range from [-1.0,1.0), so range is 2.0 total */
@ -1054,20 +981,8 @@ CassetteDialog::CassetteData::ProcessSamplePeak(float sample, long sampleIndex,
return emitBit; return emitBit;
} }
bool CassetteDialog::CassetteData::UpdatePhase(ScanState* pScanState,
/* long sampleIndex, float halfCycleUsec, int* pBitVal)
* Given the width of a half-cycle, update "phase" and decide whether or not
* it's time to emit a bit.
*
* Updates "halfCycleWidth" too, alternating between 0.0 and a value.
*
* The "sampleIndex" parameter is largely just for display. We use it to
* set the "start" and "end" pointers, but those are also ultimately just
* for display to the user.
*/
bool
CassetteDialog::CassetteData::UpdatePhase(ScanState* pScanState, long sampleIndex,
float halfCycleUsec, int* pBitVal)
{ {
float fullCycleUsec; float fullCycleUsec;
bool emitBit = false; bool emitBit = false;

View File

@ -25,18 +25,31 @@ public:
bool IsDirty(void) const { return fDirty; } bool IsDirty(void) const { return fDirty; }
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
//virtual void DoDataExchange(CDataExchange* pDX); //virtual void DoDataExchange(CDataExchange* pDX);
//virtual void OnOK(void); //virtual void OnOK(void);
//enum { WMU_DIALOG_READY = WM_USER+2 }; //enum { WMU_DIALOG_READY = WM_USER+2 };
/*
* Something changed in the list. Update the "OK" button.
*/
afx_msg void OnListChange(NMHDR* pNotifyStruct, LRESULT* pResult); afx_msg void OnListChange(NMHDR* pNotifyStruct, LRESULT* pResult);
afx_msg void OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult);
/*
* The volume filter drop-down box has changed.
*/
afx_msg void OnAlgorithmChange(void); afx_msg void OnAlgorithmChange(void);
afx_msg void OnHelp(void);
/*
* User pressed "import" button. Add the selected item to the current
* archive or disk image.
*/
afx_msg void OnImport(void); afx_msg void OnImport(void);
afx_msg void OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult);
afx_msg void OnHelp(void);
/* /*
* This holds converted data from the WAV file, plus some meta-data * This holds converted data from the WAV file, plus some meta-data
* like what type of file we think this is. * like what type of file we think this is.
@ -64,6 +77,13 @@ private:
kAlgorithmMAX kAlgorithmMAX
} Algorithm; } Algorithm;
/*
* Scan the WAV file, starting from the specified byte offset.
*
* Returns "true" if we found a file, "false" if not (indicating that the
* end of the input has been reached). Updates "*pStartOffset" to point
* past the end of the data we've read.
*/
bool Scan(SoundFile* pSoundFile, Algorithm alg, long* pSampleOffset); bool Scan(SoundFile* pSoundFile, Algorithm alg, long* pSampleOffset);
unsigned char* GetDataBuf(void) const { return fOutputBuf; } unsigned char* GetDataBuf(void) const { return fOutputBuf; }
int GetDataLen(void) const { return fOutputLen; } int GetDataLen(void) const { return fOutputLen; }
@ -117,14 +137,52 @@ private:
/* constants */ /* constants */
float usecPerSample; float usecPerSample;
} ScanState; } ScanState;
/*
* Convert a block of samples from PCM to float.
*
* Only the first (left) channel is converted in multi-channel formats.
*/
void ConvertSamplesToReal(const WAVEFORMATEX* pFormat, void ConvertSamplesToReal(const WAVEFORMATEX* pFormat,
const unsigned char* buf, long chunkLen, float* sampleBuf); const unsigned char* buf, long chunkLen, float* sampleBuf);
/*
* Process one audio sample. Updates "pScanState" appropriately.
*
* If we think we found a bit, this returns "true" with 0 or 1 in "*pBitVal".
*/
bool ProcessSample(float sample, long sampleIndex, bool ProcessSample(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal); ScanState* pScanState, int* pBitVal);
/*
* Process the data by measuring the distance between zero crossings.
*
* This is very similar to the way the Apple II does it, though
* we have to scan for the 770Hz lead-in instead of simply assuming the
* the user has queued up the tape.
*
* To offset the effects of DC bias, we examine full cycles instead of
* half cycles.
*/
bool ProcessSampleZero(float sample, long sampleIndex, bool ProcessSampleZero(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal); ScanState* pScanState, int* pBitVal);
/*
* Process the data by finding and measuring the distance between peaks.
*/
bool ProcessSamplePeak(float sample, long sampleIndex, bool ProcessSamplePeak(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal); ScanState* pScanState, int* pBitVal);
/*
* Given the width of a half-cycle, update "phase" and decide whether or not
* it's time to emit a bit.
*
* Updates "halfCycleWidth" too, alternating between 0.0 and a value.
*
* The "sampleIndex" parameter is largely just for display. We use it to
* set the "start" and "end" pointers, but those are also ultimately just
* for display to the user.
*/
bool UpdatePhase(ScanState* pScanState, long sampleIndex, bool UpdatePhase(ScanState* pScanState, long sampleIndex,
float halfCycleUsec, int* pBitVal); float halfCycleUsec, int* pBitVal);
@ -141,7 +199,18 @@ private:
bool fChecksumGood; bool fChecksumGood;
}; };
/*
* Analyze the contents of a WAV file.
*
* Returns true if it found anything at all, false if not.
*/
bool AnalyzeWAV(void); bool AnalyzeWAV(void);
/*
* Add an entry to the list.
*
* Layout: index format length checksum start-offset
*/
void AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType); void AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType);
enum { enum {

View File

@ -17,12 +17,7 @@ BEGIN_MESSAGE_MAP(ChooseAddTargetDialog, CDialog)
ON_COMMAND(IDHELP, OnHelp) ON_COMMAND(IDHELP, OnHelp)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL ChooseAddTargetDialog::OnInitDialog(void)
* Initialize the dialog box. This requires scanning the provided disk
* archive.
*/
BOOL
ChooseAddTargetDialog::OnInitDialog(void)
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
@ -51,14 +46,13 @@ ChooseAddTargetDialog::OnInitDialog(void)
return TRUE; return TRUE;
} }
/* void ChooseAddTargetDialog::DoDataExchange(CDataExchange* pDX)
* Not much to do on the way in. On the way out, make sure that they've
* selected something acceptable, and copy the values to an easily
* accessible location.
*/
void
ChooseAddTargetDialog::DoDataExchange(CDataExchange* pDX)
{ {
/*
* Not much to do on the way in. On the way out, make sure that they've
* selected something acceptable, and copy the values to an easily
* accessible location.
*/
if (pDX->m_bSaveAndValidate) { if (pDX->m_bSaveAndValidate) {
CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_ADD_TARGET_TREE); CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_ADD_TARGET_TREE);
CString errMsg, appName; CString errMsg, appName;
@ -91,12 +85,7 @@ ChooseAddTargetDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
void ChooseAddTargetDialog::OnHelp(void)
/*
* User pressed the "Help" button.
*/
void
ChooseAddTargetDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_CHOOSE_TARGET, HELP_CONTEXT); WinHelp(HELP_TOPIC_CHOOSE_TARGET, HELP_CONTEXT);
} }

View File

@ -35,8 +35,13 @@ public:
DiskImgLib::A2File* fpChosenSubdir; DiskImgLib::A2File* fpChosenSubdir;
private: private:
virtual BOOL OnInitDialog(void); /*
virtual void DoDataExchange(CDataExchange* pDX); * Initialize the dialog box. This requires scanning the provided disk
* archive.
*/
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
DiskFSTree fDiskFSTree; DiskFSTree fDiskFSTree;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for "choose a directory" dialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "ChooseDirDialog.h" #include "ChooseDirDialog.h"
#include "NewFolderDialog.h" #include "NewFolderDialog.h"
@ -22,11 +19,7 @@ BEGIN_MESSAGE_MAP(ChooseDirDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL ChooseDirDialog::OnInitDialog(void)
* Initialize dialog components.
*/
BOOL
ChooseDirDialog::OnInitDialog(void)
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
@ -63,11 +56,7 @@ ChooseDirDialog::OnInitDialog(void)
return FALSE; // leave focus on shell tree return FALSE; // leave focus on shell tree
} }
/* BOOL ChooseDirDialog::PreTranslateMessage(MSG* pMsg)
* Special keypress handling.
*/
BOOL
ChooseDirDialog::PreTranslateMessage(MSG* pMsg)
{ {
if (pMsg->message == WM_KEYDOWN && if (pMsg->message == WM_KEYDOWN &&
pMsg->wParam == VK_RETURN) pMsg->wParam == VK_RETURN)
@ -82,33 +71,19 @@ ChooseDirDialog::PreTranslateMessage(MSG* pMsg)
return CDialog::PreTranslateMessage(pMsg); return CDialog::PreTranslateMessage(pMsg);
} }
/* BOOL ChooseDirDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* F1 key hit, or '?' button in title bar used to select help for an
* item in the dialog.
*/
BOOL
ChooseDirDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
DWORD context = lpHelpInfo->iCtrlId; DWORD context = lpHelpInfo->iCtrlId;
WinHelp(context, HELP_CONTEXTPOPUP); WinHelp(context, HELP_CONTEXTPOPUP);
return TRUE; // indicate success?? return TRUE; // indicate success??
} }
/* void ChooseDirDialog::OnHelp(void)
* User pressed Ye Olde Helppe Button.
*/
void
ChooseDirDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_CHOOSE_FOLDER, HELP_CONTEXT); WinHelp(HELP_TOPIC_CHOOSE_FOLDER, HELP_CONTEXT);
} }
/* void ChooseDirDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
* Replace the ShellTree's default SELCHANGED handler with this so we can
* track changes to the edit control.
*/
void
ChooseDirDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
{ {
CString path; CString path;
CWnd* pWnd = GetDlgItem(IDC_CHOOSEDIR_PATH); CWnd* pWnd = GetDlgItem(IDC_CHOOSEDIR_PATH);
@ -133,11 +108,7 @@ ChooseDirDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* void ChooseDirDialog::OnExpandTree(void)
* User pressed "Expand Tree" button.
*/
void
ChooseDirDialog::OnExpandTree(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString str; CString str;
@ -157,11 +128,7 @@ ChooseDirDialog::OnExpandTree(void)
} }
} }
/* void ChooseDirDialog::OnNewFolder(void)
* User pressed "New Folder" button.
*/
void
ChooseDirDialog::OnNewFolder(void)
{ {
if (fPathName.IsEmpty()) { if (fPathName.IsEmpty()) {
MessageBox(L"You can't create a folder in this part of the tree.", MessageBox(L"You can't create a folder in this part of the tree.",

View File

@ -32,13 +32,28 @@ public:
void SetPathName(const WCHAR* str) { fPathName = str; } void SetPathName(const WCHAR* str) { fPathName = str; }
protected: protected:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual BOOL PreTranslateMessage(MSG* pMsg);
// Special handling for "return" key.
virtual BOOL PreTranslateMessage(MSG* pMsg) override;
/*
* Replace the ShellTree's default SELCHANGED handler with this so we can
* track changes to the edit control.
*/
afx_msg void OnSelChanged(NMHDR* pnmh, LRESULT* pResult); afx_msg void OnSelChanged(NMHDR* pnmh, LRESULT* pResult);
// F1 key hit, or '?' button in title bar used to select help for an
// item in the dialog. For ON_WM_HELPINFO.
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
// User pressed "Expand Tree" button.
afx_msg void OnExpandTree(void); afx_msg void OnExpandTree(void);
// User pressed "New Folder" button.
afx_msg void OnNewFolder(void); afx_msg void OnNewFolder(void);
// User pressed "Help" button.
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
private: private:

View File

@ -4,7 +4,8 @@
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/* /*
* Handle clipboard functions (copy, paste). * Handle clipboard functions (copy, paste). This is part of MainWindow,
* split out into a separate file for clarity.
*/ */
#include "StdAfx.h" #include "StdAfx.h"
#include "Main.h" #include "Main.h"
@ -94,11 +95,7 @@ typedef struct FileCollectionEntry {
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnEditCopy(void)
* Copy data to the clipboard.
*/
void
MainWindow::OnEditCopy(void)
{ {
CString errStr, fileList; CString errStr, fileList;
SelectionSet selSet; SelectionSet selSet;
@ -181,22 +178,14 @@ MainWindow::OnEditCopy(void)
bail: bail:
CloseClipboard(); CloseClipboard();
} }
void
MainWindow::OnUpdateEditCopy(CCmdUI* pCmdUI) void MainWindow::OnUpdateEditCopy(CCmdUI* pCmdUI)
{ {
pCmdUI->Enable(fpContentList != NULL && pCmdUI->Enable(fpContentList != NULL &&
fpContentList->GetSelectedCount() > 0); fpContentList->GetSelectedCount() > 0);
} }
/* CString MainWindow::CreateFileList(SelectionSet* pSelSet)
* Create a list of selected files.
*
* The returned string uses tab-delineated fields with CSV-style quoting
* around the filename (so that double quotes in the filename don't confuse
* applications like MS Excel).
*/
CString
MainWindow::CreateFileList(SelectionSet* pSelSet)
{ {
SelectionEntry* pSelEntry; SelectionEntry* pSelEntry;
GenericEntry* pEntry; GenericEntry* pEntry;
@ -232,11 +221,7 @@ MainWindow::CreateFileList(SelectionSet* pSelSet)
return fullStr; return fullStr;
} }
/* /*static*/ CString MainWindow::DblDblQuote(const WCHAR* str)
* Double-up all double quotes.
*/
/*static*/ CString
MainWindow::DblDblQuote(const WCHAR* str)
{ {
CString result; CString result;
WCHAR* buf; WCHAR* buf;
@ -258,12 +243,7 @@ MainWindow::DblDblQuote(const WCHAR* str)
return result; return result;
} }
long MainWindow::GetClipboardContentLen(void)
/*
* Compute the size of everything currently on the clipboard.
*/
long
MainWindow::GetClipboardContentLen(void)
{ {
long len = 0; long len = 0;
UINT format = 0; UINT format = 0;
@ -278,11 +258,7 @@ MainWindow::GetClipboardContentLen(void)
return len; return len;
} }
/* HGLOBAL MainWindow::CreateFileCollection(SelectionSet* pSelSet)
* Create the file collection.
*/
HGLOBAL
MainWindow::CreateFileCollection(SelectionSet* pSelSet)
{ {
SelectionEntry* pSelEntry; SelectionEntry* pSelEntry;
GenericEntry* pEntry; GenericEntry* pEntry;
@ -441,18 +417,8 @@ bail:
return hResult; return hResult;
} }
/* CString MainWindow::CopyToCollection(GenericEntry* pEntry, void** pBuf,
* Copy the contents of the file referred to by "pEntry" into the buffer long* pBufLen)
* "*pBuf", which has "*pBufLen" bytes in it.
*
* The call fails if "*pBufLen" isn't large enough.
*
* Returns an empty string on success, or an error message on failure.
* On success, "*pBuf" will be advanced past the data added, and "*pBufLen"
* will be reduced by the amount of data copied into "buf".
*/
CString
MainWindow::CopyToCollection(GenericEntry* pEntry, void** pBuf, long* pBufLen)
{ {
FileCollectionEntry collEnt; FileCollectionEntry collEnt;
CString errStr, dummyStr; CString errStr, dummyStr;
@ -615,19 +581,14 @@ MainWindow::CopyToCollection(GenericEntry* pEntry, void** pBuf, long* pBufLen)
* ========================================================================== * ==========================================================================
*/ */
/* void MainWindow::OnEditPaste(void)
* Paste data from the clipboard, using the configured defaults.
*/
void
MainWindow::OnEditPaste(void)
{ {
bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths); bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths);
DoPaste(pasteJunkPaths); DoPaste(pasteJunkPaths);
} }
void void MainWindow::OnUpdateEditPaste(CCmdUI* pCmdUI)
MainWindow::OnUpdateEditPaste(CCmdUI* pCmdUI)
{ {
bool dataAvailable = false; bool dataAvailable = false;
UINT myFormat; UINT myFormat;
@ -640,12 +601,7 @@ MainWindow::OnUpdateEditPaste(CCmdUI* pCmdUI)
dataAvailable); dataAvailable);
} }
/* void MainWindow::OnEditPasteSpecial(void)
* Paste data from the clipboard, giving the user the opportunity to select
* how the files are handled.
*/
void
MainWindow::OnEditPasteSpecial(void)
{ {
PasteSpecialDialog dlg; PasteSpecialDialog dlg;
bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths); bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths);
@ -673,17 +629,12 @@ MainWindow::OnEditPasteSpecial(void)
DoPaste(pasteJunkPaths); DoPaste(pasteJunkPaths);
} }
void void MainWindow::OnUpdateEditPasteSpecial(CCmdUI* pCmdUI)
MainWindow::OnUpdateEditPasteSpecial(CCmdUI* pCmdUI)
{ {
OnUpdateEditPaste(pCmdUI); OnUpdateEditPaste(pCmdUI);
} }
/* void MainWindow::DoPaste(bool pasteJunkPaths)
* Do some prep work and then call ProcessClipboard to copy files in.
*/
void
MainWindow::DoPaste(bool pasteJunkPaths)
{ {
CString errStr, buildStr; CString errStr, buildStr;
UINT format = 0; UINT format = 0;
@ -761,13 +712,8 @@ bail:
CloseClipboard(); CloseClipboard();
} }
/* CString MainWindow::ProcessClipboard(const void* vbuf, long bufLen,
* Process the data in the clipboard. bool pasteJunkPaths)
*
* Returns an empty string on success, or an error message on failure.
*/
CString
MainWindow::ProcessClipboard(const void* vbuf, long bufLen, bool pasteJunkPaths)
{ {
FileCollection fileColl; FileCollection fileColl;
CString errMsg, storagePrefix; CString errMsg, storagePrefix;
@ -954,17 +900,8 @@ bail:
return errMsg; return errMsg;
} }
/* CString MainWindow::ProcessClipboardEntry(const FileCollectionEntry* pCollEnt,
* Process a single clipboard entry. const WCHAR* pathName, const uint8_t* buf, long remLen)
*
* On entry, "buf" points to the start of the first chunk of data (either
* data fork or resource fork). If the file has empty forks or is a
* subdirectory, then "buf" is actually pointing at the start of the
* next entry.
*/
CString
MainWindow::ProcessClipboardEntry(const FileCollectionEntry* pCollEnt,
const WCHAR* pathName, const unsigned char* buf, long remLen)
{ {
GenericArchive::FileDetails::FileKind entryKind; GenericArchive::FileDetails::FileKind entryKind;
GenericArchive::FileDetails details; GenericArchive::FileDetails details;

View File

@ -22,11 +22,7 @@ BEGIN_MESSAGE_MAP(RenameOverwriteDialog, CDialog)
ON_WM_HELPINFO() ON_WM_HELPINFO()
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL RenameOverwriteDialog::OnInitDialog(void)
* Init static text fields.
*/
BOOL
RenameOverwriteDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
@ -37,11 +33,7 @@ RenameOverwriteDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void RenameOverwriteDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
RenameOverwriteDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_Text(pDX, IDC_RENOVWR_ORIG_NAME, fExistingFile); DDX_Text(pDX, IDC_RENOVWR_ORIG_NAME, fExistingFile);
DDX_Text(pDX, IDC_RENOVWR_NEW_NAME, fNewName); DDX_Text(pDX, IDC_RENOVWR_NEW_NAME, fNewName);
@ -58,8 +50,7 @@ RenameOverwriteDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
BOOL BOOL RenameOverwriteDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
RenameOverwriteDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
@ -82,11 +73,7 @@ BEGIN_MESSAGE_MAP(ConfirmOverwriteDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL ConfirmOverwriteDialog::OnInitDialog(void)
* Replace some static text fields.
*/
BOOL
ConfirmOverwriteDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString tmpStr, dateStr; CString tmpStr, dateStr;
@ -118,47 +105,39 @@ ConfirmOverwriteDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* BOOL ConfirmOverwriteDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Handle a click on the question-mark button.
*/
BOOL
ConfirmOverwriteDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void ConfirmOverwriteDialog::OnYes(void)
* One of the buttons was hit.
*/
void
ConfirmOverwriteDialog::OnYes(void)
{ {
fResultOverwrite = true; fResultOverwrite = true;
CDialog::OnOK(); CDialog::OnOK();
} }
void
ConfirmOverwriteDialog::OnYesToAll(void) void ConfirmOverwriteDialog::OnYesToAll(void)
{ {
fResultOverwrite = true; fResultOverwrite = true;
fResultApplyToAll = true; fResultApplyToAll = true;
CDialog::OnOK(); CDialog::OnOK();
} }
void
ConfirmOverwriteDialog::OnNo(void) void ConfirmOverwriteDialog::OnNo(void)
{ {
//fResultOverwrite = false; //fResultOverwrite = false;
CDialog::OnOK(); CDialog::OnOK();
} }
void
ConfirmOverwriteDialog::OnNoToAll(void) void ConfirmOverwriteDialog::OnNoToAll(void)
{ {
//fResultOverwrite = true; //fResultOverwrite = true;
fResultApplyToAll = true; fResultApplyToAll = true;
CDialog::OnOK(); CDialog::OnOK();
} }
void
ConfirmOverwriteDialog::OnRename(void) void ConfirmOverwriteDialog::OnRename(void)
{ {
RenameOverwriteDialog dlg; RenameOverwriteDialog dlg;

View File

@ -45,14 +45,16 @@ public:
bool fAllowRename; bool fAllowRename;
private: private:
virtual BOOL OnInitDialog(void) override;
afx_msg void OnYes(void); afx_msg void OnYes(void);
afx_msg void OnYesToAll(void); afx_msg void OnYesToAll(void);
afx_msg void OnNo(void); afx_msg void OnNo(void);
afx_msg void OnNoToAll(void); afx_msg void OnNoToAll(void);
afx_msg void OnRename(void); afx_msg void OnRename(void);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
virtual BOOL OnInitDialog(void); // Handle a click on the question-mark button.
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
}; };
@ -82,8 +84,8 @@ public:
CString fNewName; CString fNewName;
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);

View File

@ -35,12 +35,7 @@ ContentList::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
#endif #endif
/* BOOL ContentList::PreCreateWindow(CREATESTRUCT& cs)
* Put the window into "report" mode, and add a client edge since we're not
* using one on the frame window.
*/
BOOL
ContentList::PreCreateWindow(CREATESTRUCT& cs)
{ {
if (!CListCtrl::PreCreateWindow(cs)) if (!CListCtrl::PreCreateWindow(cs))
return FALSE; return FALSE;
@ -53,27 +48,18 @@ ContentList::PreCreateWindow(CREATESTRUCT& cs)
return TRUE; return TRUE;
} }
/* void ContentList::PostNcDestroy(void)
* Auto-cleanup the object.
*/
void
ContentList::PostNcDestroy(void)
{ {
LOGI("ContentList PostNcDestroy"); LOGI("ContentList PostNcDestroy");
delete this; delete this;
} }
static inline int static inline int MaxVal(int a, int b)
MaxVal(int a, int b)
{ {
return a > b ? a : b; return a > b ? a : b;
} }
/* int ContentList::OnCreate(LPCREATESTRUCT lpcs)
* Create and populate list control.
*/
int
ContentList::OnCreate(LPCREATESTRUCT lpcs)
{ {
CString colHdrs[kNumVisibleColumns] = { CString colHdrs[kNumVisibleColumns] = {
"Pathname", "Type", "Aux", "Mod Date", "Pathname", "Type", "Aux", "Mod Date",
@ -126,12 +112,7 @@ ContentList::OnCreate(LPCREATESTRUCT lpcs)
return 0; return 0;
} }
/* void ContentList::OnDestroy(void)
* If we're being shut down, save off the column width info before the window
* gets destroyed.
*/
void
ContentList::OnDestroy(void)
{ {
LOGI("ContentList OnDestroy"); LOGI("ContentList OnDestroy");
@ -139,22 +120,13 @@ ContentList::OnDestroy(void)
CListCtrl::OnDestroy(); CListCtrl::OnDestroy();
} }
/* void ContentList::OnSysColorChange(void)
* The system colors are changing; delete the image list and re-load it.
*/
void
ContentList::OnSysColorChange(void)
{ {
fHdrImageList.DeleteImageList(); fHdrImageList.DeleteImageList();
LoadHeaderImages(); LoadHeaderImages();
} }
/* void ContentList::OnColumnClick(NMHDR* pnmh, LRESULT* pResult)
* They've clicked on a header. Figure out what kind of sort order we want
* to use.
*/
void
ContentList::OnColumnClick(NMHDR* pnmh, LRESULT* pResult)
{ {
NM_LISTVIEW* pnmlv = (NM_LISTVIEW*) pnmh; NM_LISTVIEW* pnmlv = (NM_LISTVIEW*) pnmh;
@ -171,28 +143,14 @@ ContentList::OnColumnClick(NMHDR* pnmh, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* void ContentList::ExportColumnWidths(void)
* Copy the current column widths out to the Preferences object.
*/
void
ContentList::ExportColumnWidths(void)
{ {
//LOGI("ExportColumnWidths"); //LOGI("ExportColumnWidths");
for (int i = 0; i < kNumVisibleColumns; i++) for (int i = 0; i < kNumVisibleColumns; i++)
fpLayout->SetColumnWidth(i, GetColumnWidth(i)); fpLayout->SetColumnWidth(i, GetColumnWidth(i));
} }
/* void ContentList::NewColumnWidths(void)
* Call this when the column widths are changed programmatically (e.g. by
* the preferences page enabling or disabling columns).
*
* We want to set any defaulted entries to actual values so that, if the
* font properties change, column A doesn't resize when column B is tweaked
* in the Preferences dialog. (If it's still set to "default", then when
* we say "update all widths" the defaultedness will be re-evaluated.)
*/
void
ContentList::NewColumnWidths(void)
{ {
for (int i = 0; i < kNumVisibleColumns; i++) { for (int i = 0; i < kNumVisibleColumns; i++) {
int width = fpLayout->GetColumnWidth(i); int width = fpLayout->GetColumnWidth(i);
@ -205,38 +163,7 @@ ContentList::NewColumnWidths(void)
} }
} }
#if 0 // replaced by GenericArchive reload flag void ContentList::Reload(bool saveSelection)
/*
* If we're in the middle of an update, invalidate the contents of the list
* so that we don't try to redraw from underlying storage that is no longer
* there.
*
* If we call DeleteAllItems the list will immediately blank itself. This
* rather sucks. Instead, we just mark it as invalid and have the "virtual"
* list goodies return empty strings. If the window has to redraw it won't
* do so properly, but most of the time it looks good and it beats flashing
* blank or crashing.
*/
void
ContentList::Invalidate(void)
{
fInvalid = true;
}
#endif
/*
* The archive contents have changed. Reload the list from the
* GenericArchive.
*
* Reloading causes the current selection and view position to be lost. This
* is sort of annoying if all we did is add a comment, so we try to save the
* selection and reapply it. To do this correctly we need some sort of
* unique identifier so we can spot the records that have come back.
*
* Nothing in GenericArchive should be considered valid at this point.
*/
void
ContentList::Reload(bool saveSelection)
{ {
LOGI("Reloading ContentList"); LOGI("Reloading ContentList");
CWaitCursor waitc; CWaitCursor waitc;
@ -271,14 +198,7 @@ ContentList::Reload(bool saveSelection)
EnsureVisible(top, false); EnsureVisible(top, false);
} }
#if 1 long* ContentList::GetSelectionSerials(long* pSelCount)
/*
* Get the "selection serials" from the list of selected items.
*
* The caller is responsible for delete[]ing the return value.
*/
long*
ContentList::GetSelectionSerials(long* pSelCount)
{ {
long* savedSel = NULL; long* savedSel = NULL;
long maxCount; long maxCount;
@ -313,11 +233,7 @@ ContentList::GetSelectionSerials(long* pSelCount)
return savedSel; return savedSel;
} }
/* void ContentList::RestoreSelection(const long* savedSel, long selCount)
* Restore the selection from the "savedSel" list.
*/
void
ContentList::RestoreSelection(const long* savedSel, long selCount)
{ {
LOGI("RestoreSelection (selCount=%d)", selCount); LOGI("RestoreSelection (selCount=%d)", selCount);
if (savedSel == NULL) if (savedSel == NULL)
@ -341,14 +257,8 @@ ContentList::RestoreSelection(const long* savedSel, long selCount)
} }
} }
} }
#endif
void ContentList::NewSortOrder(void)
/*
* Call this when the sort order changes.
*/
void
ContentList::NewSortOrder(void)
{ {
CWaitCursor wait; // automatically changes mouse to hourglass CWaitCursor wait; // automatically changes mouse to hourglass
int column; int column;
@ -361,14 +271,8 @@ ContentList::NewSortOrder(void)
SortItems(CompareFunc, column); SortItems(CompareFunc, column);
} }
/* /*static*/ void ContentList::MakeFileTypeDisplayString(const GenericEntry* pEntry,
* Get the file type display string. WCHAR* buf)
*
* "buf" must be able to hold at least 4 characters plus the NUL (i.e. 5).
* Use kFileTypeBufLen.
*/
/*static*/ void
ContentList::MakeFileTypeDisplayString(const GenericEntry* pEntry, WCHAR* buf)
{ {
bool isDir = bool isDir =
pEntry->GetRecordKind() == GenericEntry::kRecordKindVolumeDir || pEntry->GetRecordKind() == GenericEntry::kRecordKindVolumeDir ||
@ -430,14 +334,7 @@ ContentList::MakeFileTypeDisplayString(const GenericEntry* pEntry, WCHAR* buf)
} }
} }
/* /*static*/ void ContentList::MakeMacTypeString(unsigned long val, WCHAR* buf)
* Convert an HFS file/creator type into a string.
*
* "buf" must be able to hold at least 4 characters plus the NUL. Use
* kFileTypeBufLen.
*/
/*static*/ void
ContentList::MakeMacTypeString(unsigned long val, WCHAR* buf)
{ {
/* expand longword with ASCII type bytes */ /* expand longword with ASCII type bytes */
buf[0] = (unsigned char) (val >> 24); buf[0] = (unsigned char) (val >> 24);
@ -453,14 +350,8 @@ ContentList::MakeMacTypeString(unsigned long val, WCHAR* buf)
} }
} }
/* /*static*/ void ContentList::MakeAuxTypeDisplayString(const GenericEntry* pEntry,
* Get the aux type display string. WCHAR* buf)
*
* "buf" must be able to hold at least 5 characters plus the NUL (i.e. 6).
* Use kFileTypeBufLen.
*/
/*static*/ void
ContentList::MakeAuxTypeDisplayString(const GenericEntry* pEntry, WCHAR* buf)
{ {
bool isDir = bool isDir =
pEntry->GetRecordKind() == GenericEntry::kRecordKindVolumeDir || pEntry->GetRecordKind() == GenericEntry::kRecordKindVolumeDir ||
@ -481,15 +372,7 @@ ContentList::MakeAuxTypeDisplayString(const GenericEntry* pEntry, WCHAR* buf)
} }
} }
void ContentList::MakeRatioDisplayString(const GenericEntry* pEntry, WCHAR* buf,
/*
* Generate the funky ratio display string. While we're at it, return a
* numeric value that we can sort on.
*
* "buf" must be able to hold at least 6 chars plus the NULL.
*/
void
ContentList::MakeRatioDisplayString(const GenericEntry* pEntry, WCHAR* buf,
int* pPerc) int* pPerc)
{ {
LONGLONG totalLen, totalCompLen; LONGLONG totalLen, totalCompLen;
@ -508,15 +391,7 @@ ContentList::MakeRatioDisplayString(const GenericEntry* pEntry, WCHAR* buf,
} }
} }
void ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult)
/*
* Return the value for a particular row and column.
*
* This gets called *a lot* while the list is being drawn, scrolled, etc.
* Don't do anything too expensive.
*/
void
ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult)
{ {
static const WCHAR kAccessBits[] = L"dnb iwr"; static const WCHAR kAccessBits[] = L"dnb iwr";
LV_DISPINFO* plvdi = (LV_DISPINFO*) pnmh; LV_DISPINFO* plvdi = (LV_DISPINFO*) pnmh;
@ -616,12 +491,10 @@ ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* /*
* Helper functions for sort routine. * Helper functions for sort routine.
*/ */
static inline int static inline int CompareUnsignedLong(unsigned long u1, unsigned long u2)
CompareUnsignedLong(unsigned long u1, unsigned long u2)
{ {
if (u1 < u2) if (u1 < u2)
return -1; return -1;
@ -630,8 +503,7 @@ CompareUnsignedLong(unsigned long u1, unsigned long u2)
else else
return 0; return 0;
} }
static inline int static inline int CompareLONGLONG(LONGLONG u1, LONGLONG u2)
CompareLONGLONG(LONGLONG u1, LONGLONG u2)
{ {
if (u1 < u2) if (u1 < u2)
return -1; return -1;
@ -640,8 +512,7 @@ CompareLONGLONG(LONGLONG u1, LONGLONG u2)
else else
return 0; return 0;
} }
static inline int static inline int CompareTime(time_t t1, time_t t2)
CompareTime(time_t t1, time_t t2)
{ {
if (t1 < t2) if (t1 < t2)
return -1; return -1;
@ -651,11 +522,8 @@ CompareTime(time_t t1, time_t t2)
return 0; return 0;
} }
/* int CALLBACK ContentList::CompareFunc(LPARAM lParam1, LPARAM lParam2,
* Static comparison function for list sorting. LPARAM lParamSort)
*/
int CALLBACK
ContentList::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{ {
const GenericEntry* pEntry1 = (const GenericEntry*) lParam1; const GenericEntry* pEntry1 = (const GenericEntry*) lParam1;
const GenericEntry* pEntry2 = (const GenericEntry*) lParam2; const GenericEntry* pEntry2 = (const GenericEntry*) lParam2;
@ -730,16 +598,7 @@ ContentList::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
return result; return result;
} }
/* int ContentList::LoadData(void)
* Fill the columns with data from the archive entries. We use a "virtual"
* list control to avoid storing everything multiple times. However, we
* still create one item per entry so that the list control will do most
* of the sorting for us (otherwise we have to do the sorting ourselves).
*
* Someday we should probably move to a wholly virtual list view.
*/
int
ContentList::LoadData(void)
{ {
GenericEntry* pEntry; GenericEntry* pEntry;
LV_ITEM lvi; LV_ITEM lvi;
@ -781,12 +640,7 @@ ContentList::LoadData(void)
return 0; return 0;
} }
int ContentList::GetDefaultWidth(int col)
/*
* Return the default width for the specified column.
*/
int
ContentList::GetDefaultWidth(int col)
{ {
int retval; int retval;
@ -826,12 +680,7 @@ ContentList::GetDefaultWidth(int col)
return retval; return retval;
} }
void ContentList::SetSortIcon(void)
/*
* Set the up/down sorting arrow as appropriate.
*/
void
ContentList::SetSortIcon(void)
{ {
CHeaderCtrl* pHeader = GetHeaderCtrl(); CHeaderCtrl* pHeader = GetHeaderCtrl();
ASSERT(pHeader != NULL); ASSERT(pHeader != NULL);
@ -857,16 +706,7 @@ ContentList::SetSortIcon(void)
} }
} }
void ContentList::OnDoubleClick(NMHDR*, LRESULT* pResult)
/*
* Handle a double-click on an item.
*
* The double-click should single-select the item, so we can throw it
* straight into the viewer. However, there are some uses for bulk
* double-clicking.
*/
void
ContentList::OnDoubleClick(NMHDR*, LRESULT* pResult)
{ {
/* test */ /* test */
DWORD dwPos = ::GetMessagePos(); DWORD dwPos = ::GetMessagePos();
@ -883,20 +723,17 @@ ContentList::OnDoubleClick(NMHDR*, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* void ContentList::OnRightClick(NMHDR*, LRESULT* pResult)
* Handle a right-click on an item.
*
* -The first item in the menu performs the double-click action on the
* -item clicked on. The rest of the menu is simply a mirror of the items
* -in the "Actions" menu. To make this work, we let the main window handle
* -everything, but save a copy of the index of the menu item that was
* -clicked on.
*
* [We do this differently now?? ++ATM 20040722]
*/
void
ContentList::OnRightClick(NMHDR*, LRESULT* pResult)
{ {
/*
* -The first item in the menu performs the double-click action on the
* -item clicked on. The rest of the menu is simply a mirror of the items
* -in the "Actions" menu. To make this work, we let the main window handle
* -everything, but save a copy of the index of the menu item that was
* -clicked on.
*
* [We do this differently now?? ++ATM 20040722]
*/
DWORD dwPos = ::GetMessagePos(); DWORD dwPos = ::GetMessagePos();
CPoint point ((int) LOWORD(dwPos), (int) HIWORD(dwPos)); CPoint point ((int) LOWORD(dwPos), (int) HIWORD(dwPos));
ScreenToClient(&point); ScreenToClient(&point);
@ -922,11 +759,7 @@ ContentList::OnRightClick(NMHDR*, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* void ContentList::SelectAll(void)
* Mark everything as selected.
*/
void
ContentList::SelectAll(void)
{ {
int i; int i;
@ -937,11 +770,7 @@ ContentList::SelectAll(void)
} }
} }
/* void ContentList::InvertSelection(void)
* Toggle the "selected" state flag.
*/
void
ContentList::InvertSelection(void)
{ {
int i, oldState; int i, oldState;
@ -953,29 +782,26 @@ ContentList::InvertSelection(void)
} }
} }
/* void ContentList::SelectSubdirContents(void)
* Select the contents of any selected subdirs.
*
* We do the selection by prefix matching on the display name. This means
* we do one pass through the list for the contents of a subdir, including
* all of its subdirs. However, the subdirs we select as we're going will
* be indistinguishable from subdirs selected by the user, which could
* result in O(n^2) behavior.
*
* We mark the user's selection with LVIS_CUT, process them all, then go
* back and clear all of the LVIS_CUT flags. Of course, if they select
* the entire archive, we're approach O(n^2) anyway. If efficiency is a
* problem we will need to sort the list, do some work, then sort it back
* the way it was.
*
* This doesn't work for volume directories, because their display name
* isn't quite right. That's okay for now -- we document that we don't
* allow deletion of the volume directory. (We don't currently have a test
* to see if a GenericEntry is a volume dir; might want to add one.)
*/
void
ContentList::SelectSubdirContents(void)
{ {
/*
* We do the selection by prefix matching on the display name. This means
* we do one pass through the list for the contents of a subdir, including
* all of its subdirs. However, the subdirs we select as we're going will
* be indistinguishable from subdirs selected by the user, which could
* result in O(n^2) behavior.
*
* We mark the user's selection with LVIS_CUT, process them all, then go
* back and clear all of the LVIS_CUT flags. Of course, if they select
* the entire archive, we're approach O(n^2) anyway. If efficiency is a
* problem we will need to sort the list, do some work, then sort it back
* the way it was.
*
* This doesn't work for volume directories, because their display name
* isn't quite right. That's okay for now -- we document that we don't
* allow deletion of the volume directory. (We don't currently have a test
* to see if a GenericEntry is a volume dir; might want to add one.)
*/
POSITION posn; POSITION posn;
posn = GetFirstSelectedItemPosition(); posn = GetFirstSelectedItemPosition();
if (posn == NULL) { if (posn == NULL) {
@ -1018,11 +844,7 @@ ContentList::SelectSubdirContents(void)
} }
} }
/* void ContentList::SelectSubdir(const WCHAR* displayPrefix)
* Select every entry whose display name has "displayPrefix" as a prefix.
*/
void
ContentList::SelectSubdir(const WCHAR* displayPrefix)
{ {
LOGI(" ContentList selecting all in '%ls'", displayPrefix); LOGI(" ContentList selecting all in '%ls'", displayPrefix);
int len = wcslen(displayPrefix); int len = wcslen(displayPrefix);
@ -1035,22 +857,13 @@ ContentList::SelectSubdir(const WCHAR* displayPrefix)
} }
} }
/* void ContentList::ClearSelection(void)
* Mark all items as unselected.
*/
void
ContentList::ClearSelection(void)
{ {
for (int i = GetItemCount()-1; i >= 0; i--) for (int i = GetItemCount()-1; i >= 0; i--)
SetItemState(i, 0, LVIS_SELECTED); SetItemState(i, 0, LVIS_SELECTED);
} }
/* void ContentList::FindNext(const WCHAR* str, bool down, bool matchCase,
* Find the next matching entry. We start after the first selected item.
* If we find a matching entry, we clear the current selection and select it.
*/
void
ContentList::FindNext(const WCHAR* str, bool down, bool matchCase,
bool wholeWord) bool wholeWord)
{ {
POSITION posn; POSITION posn;
@ -1110,11 +923,7 @@ ContentList::FindNext(const WCHAR* str, bool down, bool matchCase,
} }
} }
/* bool ContentList::CompareFindString(int num, const WCHAR* str, bool matchCase,
* Compare "str" against the contents of entry "num".
*/
bool
ContentList::CompareFindString(int num, const WCHAR* str, bool matchCase,
bool wholeWord) bool wholeWord)
{ {
GenericEntry* pEntry = (GenericEntry*) GetItemData(num); GenericEntry* pEntry = (GenericEntry*) GetItemData(num);

View File

@ -4,7 +4,7 @@
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/* /*
* Class declaration for a list control showing archive contents. * Declarations for a list control showing archive contents.
*/ */
#ifndef APP_CONTENTLIST_H #ifndef APP_CONTENTLIST_H
#define APP_CONTENTLIST_H #define APP_CONTENTLIST_H
@ -45,21 +45,69 @@ public:
fpArchive->ClearReloadFlag(); fpArchive->ClearReloadFlag();
} }
// call this before updating underlying storage; call Reload to un-inval /*
// void Invalidate(void); * The archive contents have changed. Reload the list from the
// reload from underlying storage * GenericArchive.
*
* Reloading causes the current selection and view position to be lost. This
* is sort of annoying if all we did is add a comment, so we try to save the
* selection and reapply it. To do this correctly we need some sort of
* unique identifier so we can spot the records that have come back.
*
* Nothing in GenericArchive should be considered valid at this point.
*/
void Reload(bool saveSelection = false); void Reload(bool saveSelection = false);
/*
* Call this when the sort order changes.
*/
void NewSortOrder(void); void NewSortOrder(void);
/*
* Call this when the column widths are changed programmatically (e.g. by
* the preferences page enabling or disabling columns).
*
* We want to set any defaulted entries to actual values so that, if the
* font properties change, column A doesn't resize when column B is tweaked
* in the Preferences dialog. (If it's still set to "default", then when
* we say "update all widths" the defaultedness will be re-evaluated.)
*/
void NewColumnWidths(void); void NewColumnWidths(void);
/*
* Copy the current column widths out to the Preferences object.
*/
void ExportColumnWidths(void); void ExportColumnWidths(void);
/*
* Mark everything as selected.
*/
void SelectAll(void); void SelectAll(void);
/*
* Toggle the "selected" state flag.
*/
void InvertSelection(void); void InvertSelection(void);
/*
* Mark all items as unselected.
*/
void ClearSelection(void); void ClearSelection(void);
/*
* Select the contents of any selected subdirs.
*/
void SelectSubdirContents(void); void SelectSubdirContents(void);
/*
* Find the next matching entry. We start after the first selected item.
* If we find a matching entry, we clear the current selection and select it.
*/
void FindNext(const WCHAR* str, bool down, bool matchCase, bool wholeWord); void FindNext(const WCHAR* str, bool down, bool matchCase, bool wholeWord);
/*
* Compare "str" against the contents of entry "num".
*/
bool CompareFindString(int num, const WCHAR* str, bool matchCase, bool CompareFindString(int num, const WCHAR* str, bool matchCase,
bool wholeWord); bool wholeWord);
@ -67,21 +115,63 @@ public:
//void ClearRightClickItem(void) { fRightClickItem = -1; } //void ClearRightClickItem(void) { fRightClickItem = -1; }
enum { kFileTypeBufLen = 5, kAuxTypeBufLen = 6 }; enum { kFileTypeBufLen = 5, kAuxTypeBufLen = 6 };
/*
* Get the file type display string.
*
* "buf" must be able to hold at least 4 characters plus the NUL (i.e. 5).
* Use kFileTypeBufLen.
*/
static void MakeFileTypeDisplayString(const GenericEntry* pEntry, static void MakeFileTypeDisplayString(const GenericEntry* pEntry,
WCHAR* buf); WCHAR* buf);
/*
* Get the aux type display string.
*
* "buf" must be able to hold at least 5 characters plus the NUL (i.e. 6).
* Use kFileTypeBufLen.
*/
static void MakeAuxTypeDisplayString(const GenericEntry* pEntry, static void MakeAuxTypeDisplayString(const GenericEntry* pEntry,
WCHAR* buf); WCHAR* buf);
protected: protected:
// overridden functions /*
virtual BOOL PreCreateWindow(CREATESTRUCT& cs); * Puts the window into "report" mode, and add a client edge since we're not
virtual void PostNcDestroy(void); * using one on the frame window.
*/
virtual BOOL PreCreateWindow(CREATESTRUCT& cs) override;
// Destroy "this".
virtual void PostNcDestroy(void) override;
/*
* Create and populate list control.
*/
afx_msg int OnCreate(LPCREATESTRUCT); afx_msg int OnCreate(LPCREATESTRUCT);
/*
* When being shut down, save off the column width info before the window
* gets destroyed.
*/
afx_msg void OnDestroy(void); afx_msg void OnDestroy(void);
/*
* The system colors are changing; delete the image list and re-load it.
*/
afx_msg void OnSysColorChange(void); afx_msg void OnSysColorChange(void);
//afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
/*
* They've clicked on a header. Figure out what kind of sort order we want
* to use.
*/
afx_msg void OnColumnClick(NMHDR*, LRESULT*); afx_msg void OnColumnClick(NMHDR*, LRESULT*);
/*
* Return the value for a particular row and column.
*
* This gets called *a lot* while the list is being drawn, scrolled, etc.
* Don't do anything too expensive.
*/
afx_msg void OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult); afx_msg void OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult);
private: private:
@ -105,22 +195,79 @@ private:
kListIconDamaged = 3, kListIconDamaged = 3,
kListIconSuspicious = 4, kListIconSuspicious = 4,
}; };
/*
* Fill the columns with data from the archive entries. We use a "virtual"
* list control to avoid storing everything multiple times. However, we
* still create one item per entry so that the list control will do most
* of the sorting for us (otherwise we have to do the sorting ourselves).
*
* Someday we should probably move to a wholly virtual list view.
*/
int LoadData(void); int LoadData(void);
/*
* Get the "selection serials" from the list of selected items.
*
* The caller is responsible for delete[]ing the return value.
*/
long* GetSelectionSerials(long* pSelCount); long* GetSelectionSerials(long* pSelCount);
/*
* Restore the selection from the "savedSel" list.
*/
void RestoreSelection(const long* savedSel, long selCount); void RestoreSelection(const long* savedSel, long selCount);
/*
* Return the default width for the specified column.
*/
int GetDefaultWidth(int col); int GetDefaultWidth(int col);
/*
* Convert an HFS file/creator type into a string.
*
* "buf" must be able to hold at least 4 characters plus the NUL. Use
* kFileTypeBufLen.
*/
static void MakeMacTypeString(unsigned long val, WCHAR* buf); static void MakeMacTypeString(unsigned long val, WCHAR* buf);
/*
* Generate the funky ratio display string. While we're at it, return a
* numeric value that we can sort on.
*
* "buf" must be able to hold at least 6 chars plus the NULL.
*/
static void MakeRatioDisplayString(const GenericEntry* pEntry, WCHAR* buf, static void MakeRatioDisplayString(const GenericEntry* pEntry, WCHAR* buf,
int* pPerc); int* pPerc);
/*
* Set the up/down sorting arrow as appropriate.
*/
void SetSortIcon(void); void SetSortIcon(void);
/*
* Static comparison function for list sorting.
*/
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2,
LPARAM lParamSort); LPARAM lParamSort);
/*
* Handle a double-click on an item.
*
* The double-click should single-select the item, so we can throw it
* straight into the viewer. However, there are some uses for bulk
* double-clicking.
*/
void OnDoubleClick(NMHDR* pnmh, LRESULT* pResult); void OnDoubleClick(NMHDR* pnmh, LRESULT* pResult);
/*
* Handle a right-click on an item.
*/
void OnRightClick(NMHDR* pnmh, LRESULT* pResult); void OnRightClick(NMHDR* pnmh, LRESULT* pResult);
/*
* Select every entry whose display name has "displayPrefix" as a prefix.
*/
void SelectSubdir(const WCHAR* displayPrefix); void SelectSubdir(const WCHAR* displayPrefix);
CImageList fHdrImageList; CImageList fHdrImageList;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for ConvDiskOptionsDialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "ConvDiskOptionsDialog.h" #include "ConvDiskOptionsDialog.h"
#include "NufxArchive.h" #include "NufxArchive.h"
@ -27,14 +24,10 @@ BEGIN_MESSAGE_MAP(ConvDiskOptionsDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
// TODO: get this from DiskImgLib header?
const int kProDOSVolNameMax = 15; // longest possible ProDOS volume name const int kProDOSVolNameMax = 15; // longest possible ProDOS volume name
/* BOOL ConvDiskOptionsDialog::OnInitDialog(void)
* Set up our modified version of the "use selection" dialog.
*/
BOOL
ConvDiskOptionsDialog::OnInitDialog(void)
{ {
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_CONVDISK_VOLNAME); CEdit* pEdit = (CEdit*) GetDlgItem(IDC_CONVDISK_VOLNAME);
ASSERT(pEdit != NULL); ASSERT(pEdit != NULL);
@ -50,11 +43,7 @@ ConvDiskOptionsDialog::OnInitDialog(void)
return UseSelectionDialog::OnInitDialog(); return UseSelectionDialog::OnInitDialog();
} }
/* void ConvDiskOptionsDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
ConvDiskOptionsDialog::DoDataExchange(CDataExchange* pDX)
{ {
UINT specifyBlocks = 280; UINT specifyBlocks = 280;
CString errMsg; CString errMsg;
@ -99,12 +88,7 @@ ConvDiskOptionsDialog::DoDataExchange(CDataExchange* pDX)
UseSelectionDialog::DoDataExchange(pDX); UseSelectionDialog::DoDataExchange(pDX);
} }
/* void ConvDiskOptionsDialog::OnRadioChangeRange(UINT nID)
* When one of the radio buttons is clicked on, update the active status
* and contents of the "specify size" edit box.
*/
void
ConvDiskOptionsDialog::OnRadioChangeRange(UINT nID)
{ {
LOGI("OnChangeRange id=%d", nID); LOGI("OnChangeRange id=%d", nID);
@ -115,25 +99,13 @@ ConvDiskOptionsDialog::OnRadioChangeRange(UINT nID)
NewDiskSize::UpdateSpecifyEdit(this); NewDiskSize::UpdateSpecifyEdit(this);
} }
/* bool ConvDiskOptionsDialog::IsValidVolumeName_ProDOS(const WCHAR* name)
* Test a ProDOS filename for validity.
*/
bool
ConvDiskOptionsDialog::IsValidVolumeName_ProDOS(const WCHAR* name)
{ {
CStringA nameA(name); CStringA nameA(name);
return DiskImgLib::DiskFSProDOS::IsValidVolumeName(nameA); return DiskImgLib::DiskFSProDOS::IsValidVolumeName(nameA);
} }
void ConvDiskOptionsDialog::ResetSizeControls(void)
/*
* Enable all size radio buttons and reset the "size required" display.
*
* This should be invoked whenever the convert selection changes, and may be
* called at any time.
*/
void
ConvDiskOptionsDialog::ResetSizeControls(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString spaceReq; CString spaceReq;
@ -155,14 +127,7 @@ ConvDiskOptionsDialog::ResetSizeControls(void)
NewDiskSize::EnableButtons(this); NewDiskSize::EnableButtons(this);
} }
/* void ConvDiskOptionsDialog::LimitSizeControls(long totalBlocks, long blocksUsed)
* Display the space requirements and disable radio button controls that are
* for values that are too small.
*
* Pass in the number of blocks required on a 32MB ProDOS volume.
*/
void
ConvDiskOptionsDialog::LimitSizeControls(long totalBlocks, long blocksUsed)
{ {
LOGI("LimitSizeControls %ld %ld", totalBlocks, blocksUsed); LOGI("LimitSizeControls %ld %ld", totalBlocks, blocksUsed);
LOGI("Full volume requires %ld bitmap blocks", LOGI("Full volume requires %ld bitmap blocks",
@ -209,17 +174,7 @@ ConvDiskOptionsDialog::LimitSizeControls(long totalBlocks, long blocksUsed)
#endif #endif
} }
void ConvDiskOptionsDialog::OnCompute(void)
/*
* Compute the amount of space required for the files. We use the result to
* disable the controls that can't be used.
*
* We don't need to enable controls here, because the only way to change the
* set of files is by flipping between "all" and "selected", and we can handle
* that separately.
*/
void
ConvDiskOptionsDialog::OnCompute(void)
{ {
MainWindow* pMain = (MainWindow*)::AfxGetMainWnd(); MainWindow* pMain = (MainWindow*)::AfxGetMainWnd();
const Preferences* pPreferences = GET_PREFERENCES(); const Preferences* pPreferences = GET_PREFERENCES();

View File

@ -35,16 +35,44 @@ public:
long fNumBlocks; // computed when DoModal finishes long fNumBlocks; // computed when DoModal finishes
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
// BOOL OnHelpInfo(HELPINFO* lpHelpInfo); /*
* Enable all size radio buttons and reset the "size required" display.
*
* This should be invoked whenever the convert selection changes, and may be
* called at any time.
*/
afx_msg void ResetSizeControls(void); afx_msg void ResetSizeControls(void);
/*
* Compute the amount of space required for the files. We use the result to
* disable the controls that can't be used.
*
* We don't need to enable controls here, because the only way to change the
* set of files is by flipping between "all" and "selected", and we can handle
* that separately.
*/
afx_msg void OnCompute(void); afx_msg void OnCompute(void);
/*
* When one of the radio buttons is clicked on, update the active status
* and contents of the "specify size" edit box.
*/
afx_msg void OnRadioChangeRange(UINT nID); afx_msg void OnRadioChangeRange(UINT nID);
/*
* Display the space requirements and disable radio button controls that are
* for values that are too small.
*
* Pass in the number of blocks required on a 32MB ProDOS volume.
*/
void LimitSizeControls(long totalBlocks, long blocksUsed); void LimitSizeControls(long totalBlocks, long blocksUsed);
/*
* Test a ProDOS filename for validity.
*/
bool IsValidVolumeName_ProDOS(const WCHAR* name); bool IsValidVolumeName_ProDOS(const WCHAR* name);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()

View File

@ -3,29 +3,11 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for ConvFileOptionsDialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "ConvFileOptionsDialog.h" #include "ConvFileOptionsDialog.h"
//#include "NufxArchive.h"
#if 0
/*
* Set up our modified version of the "use selection" dialog.
*/
BOOL
ConvFileOptionsDialog::OnInitDialog(void)
{
return UseSelectionDialog::OnInitDialog();
}
#endif
/* void ConvFileOptionsDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
ConvFileOptionsDialog::DoDataExchange(CDataExchange* pDX)
{ {
//DDX_Check(pDX, IDC_CONVFILE_CONVDOS, fConvDOSText); //DDX_Check(pDX, IDC_CONVFILE_CONVDOS, fConvDOSText);
//DDX_Check(pDX, IDC_CONVFILE_CONVPASCAL, fConvPascalText); //DDX_Check(pDX, IDC_CONVFILE_CONVPASCAL, fConvPascalText);

View File

@ -29,8 +29,7 @@ public:
BOOL fPreserveEmptyFolders; BOOL fPreserveEmptyFolders;
private: private:
//virtual BOOL OnInitDialog(void); virtual void DoDataExchange(CDataExchange* pDX) override;
virtual void DoDataExchange(CDataExchange* pDX);
//DECLARE_MESSAGE_MAP() //DECLARE_MESSAGE_MAP()
}; };

View File

@ -22,17 +22,13 @@ BEGIN_MESSAGE_MAP(CreateImageDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
// TODO: obtain from DiskImgLib header?
const int kProDOSVolNameMax = 15; // longest possible ProDOS volume name const int kProDOSVolNameMax = 15; // longest possible ProDOS volume name
const int kPascalVolNameMax = 7; // longest possible Pascal volume name const int kPascalVolNameMax = 7; // longest possible Pascal volume name
const int kHFSVolNameMax = 27; // longest possible HFS volume name const int kHFSVolNameMax = 27; // longest possible HFS volume name
const long kMaxBlankBlocks = 16777216; // 8GB in 512-byte blocks const long kMaxBlankBlocks = 16777216; // 8GB in 512-byte blocks
/* BOOL CreateImageDialog::OnInitDialog(void)
* Set up our modified version of the "use selection" dialog.
*/
BOOL
CreateImageDialog::OnInitDialog(void)
{ {
// high bit set in signed short means key is down // high bit set in signed short means key is down
if (::GetKeyState(VK_SHIFT) < 0) { if (::GetKeyState(VK_SHIFT) < 0) {
@ -63,11 +59,7 @@ CreateImageDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void CreateImageDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
CreateImageDialog::DoDataExchange(CDataExchange* pDX)
{ {
UINT specifyBlocks = 280; UINT specifyBlocks = 280;
CString errMsg; CString errMsg;
@ -169,12 +161,7 @@ CreateImageDialog::DoDataExchange(CDataExchange* pDX)
CDialog::DoDataExchange(pDX); CDialog::DoDataExchange(pDX);
} }
/* void CreateImageDialog::OnFormatChangeRange(UINT nID)
* When the user chooses a format, enable and disable controls as
* appropriate.
*/
void
CreateImageDialog::OnFormatChangeRange(UINT nID)
{ {
static const struct { static const struct {
UINT buttonID; UINT buttonID;
@ -262,12 +249,7 @@ CreateImageDialog::OnFormatChangeRange(UINT nID)
} }
} }
/* void CreateImageDialog::OnSizeChangeRange(UINT nID)
* When one of the radio buttons is clicked on, update the active status
* and contents of the "specify size" edit box.
*/
void
CreateImageDialog::OnSizeChangeRange(UINT nID)
{ {
LOGI("OnSizeChangeRange id=%d", nID); LOGI("OnSizeChangeRange id=%d", nID);
@ -290,62 +272,37 @@ CreateImageDialog::OnSizeChangeRange(UINT nID)
} }
/* bool CreateImageDialog::IsValidVolumeName_DOS(const WCHAR* name)
* Test a DOS filename for validity.
*/
bool
CreateImageDialog::IsValidVolumeName_DOS(const WCHAR* name)
{ {
CStringA nameStr(name); CStringA nameStr(name);
return DiskImgLib::DiskFSDOS33::IsValidVolumeName(nameStr); return DiskImgLib::DiskFSDOS33::IsValidVolumeName(nameStr);
} }
/* bool CreateImageDialog::IsValidVolumeName_ProDOS(const WCHAR* name)
* Test a ProDOS filename for validity.
*/
bool
CreateImageDialog::IsValidVolumeName_ProDOS(const WCHAR* name)
{ {
CStringA nameStr(name); CStringA nameStr(name);
return DiskImgLib::DiskFSProDOS::IsValidVolumeName(nameStr); return DiskImgLib::DiskFSProDOS::IsValidVolumeName(nameStr);
} }
/* bool CreateImageDialog::IsValidVolumeName_Pascal(const WCHAR* name)
* Test a Pascal filename for validity.
*/
bool
CreateImageDialog::IsValidVolumeName_Pascal(const WCHAR* name)
{ {
CStringA nameStr(name); CStringA nameStr(name);
return DiskImgLib::DiskFSPascal::IsValidVolumeName(nameStr); return DiskImgLib::DiskFSPascal::IsValidVolumeName(nameStr);
} }
/* bool CreateImageDialog::IsValidVolumeName_HFS(const WCHAR* name)
* Test an HFS filename for validity.
*/
bool
CreateImageDialog::IsValidVolumeName_HFS(const WCHAR* name)
{ {
CStringA nameStr(name); CStringA nameStr(name);
return DiskImgLib::DiskFSHFS::IsValidVolumeName(nameStr); return DiskImgLib::DiskFSHFS::IsValidVolumeName(nameStr);
} }
BOOL CreateImageDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
/*
* Context help request (question mark button).
*/
BOOL
CreateImageDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void CreateImageDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
CreateImageDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_IMAGE_CREATOR, HELP_CONTEXT); WinHelp(HELP_TOPIC_IMAGE_CREATOR, HELP_CONTEXT);
} }

View File

@ -52,14 +52,27 @@ public:
long fNumBlocks; // computed when DoModal finishes long fNumBlocks; // computed when DoModal finishes
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
// BOOL OnHelpInfo(HELPINFO* lpHelpInfo); // afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
/*
* When the user chooses a format, enable and disable controls as
* appropriate.
*/
afx_msg void OnFormatChangeRange(UINT nID); afx_msg void OnFormatChangeRange(UINT nID);
/*
* When one of the radio buttons is clicked on, update the active status
* and contents of the "specify size" edit box.
*/
afx_msg void OnSizeChangeRange(UINT nID); afx_msg void OnSizeChangeRange(UINT nID);
// Context help (question mark).
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
// Dialog help ("help" button).
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
bool IsValidVolumeName_DOS(const WCHAR* name); bool IsValidVolumeName_DOS(const WCHAR* name);

View File

@ -16,11 +16,7 @@ BEGIN_MESSAGE_MAP(CreateSubdirDialog, CDialog)
ON_WM_HELPINFO() ON_WM_HELPINFO()
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL CreateSubdirDialog::OnInitDialog(void)
* Set up the control.
*/
BOOL
CreateSubdirDialog::OnInitDialog(void)
{ {
/* do the DoDataExchange stuff */ /* do the DoDataExchange stuff */
CDialog::OnInitDialog(); CDialog::OnInitDialog();
@ -34,11 +30,7 @@ CreateSubdirDialog::OnInitDialog(void)
return FALSE; // we set the focus return FALSE; // we set the focus
} }
/* void CreateSubdirDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
CreateSubdirDialog::DoDataExchange(CDataExchange* pDX)
{ {
CString msg, failed; CString msg, failed;
@ -71,11 +63,7 @@ fail:
return; return;
} }
/* BOOL CreateSubdirDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
CreateSubdirDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it

View File

@ -32,9 +32,10 @@ public:
protected: protected:
// overrides // overrides
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
// Context help request (question mark button).
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
private: private:

View File

@ -15,12 +15,7 @@ BEGIN_MESSAGE_MAP(DEFileDialog, CDialog)
ON_WM_HELPINFO() ON_WM_HELPINFO()
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL DEFileDialog::OnInitDialog(void)
* Turn off the "OK" button, which is only active when some text
* has been typed in the window.
*/
BOOL
DEFileDialog::OnInitDialog(void)
{ {
CWnd* pWnd = GetDlgItem(IDOK); CWnd* pWnd = GetDlgItem(IDOK);
ASSERT(pWnd != NULL); ASSERT(pWnd != NULL);
@ -29,22 +24,13 @@ DEFileDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void DEFileDialog::DoDataExchange(CDataExchange* pDX)
* Get the filename and the "open resource fork" check box.
*/
void
DEFileDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_Text(pDX, IDC_DEFILE_FILENAME, fName); DDX_Text(pDX, IDC_DEFILE_FILENAME, fName);
DDX_Check(pDX, IDC_DEFILE_RSRC, fOpenRsrcFork); DDX_Check(pDX, IDC_DEFILE_RSRC, fOpenRsrcFork);
} }
/* void DEFileDialog::OnChange(void)
* The text has changed. If there's nothing in the box, dim the
* "OK" button.
*/
void
DEFileDialog::OnChange(void)
{ {
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_DEFILE_FILENAME); CEdit* pEdit = (CEdit*) GetDlgItem(IDC_DEFILE_FILENAME);
ASSERT(pEdit != NULL); ASSERT(pEdit != NULL);
@ -58,11 +44,7 @@ DEFileDialog::OnChange(void)
pWnd->EnableWindow(!str.IsEmpty()); pWnd->EnableWindow(!str.IsEmpty());
} }
/* BOOL DEFileDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
DEFileDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it

View File

@ -44,11 +44,23 @@ public:
int fOpenRsrcFork; int fOpenRsrcFork;
protected: protected:
// overrides /*
virtual BOOL OnInitDialog(void); * Turn off the "OK" button, which is only active when some text
virtual void DoDataExchange(CDataExchange* pDX); * has been typed in the window.
*/
virtual BOOL OnInitDialog(void) override;
/*
* Get the filename and the "open resource fork" check box.
*/
virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* The text has changed. If there's nothing in the box, dim the
* "OK" button.
*/
afx_msg virtual void OnChange(void); afx_msg virtual void OnChange(void);
afx_msg virtual BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg virtual BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
private: private:

View File

@ -17,7 +17,7 @@
#include "ConfirmOverwriteDialog.h" #include "ConfirmOverwriteDialog.h"
#include "../diskimg/DiskImgDetail.h" #include "../diskimg/DiskImgDetail.h"
static const char* kEmptyFolderMarker = ".$$EmptyFolder"; static const char kEmptyFolderMarker[] = ".$$EmptyFolder";
/* /*
@ -26,24 +26,7 @@ static const char* kEmptyFolderMarker = ".$$EmptyFolder";
* =========================================================================== * ===========================================================================
*/ */
/* int DiskEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
* Extract data from a disk image.
*
* If "*ppText" is non-NULL, the data will be read into the pointed-to buffer
* so long as it's shorter than *pLength bytes. The value in "*pLength"
* will be set to the actual length used.
*
* If "*ppText" is NULL, the uncompressed data will be placed into a buffer
* allocated with "new[]".
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pErrMsg" holds an error
* message.
*
* "which" is an anonymous GenericArchive enum (e.g. "kDataThread").
*/
int
DiskEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const CString* pErrMsg) const
{ {
DIError dierr; DIError dierr;
@ -150,16 +133,7 @@ bail:
return result; return result;
} }
/* int DiskEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
* Extract data from a thread to a file. Since we're not copying to memory,
* we can't assume that we're able to hold the entire file all at once.
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pMsg" holds an
* error message.
*/
int
DiskEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const ConvertHighASCII convHA, CString* pErrMsg) const
{ {
A2FileDescr* pOpenFile = NULL; A2FileDescr* pOpenFile = NULL;
@ -219,12 +193,7 @@ bail:
return result; return result;
} }
/* DIError DiskEntry::CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv,
* Copy data from the open A2File to outfp, possibly converting EOL along
* the way.
*/
DIError
DiskEntry::CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pMsg) const ConvertHighASCII convHA, CString* pMsg) const
{ {
DIError dierr = kDIErrNone; DIError dierr = kDIErrNone;
@ -287,13 +256,7 @@ bail:
return dierr; return dierr;
} }
bool DiskEntry::GetFeatureFlag(Feature feature) const
/*
* Figure out whether or not we're allowed to change a file's type and
* aux type.
*/
bool
DiskEntry::GetFeatureFlag(Feature feature) const
{ {
DiskImg::FSFormat format; DiskImg::FSFormat format;
@ -392,11 +355,7 @@ DiskEntry::GetFeatureFlag(Feature feature) const
* =========================================================================== * ===========================================================================
*/ */
/* /*static*/ CString DiskArchive::AppInit(void)
* Perform one-time initialization of the DiskLib library.
*/
/*static*/ CString
DiskArchive::AppInit(void)
{ {
CString result(""); CString result("");
DIError dierr; DIError dierr;
@ -427,21 +386,13 @@ bail:
return result; return result;
} }
/* /*static*/ void DiskArchive::AppCleanup(void)
* Perform one-time cleanup of DiskImgLib at shutdown time.
*/
/*static*/ void
DiskArchive::AppCleanup(void)
{ {
DiskImgLib::Global::AppCleanup(); DiskImgLib::Global::AppCleanup();
} }
/*static*/ void DiskArchive::DebugMsgHandler(const char* file, int line,
/* const char* msg)
* Handle a debug message from the DiskImg library.
*/
/*static*/ void
DiskArchive::DebugMsgHandler(const char* file, int line, const char* msg)
{ {
ASSERT(file != NULL); ASSERT(file != NULL);
ASSERT(msg != NULL); ASSERT(msg != NULL);
@ -449,14 +400,7 @@ DiskArchive::DebugMsgHandler(const char* file, int line, const char* msg)
LOG_BASE(DebugLog::LOG_INFO, file, line, "<diskimg> %hs", msg); LOG_BASE(DebugLog::LOG_INFO, file, line, "<diskimg> %hs", msg);
} }
/* /*static*/ bool DiskArchive::ProgressCallback(DiskImgLib::A2FileDescr* pFile,
* Progress update callback, called from DiskImgLib during read/write
* operations.
*
* Returns "true" if we should continue;
*/
/*static*/ bool
DiskArchive::ProgressCallback(DiskImgLib::A2FileDescr* pFile,
DiskImgLib::di_off_t max, DiskImgLib::di_off_t current, void* state) DiskImgLib::di_off_t max, DiskImgLib::di_off_t current, void* state)
{ {
int status; int status;
@ -471,16 +415,8 @@ DiskArchive::ProgressCallback(DiskImgLib::A2FileDescr* pFile,
return true; // tell DiskImgLib to continue what it's doing return true; // tell DiskImgLib to continue what it's doing
} }
/* /*static*/ bool DiskArchive::ScanProgressCallback(void* cookie, const char* str,
* Progress update callback, called from DiskImgLib while scanning a volume int count)
* during Open().
*
* "str" must not contain a '%'. (TODO: fix that)
*
* Returns "true" if we should continue.
*/
/*static*/ bool
DiskArchive::ScanProgressCallback(void* cookie, const char* str, int count)
{ {
CString fmt; CString fmt;
bool cont; bool cont;
@ -498,12 +434,8 @@ DiskArchive::ScanProgressCallback(void* cookie, const char* str, int count)
return cont; return cont;
} }
GenericArchive::OpenResult DiskArchive::Open(const WCHAR* filename,
/* bool readOnly, CString* pErrMsg)
* Finish instantiating a DiskArchive object by opening an existing file.
*/
GenericArchive::OpenResult
DiskArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
{ {
DIError dierr; DIError dierr;
CString errMsg; CString errMsg;
@ -715,14 +647,7 @@ bail:
return result; return result;
} }
CString DiskArchive::New(const WCHAR* fileName, const void* vOptions)
/*
* Finish instantiating a DiskArchive object by creating a new archive.
*
* Returns an error string on failure, or "" on success.
*/
CString
DiskArchive::New(const WCHAR* fileName, const void* vOptions)
{ {
const Preferences* pPreferences = GET_PREFERENCES(); const Preferences* pPreferences = GET_PREFERENCES();
NewOptions* pOptions = (NewOptions*) vOptions; NewOptions* pOptions = (NewOptions*) vOptions;
@ -901,11 +826,7 @@ bail:
return retmsg; return retmsg;
} }
/* CString DiskArchive::Close(void)
* Close the DiskArchive ojbect.
*/
CString
DiskArchive::Close(void)
{ {
if (fpPrimaryDiskFS != NULL) { if (fpPrimaryDiskFS != NULL) {
LOGI("DiskArchive shutdown closing disk image"); LOGI("DiskArchive shutdown closing disk image");
@ -930,17 +851,7 @@ DiskArchive::Close(void)
return L""; return L"";
} }
/* CString DiskArchive::Flush(void)
* Flush the DiskArchive object.
*
* Most of the stuff we do with disk images goes straight through, but in
* the case of compressed disks we don't normally re-compress them until
* it's time to close them. This forces us to update the copy on disk.
*
* Returns an empty string on success, or an error message on failure.
*/
CString
DiskArchive::Flush(void)
{ {
DIError dierr; DIError dierr;
CWaitCursor waitc; CWaitCursor waitc;
@ -959,23 +870,14 @@ DiskArchive::Flush(void)
return L""; return L"";
} }
/* bool DiskArchive::IsModified(void) const
* Returns "true" if the archive has un-flushed modifications pending.
*/
bool
DiskArchive::IsModified(void) const
{ {
assert(fpPrimaryDiskFS != NULL); assert(fpPrimaryDiskFS != NULL);
return fpPrimaryDiskFS->GetDiskImg()->GetDirtyFlag(); return fpPrimaryDiskFS->GetDiskImg()->GetDirtyFlag();
} }
/* void DiskArchive::GetDescription(CString* pStr) const
* Return an description of the disk archive, suitable for display in the
* main title bar.
*/
void
DiskArchive::GetDescription(CString* pStr) const
{ {
if (fpPrimaryDiskFS == NULL) if (fpPrimaryDiskFS == NULL)
return; return;
@ -985,14 +887,7 @@ DiskArchive::GetDescription(CString* pStr) const
} }
} }
int DiskArchive::LoadContents(void)
/*
* Load the contents of a "disk archive".
*
* Returns 0 on success.
*/
int
DiskArchive::LoadContents(void)
{ {
int result; int result;
@ -1018,22 +913,7 @@ DiskArchive::LoadContents(void)
return result; return result;
} }
/* CString DiskArchive::Reload()
* Reload the stuff from the underlying DiskFS.
*
* This also does a "lite" flush of the disk data. For files that are
* essentially being written as we go, this does little more than clear
* the "dirty" flag. Files that need to be recompressed or have some
* other slow operation remain dirty.
*
* We don't need to do the flush as part of the reload -- we can load the
* contents with everything in a perfectly dirty state. We don't need to
* do it at all. We do it to keep the "dirty" flag clear when nothing is
* really dirty, and we do it here because almost all of our functions call
* "reload" after making changes, which makes it convenient to call from here.
*/
CString
DiskArchive::Reload()
{ {
fReloadFlag = true; // tell everybody that cached data is invalid fReloadFlag = true; // tell everybody that cached data is invalid
@ -1047,14 +927,7 @@ DiskArchive::Reload()
return ""; return "";
} }
/* int DiskArchive::InternalReload(CWnd* pMsgWnd)
* Reload the contents of the archive, showing an error message if the
* reload fails.
*
* Returns 0 on success, -1 on failure.
*/
int
DiskArchive::InternalReload(CWnd* pMsgWnd)
{ {
CString errMsg; CString errMsg;
@ -1068,14 +941,7 @@ DiskArchive::InternalReload(CWnd* pMsgWnd)
return 0; return 0;
} }
/* int DiskArchive::LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName)
* Load the contents of a DiskFS.
*
* Recursively handle sub-volumes. "volName" holds the name of the
* sub-volume as it should appear in the list.
*/
int
DiskArchive::LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName)
{ {
static const WCHAR* kBlankFileName = L"<blank filename>"; static const WCHAR* kBlankFileName = L"<blank filename>";
A2File* pFile; A2File* pFile;
@ -1231,15 +1097,7 @@ DiskArchive::LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName)
return 0; return 0;
} }
void DiskArchive::PreferencesChanged(void)
/*
* User has updated their preferences. Take note.
*
* Setting preferences in a DiskFS causes those prefs to be pushed down
* to all sub-volumes.
*/
void
DiskArchive::PreferencesChanged(void)
{ {
const Preferences* pPreferences = GET_PREFERENCES(); const Preferences* pPreferences = GET_PREFERENCES();
@ -1251,12 +1109,7 @@ DiskArchive::PreferencesChanged(void)
} }
} }
long DiskArchive::GetCapability(Capability cap)
/*
* Report on what this disk image is capable of.
*/
long
DiskArchive::GetCapability(Capability cap)
{ {
switch (cap) { switch (cap) {
case kCapCanTest: case kCapCanTest:
@ -1297,13 +1150,7 @@ DiskArchive::GetCapability(Capability cap)
* =========================================================================== * ===========================================================================
*/ */
/* bool DiskArchive::BulkAdd(ActionProgressDialog* pActionProgress,
* Process a bulk "add" request.
*
* Returns "true" on success, "false" on failure.
*/
bool
DiskArchive::BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts)
{ {
NuError nerr; NuError nerr;
@ -1396,43 +1243,40 @@ bail:
return retVal; return retVal;
} }
/* NuError DiskArchive::DoAddFile(const AddFilesDialog* pAddOpts,
* Add a file to a disk image.
*
* Unfortunately we can't just add the files here. We need to figure out
* which pairs of files should be combined into a single "extended" file.
* (Yes, the cursed forked files strike again.)
*
* The way you tell if two files should be one is by comparing their
* filenames and type info. If they match, and one is a data fork and
* one is a resource fork, we have a single split file.
*
* We have to be careful here because we don't know which will be seen
* first and whether they'll be adjacent. We have to dig through the
* list of previously-added files for a match (O(n^2) behavior currently).
*
* We also have to compare the right filename. Comparing the Windows
* filename is a bad idea, because by definition one of them has a resource
* fork tag on it. We need to compare the normalized filename before
* the ProDOS normalizer/uniqifier gets a chance to mangle it. As luck
* would have it, that's exactly what we have in "storageName".
*
* For a NuFX archive, NufxLib does all this nonsense for us, but we have
* to manage it ourselves here. The good news is that, since we have to
* wade through all the filenames, we have an opportunity to make the names
* unique. So long as we ensure that the names we have don't clash with
* anything currently on the disk, we know that anything we add that does
* clash is running into something we just added, which means we can turn
* on CreateFile's "make unique" feature and let the filesystem-specific
* code handle uniqueness.
*
* Any fields we want to keep from the NuFileDetails struct need to be
* copied out. It's a "hairy" struct, so we need to duplicate the strings.
*/
NuError
DiskArchive::DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails) FileDetails* pDetails)
{ {
/*
* Add a file to a disk image Unfortunately we can't just add the files
* here. We need to figure which pairs of files should be combined into
* a single "extended" file (yes, the cursed forked files strike again).
*
* The way you tell if two files should be one is by comparing their
* filenames and type info. If they match, and one is a data fork and
* one is a resource fork, we have a single split file.
*
* We have to be careful here because we don't know which will be seen
* first and whether they'll be adjacent. We have to dig through the
* list of previously-added files for a match (O(n^2) behavior currently).
*
* We also have to compare the right filename. Comparing the Windows
* filename is a bad idea, because by definition one of them has a resource
* fork tag on it. We need to compare the normalized filename before
* the ProDOS normalizer/uniqifier gets a chance to mangle it. As luck
* would have it, that's exactly what we have in "storageName".
*
* For a NuFX archive, NufxLib does all this nonsense for us, but we have
* to manage it ourselves here. The good news is that, since we have to
* wade through all the filenames, we have an opportunity to make the names
* unique. So long as we ensure that the names we have don't clash with
* anything currently on the disk, we know that anything we add that does
* clash is running into something we just added, which means we can turn
* on CreateFile's "make unique" feature and let the filesystem-specific
* code handle uniqueness.
*
* Any fields we want to keep from the NuFileDetails struct need to be
* copied out. It's a "hairy" struct, so we need to duplicate the strings.
*/
NuError nuerr = kNuErrNone; NuError nuerr = kNuErrNone;
DiskFS* pDiskFS = pAddOpts->fpTargetDiskFS; DiskFS* pDiskFS = pAddOpts->fpTargetDiskFS;
@ -1527,22 +1371,7 @@ bail:
return nuerr; return nuerr;
} }
/* NuResult DiskArchive::HandleReplaceExisting(const A2File* pExisting,
* A file we're adding clashes with an existing file. Decide what to do
* about it.
*
* Returns one of the following:
* kNuOverwrite - overwrite the existing file
* kNuSkip - skip adding the existing file
* kNuRename - user wants to rename the file
* kNuAbort - cancel out of the entire add process
*
* Side effects:
* Sets fOverwriteExisting and fOverwriteNoAsk if a "to all" button is hit
* Replaces pDetails->storageName if the user elects to rename
*/
NuResult
DiskArchive::HandleReplaceExisting(const A2File* pExisting,
FileDetails* pDetails) FileDetails* pDetails)
{ {
NuResult result; NuResult result;
@ -1602,14 +1431,7 @@ DiskArchive::HandleReplaceExisting(const A2File* pExisting,
return result; return result;
} }
CString DiskArchive::ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL)
/*
* Process the list of pending file adds.
*
* This is where the rubber (finally!) meets the road.
*/
CString
DiskArchive::ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL)
{ {
CString errMsg; CString errMsg;
FileAddData* pData; FileAddData* pData;
@ -1775,25 +1597,14 @@ bail:
return errMsg; return errMsg;
} }
#define kCharLF '\n'
#define kCharCR '\r'
/* // TODO: really ought to update the progress counter, especially when reading
* Load a file into a buffer, possibly converting EOL markers and setting // really large files.
* "high ASCII" along the way. CString DiskArchive::LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
*
* Returns a pointer to a newly-allocated buffer (new[]) and the data length.
* If the file is empty, no buffer will be allocated.
*
* Returns an empty string on success, or an error message on failure.
*
* HEY: really ought to update the progress counter, especially when reading
* really large files.
*/
CString
DiskArchive::LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const
{ {
const char kCharLF = '\n';
const char kCharCR = '\r';
CString errMsg; CString errMsg;
FILE* fp; FILE* fp;
long fileLen; long fileLen;
@ -1950,16 +1761,8 @@ bail:
return errMsg; return errMsg;
} }
/* DIError DiskArchive::AddForksToDisk(DiskFS* pDiskFS,
* Add a file with the supplied data to the disk image. const DiskFS::CreateParms* pParms,
*
* Forks that exist but are empty have a length of zero. Forks that don't
* exist have a length of -1.
*
* Called by XferFile and ProcessFileAddData.
*/
DIError
DiskArchive::AddForksToDisk(DiskFS* pDiskFS, const DiskFS::CreateParms* pParms,
const unsigned char* dataBuf, long dataLen, const unsigned char* dataBuf, long dataLen,
const unsigned char* rsrcBuf, long rsrcLen) const const unsigned char* rsrcBuf, long rsrcLen) const
{ {
@ -2149,14 +1952,7 @@ bail:
return dierr; return dierr;
} }
/* void DiskArchive::ConvertFDToCP(const FileDetails* pDetails,
* Fill out a CreateParms structure from a FileDetails structure.
*
* The NuStorageType values correspond exactly to ProDOS storage types, so
* there's no need to convert them.
*/
void
DiskArchive::ConvertFDToCP(const FileDetails* pDetails,
DiskFS::CreateParms* pCreateParms) DiskFS::CreateParms* pCreateParms)
{ {
// TODO(xyzzy): need to store 8-bit form // TODO(xyzzy): need to store 8-bit form
@ -2170,19 +1966,7 @@ DiskArchive::ConvertFDToCP(const FileDetails* pDetails,
pCreateParms->modWhen = NufxArchive::DateTimeToSeconds(&pDetails->modWhen); pCreateParms->modWhen = NufxArchive::DateTimeToSeconds(&pDetails->modWhen);
} }
void DiskArchive::AddToAddDataList(FileAddData* pData)
/*
* Add an entry to the end of the FileAddData list.
*
* If "storageName" (the Windows filename with type goodies stripped, but
* without filesystem normalization) matches an entry already in the list,
* we check to see if these are forks of the same file. If they are
* different forks and we don't already have both forks, we put the
* pointer into the "fork pointer" of the existing file rather than adding
* it to the end of the list.
*/
void
DiskArchive::AddToAddDataList(FileAddData* pData)
{ {
ASSERT(pData != NULL); ASSERT(pData != NULL);
ASSERT(pData->GetNext() == NULL); ASSERT(pData->GetNext() == NULL);
@ -2234,11 +2018,7 @@ DiskArchive::AddToAddDataList(FileAddData* pData)
} }
} }
/* void DiskArchive::FreeAddDataList(void)
* Free all entries in the FileAddData list.
*/
void
DiskArchive::FreeAddDataList(void)
{ {
FileAddData* pData; FileAddData* pData;
FileAddData* pNext; FileAddData* pNext;
@ -2261,11 +2041,7 @@ DiskArchive::FreeAddDataList(void)
* =========================================================================== * ===========================================================================
*/ */
/* bool DiskArchive::CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
* Create a subdirectory named "newName" in "pParentEntry".
*/
bool
DiskArchive::CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName) const WCHAR* newName)
{ {
ASSERT(newName != NULL && wcslen(newName) > 0); ASSERT(newName != NULL && wcslen(newName) > 0);
@ -2332,11 +2108,8 @@ DiskArchive::CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
* =========================================================================== * ===========================================================================
*/ */
/* /*static*/ int DiskArchive::CompareDisplayNamesDesc(const void* ventry1,
* Compare DiskEntry display names in descending order (Z-A). const void* ventry2)
*/
/*static*/ int
DiskArchive::CompareDisplayNamesDesc(const void* ventry1, const void* ventry2)
{ {
const DiskEntry* pEntry1 = *((const DiskEntry**) ventry1); const DiskEntry* pEntry1 = *((const DiskEntry**) ventry1);
const DiskEntry* pEntry2 = *((const DiskEntry**) ventry2); const DiskEntry* pEntry2 = *((const DiskEntry**) ventry2);
@ -2344,21 +2117,18 @@ DiskArchive::CompareDisplayNamesDesc(const void* ventry1, const void* ventry2)
return wcsicmp(pEntry2->GetDisplayName(), pEntry1->GetDisplayName()); return wcsicmp(pEntry2->GetDisplayName(), pEntry1->GetDisplayName());
} }
/* bool DiskArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
* Delete the records listed in the selection set.
*
* The DiskFS DeleteFile() function will not delete a subdirectory unless
* it is empty. This complicates matters somewhat for us, because the
* selection set isn't in any particular order. We need to sort on the
* pathname and then delete bottom-up.
*
* CiderPress does work to ensure that, if a subdir is selected, everything
* in that subdir is also selected. So if we just delete everything in the
* right order, we should be okay.
*/
bool
DiskArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{ {
/*
* The DiskFS DeleteFile() function will not delete a subdirectory unless
* it is empty. This complicates matters somewhat for us, because the
* selection set isn't in any particular order. We need to sort on the
* pathname and then delete bottom-up.
*
* CiderPress does work to ensure that, if a subdir is selected, everything
* in that subdir is also selected. So if we just delete everything in the
* right order, we should be okay.
*/
CString errMsg; CString errMsg;
SelectionEntry* pSelEntry; SelectionEntry* pSelEntry;
DiskEntry* pEntry; DiskEntry* pEntry;
@ -2467,20 +2237,17 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* bool DiskArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
* Rename a set of files, one at a time.
*
* If we rename a subdirectory, it could affect the next thing we try to
* rename (because we show the full path). We have to reload our file
* list from the DiskFS after each renamed subdir. The trouble is that
* this invalidates the data displayed in the ContentList, and we won't
* redraw the screen correctly. We can work around the problem by getting
* the pathname directly from the DiskFS instead of from DiskEntry, though
* it's not immediately obvious which is less confusing.
*/
bool
DiskArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{ {
/*
* If we rename a subdirectory, it could affect the next thing we try to
* rename (because we show the full path). We have to reload our file
* list from the DiskFS after each renamed subdir. The trouble is that
* this invalidates the data displayed in the ContentList, and we won't
* redraw the screen correctly. We can work around the problem by getting
* the pathname directly from the DiskFS instead of from DiskEntry, though
* it's not immediately obvious which is less confusing.
*/
CString errMsg; CString errMsg;
bool retVal = false; bool retVal = false;
@ -2546,13 +2313,7 @@ bail:
return retVal; return retVal;
} }
/* bool DiskArchive::SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
* Set up a RenameEntryDialog for the entry in "*pEntry".
*
* Returns "true" on success, "false" on failure.
*/
bool
DiskArchive::SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
RenameEntryDialog* pDialog) RenameEntryDialog* pDialog)
{ {
DiskFS* pDiskFS; DiskFS* pDiskFS;
@ -2598,16 +2359,7 @@ DiskArchive::SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
return true; return true;
} }
/* CString DiskArchive::TestPathName(const GenericEntry* pGenericEntry,
* Verify that the a name is suitable. Called by RenameEntryDialog and
* CreateSubdirDialog.
*
* Tests for context-specific syntax and checks for duplicates.
*
* Returns an empty string on success, or an error message on failure.
*/
CString
DiskArchive::TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const const CString& basePath, const CString& newName, char newFssep) const
{ {
const DiskEntry* pEntry = (DiskEntry*) pGenericEntry; const DiskEntry* pEntry = (DiskEntry*) pGenericEntry;
@ -2670,13 +2422,7 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* bool DiskArchive::RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
* Ask a DiskFS to change its volume name.
*
* Returns "true" on success, "false" on failure.
*/
bool
DiskArchive::RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName) const WCHAR* newName)
{ {
DIError dierr; DIError dierr;
@ -2700,11 +2446,7 @@ DiskArchive::RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
return retVal; return retVal;
} }
/* CString DiskArchive::TestVolumeName(const DiskFS* pDiskFS,
* Test a volume name for validity.
*/
CString
DiskArchive::TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const const WCHAR* newName) const
{ {
DiskImg::FSFormat format; DiskImg::FSFormat format;
@ -2748,18 +2490,13 @@ DiskArchive::TestVolumeName(const DiskFS* pDiskFS,
* =========================================================================== * ===========================================================================
*/ */
/* bool DiskArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
* Set the properties of "pEntry" to what's in "pProps".
*
* [currently only supports file type, aux type, and access flags]
*
* Technically we should reload the GenericArchive from the NufxArchive,
* but the set of changes is pretty small, so we just make them here.
*/
bool
DiskArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
const FileProps* pProps) const FileProps* pProps)
{ {
/*
* Technically we should reload the GenericArchive from the disk image,
* but the set of changes is pretty small, so we just make them here.
*/
DIError dierr; DIError dierr;
DiskEntry* pEntry = (DiskEntry*) pGenericEntry; DiskEntry* pEntry = (DiskEntry*) pGenericEntry;
A2File* pFile = pEntry->GetA2File(); A2File* pFile = pEntry->GetA2File();
@ -2802,20 +2539,17 @@ DiskArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
* =========================================================================== * ===========================================================================
*/ */
/* GenericArchive::XferStatus DiskArchive::XferSelection(CWnd* pMsgWnd,
* Transfer the selected files out of this archive and into another. SelectionSet* pSelSet, ActionProgressDialog* pActionProgress,
* const XferFileOptions* pXferOpts)
* In this case, it's files on a disk (with unspecified filesystem) to a NuFX
* archive. We get the open archive pointer and some options from "pXferOpts".
*
* The selection set was created with the "any" selection criteria, which
* means there's only one entry for each file regardless of whether it's
* forked or not.
*/
GenericArchive::XferStatus
DiskArchive::XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts)
{ {
/*
* We get the open archive pointer and some options from "pXferOpts".
*
* The selection set was created with the "any" selection criteria, which
* means there's only one entry for each file regardless of whether it's
* forked or not.
*/
LOGI("DiskArchive XferSelection!"); LOGI("DiskArchive XferSelection!");
unsigned char* dataBuf = NULL; unsigned char* dataBuf = NULL;
unsigned char* rsrcBuf = NULL; unsigned char* rsrcBuf = NULL;
@ -3024,11 +2758,7 @@ bail:
return retval; return retval;
} }
/* void DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
* Prepare for file transfers.
*/
void
DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
{ {
LOGI("DiskArchive::XferPrepare"); LOGI("DiskArchive::XferPrepare");
@ -3042,21 +2772,7 @@ DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
fpXferTargetFS = pXferOpts->fpTargetFS; fpXferTargetFS = pXferOpts->fpTargetFS;
} }
/* CString DiskArchive::XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
* Transfer a file to the disk image. Called from NufxArchive's XferSelection
* and clipboard "paste".
*
* "dataLen" and "rsrcLen" will be -1 if the corresponding fork doesn't
* exist.
*
* Returns 0 on success, nonzero on failure.
*
* On success, *pDataBuf and *pRsrcBuf are freed and set to NULL. (It's
* necessary for the interface to work this way because the NufxArchive
* version just tucks the pointers into NufxLib structures.)
*/
CString
DiskArchive::XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen) long dataLen, uint8_t** pRsrcBuf, long rsrcLen)
{ {
//const int kFileTypeTXT = 0x04; //const int kFileTypeTXT = 0x04;
@ -3144,23 +2860,14 @@ bail:
return errMsg; return errMsg;
} }
void DiskArchive::XferAbort(CWnd* pMsgWnd)
/*
* Abort our progress. Not really possible, except by throwing the disk
* image away.
*/
void
DiskArchive::XferAbort(CWnd* pMsgWnd)
{ {
// Can't undo previous actions.
LOGI("DiskArchive::XferAbort"); LOGI("DiskArchive::XferAbort");
InternalReload(pMsgWnd); InternalReload(pMsgWnd);
} }
/* void DiskArchive::XferFinish(CWnd* pMsgWnd)
* Transfer is finished.
*/
void
DiskArchive::XferFinish(CWnd* pMsgWnd)
{ {
LOGI("DiskArchive::XferFinish"); LOGI("DiskArchive::XferFinish");
InternalReload(pMsgWnd); InternalReload(pMsgWnd);

View File

@ -24,14 +24,19 @@ public:
{} {}
virtual ~DiskEntry(void) {} virtual ~DiskEntry(void) {}
// retrieve thread data
virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength, virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const; CString* pErrMsg) const override;
virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv, virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const; ConvertHighASCII convHA, CString* pErrMsg) const override;
virtual long GetSelectionSerial(void) const { return -1; } // idea: T/S block number
virtual bool GetFeatureFlag(Feature feature) const; virtual long GetSelectionSerial(void) const override
{ return -1; } // idea: T/S block number
/*
* Figure out whether or not we're allowed to change a file's type and
* aux type.
*/
virtual bool GetFeatureFlag(Feature feature) const override;
// return the underlying FS format for this file // return the underlying FS format for this file
virtual DiskImg::FSFormat GetFSFormat(void) const { virtual DiskImg::FSFormat GetFSFormat(void) const {
@ -43,6 +48,10 @@ public:
void SetA2File(A2File* pFile) { fpFile = pFile; } void SetA2File(A2File* pFile) { fpFile = pFile; }
private: private:
/*
* Copy data from the open A2File to outfp, possibly converting EOL along
* the way.
*/
DIError CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv, DIError CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pMsg) const; ConvertHighASCII convHA, CString* pMsg) const;
@ -96,69 +105,145 @@ public:
} dos; } dos;
} NewOptions; } NewOptions;
// One-time initialization; returns an error string. /*
* Perform one-time initialization of the DiskLib library.
*/
static CString AppInit(void); static CString AppInit(void);
// one-time cleanup at app shutdown time
/*
* Perform one-time cleanup of DiskImgLib at shutdown time.
*/
static void AppCleanup(void); static void AppCleanup(void);
virtual OpenResult Open(const WCHAR* filename, bool readOnly, CString* pErrMsg); /*
virtual CString New(const WCHAR* filename, const void* options); * Finish instantiating a DiskArchive object by opening an existing file.
virtual CString Flush(void); */
virtual CString Reload(void); virtual OpenResult Open(const WCHAR* filename, bool readOnly,
virtual bool IsReadOnly(void) const { return fIsReadOnly; }; CString* pErrMsg) override;
virtual bool IsModified(void) const;
virtual void GetDescription(CString* pStr) const; /*
* Finish instantiating a DiskArchive object by creating a new archive.
*
* Returns an error string on failure, or "" on success.
*/
virtual CString New(const WCHAR* filename, const void* options) override;
/*
* Flush the DiskArchive object.
*
* Most of the stuff we do with disk images goes straight through, but in
* the case of compressed disks we don't normally re-compress them until
* it's time to close them. This forces us to update the copy on disk.
*
* Returns an empty string on success, or an error message on failure.
*/
virtual CString Flush(void) override;
/*
* Reload the stuff from the underlying DiskFS.
*
* This also does a "lite" flush of the disk data. For files that are
* essentially being written as we go, this does little more than clear
* the "dirty" flag. Files that need to be recompressed or have some
* other slow operation remain dirty.
*
* We don't need to do the flush as part of the reload -- we can load the
* contents with everything in a perfectly dirty state. We don't need to
* do it at all. We do it to keep the "dirty" flag clear when nothing is
* really dirty, and we do it here because almost all of our functions call
* "reload" after making changes, which makes it convenient to call from here.
*/
virtual CString Reload(void) override;
/*
* Returns true if the archive has un-flushed modifications pending.
*/
virtual bool IsModified(void) const override;
/*
* Return an description of the disk archive, suitable for display in the
* main title bar.
*/
virtual void GetDescription(CString* pStr) const override;
virtual bool BulkAdd(ActionProgressDialog* pActionProgress, virtual bool BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts); const AddFilesDialog* pAddOpts) override;
virtual bool AddDisk(ActionProgressDialog* pActionProgress, virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry, virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName); const WCHAR* newName) override;
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet); virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet); virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual CString TestPathName(const GenericEntry* pGenericEntry, virtual CString TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const; const CString& basePath, const CString& newName,
char newFssep) const override;
virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS, virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName); const WCHAR* newName) override;
virtual CString TestVolumeName(const DiskFS* pDiskFS, virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const; const WCHAR* newName) const override;
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts) const RecompressOptionsDialog* pRecompOpts) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry, virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr) CString* pStr) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str) const CString& str) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps); const FileProps* pProps) override;
virtual void PreferencesChanged(void);
virtual long GetCapability(Capability cap);
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts);
/*
* User has updated their preferences. Take note.
*
* Setting preferences in a DiskFS causes those prefs to be pushed down
* to all sub-volumes.
*/
virtual void PreferencesChanged(void) override;
virtual long GetCapability(Capability cap) override;
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress,
const XferFileOptions* pXferOpts) override;
virtual bool IsReadOnly(void) const { return fIsReadOnly; }
const DiskImg* GetDiskImg(void) const { return &fDiskImg; } const DiskImg* GetDiskImg(void) const { return &fDiskImg; }
DiskFS* GetDiskFS(void) const { return fpPrimaryDiskFS; } DiskFS* GetDiskFS(void) const { return fpPrimaryDiskFS; }
/* internal function, used by DiskArchive and DiskEntry */ /*
* Progress update callback, called from DiskImgLib during read/write
* operations.
*
* Returns "true" if we should continue;
*/
static bool ProgressCallback(DiskImgLib::A2FileDescr* pFile, static bool ProgressCallback(DiskImgLib::A2FileDescr* pFile,
DiskImgLib::di_off_t max, DiskImgLib::di_off_t current, void* state); DiskImgLib::di_off_t max, DiskImgLib::di_off_t current, void* state);
private: private:
/*
* Close the DiskArchive ojbect.
*/
virtual CString Close(void); virtual CString Close(void);
virtual void XferPrepare(const XferFileOptions* pXferOpts);
virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen);
virtual void XferAbort(CWnd* pMsgWnd);
virtual void XferFinish(CWnd* pMsgWnd);
/* DiskImg callback, used during initial scan of volume */ virtual void XferPrepare(const XferFileOptions* pXferOpts) override;
virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen) override;
virtual void XferAbort(CWnd* pMsgWnd) override;
virtual void XferFinish(CWnd* pMsgWnd) override;
/*
* Progress update callback, called from DiskImgLib while scanning a volume
* during Open().
*
* "str" must not contain a '%'. (TODO: fix that)
*
* Returns "true" if we should continue.
*/
static bool ScanProgressCallback(void* cookie, const char* str, static bool ScanProgressCallback(void* cookie, const char* str,
int count); int count);
@ -206,32 +291,123 @@ private:
FileAddData* fpNext; FileAddData* fpNext;
}; };
virtual ArchiveKind GetArchiveKind(void) { return kArchiveDiskImage; } virtual ArchiveKind GetArchiveKind(void) override { return kArchiveDiskImage; }
virtual NuError DoAddFile(const AddFilesDialog* pAddOpts, virtual NuError DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails); FileDetails* pDetails) override;
/*
* Reload the contents of the archive, showing an error message if the
* reload fails.
*
* Returns 0 on success, -1 on failure.
*/
int InternalReload(CWnd* pMsgWnd); int InternalReload(CWnd* pMsgWnd);
/*
* Compare DiskEntry display names in descending order (Z-A).
*/
static int CompareDisplayNamesDesc(const void* ventry1, const void* ventry2); static int CompareDisplayNamesDesc(const void* ventry1, const void* ventry2);
/*
* Load the contents of a "disk archive". Returns 0 on success.
*/
int LoadContents(void); int LoadContents(void);
/*
* Load the contents of a DiskFS.
*
* Recursively handle sub-volumes. "volName" holds the name of the
* sub-volume as it should appear in the list.
*/
int LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName); int LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName);
void DowncaseSubstring(CString* pStr, int startPos, int endPos, void DowncaseSubstring(CString* pStr, int startPos, int endPos,
bool prevWasSpace); bool prevWasSpace);
/*
* Handle a debug message from the DiskImg library.
*/
static void DebugMsgHandler(const char* file, int line, const char* msg); static void DebugMsgHandler(const char* file, int line, const char* msg);
/*
* A file we're adding clashes with an existing file. Decide what to do
* about it.
*
* Returns one of the following:
* kNuOverwrite - overwrite the existing file
* kNuSkip - skip adding the existing file
* kNuRename - user wants to rename the file
* kNuAbort - cancel out of the entire add process
*
* Side effects:
* Sets fOverwriteExisting and fOverwriteNoAsk if a "to all" button is hit
* Replaces pDetails->storageName if the user elects to rename
*/
NuResult HandleReplaceExisting(const A2File* pExisting, NuResult HandleReplaceExisting(const A2File* pExisting,
FileDetails* pDetails); FileDetails* pDetails);
/*
* Process the list of pending file adds.
*
* This is where the rubber (finally!) meets the road.
*/
CString ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL); CString ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL);
/*
* Load a file into a buffer, possibly converting EOL markers and setting
* "high ASCII" along the way.
*
* Returns a pointer to a newly-allocated buffer (new[]) and the data length.
* If the file is empty, no buffer will be allocated.
*
* Returns an empty string on success, or an error message on failure.
*/
CString LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen, CString LoadFile(const WCHAR* pathName, uint8_t** pBuf, long* pLen,
GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const; GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const;
/*
* Add a file with the supplied data to the disk image.
*
* Forks that exist but are empty have a length of zero. Forks that don't
* exist have a length of -1.
*
* Called by XferFile and ProcessFileAddData.
*/
DIError AddForksToDisk(DiskFS* pDiskFS, const DiskFS::CreateParms* pParms, DIError AddForksToDisk(DiskFS* pDiskFS, const DiskFS::CreateParms* pParms,
const uint8_t* dataBuf, long dataLen, const uint8_t* dataBuf, long dataLen,
const uint8_t* rsrcBuf, long rsrcLen) const; const uint8_t* rsrcBuf, long rsrcLen) const;
/*
* Add an entry to the end of the FileAddData list.
*
* If "storageName" (the Windows filename with type goodies stripped, but
* without filesystem normalization) matches an entry already in the list,
* we check to see if these are forks of the same file. If they are
* different forks and we don't already have both forks, we put the
* pointer into the "fork pointer" of the existing file rather than adding
* it to the end of the list.
*/
void AddToAddDataList(FileAddData* pData); void AddToAddDataList(FileAddData* pData);
/*
* Free all entries in the FileAddData list.
*/
void FreeAddDataList(void); void FreeAddDataList(void);
/*
* Fill out a CreateParms structure from a FileDetails structure.
*
* The NuStorageType values correspond exactly to ProDOS storage types, so
* there's no need to convert them.
*/
void ConvertFDToCP(const FileDetails* pDetails, void ConvertFDToCP(const FileDetails* pDetails,
DiskFS::CreateParms* pCreateParms); DiskFS::CreateParms* pCreateParms);
/*
* Set up a RenameEntryDialog for the entry in "*pEntry".
*
* Returns true on success, false on failure.
*/
bool SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry, bool SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
RenameEntryDialog* pDialog); RenameEntryDialog* pDialog);

View File

@ -19,11 +19,7 @@ BEGIN_MESSAGE_MAP(DiskConvertDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* void DiskConvertDialog::Init(const DiskImg* pDiskImg)
* Initialize the set of available options based on the source image.
*/
void
DiskConvertDialog::Init(const DiskImg* pDiskImg)
{ {
ASSERT(pDiskImg != NULL); ASSERT(pDiskImg != NULL);
const int kMagicNibbles = -1234; const int kMagicNibbles = -1234;
@ -129,11 +125,7 @@ DiskConvertDialog::Init(const DiskImg* pDiskImg)
} }
} }
/* void DiskConvertDialog::Init(int fileCount)
* Initialize options for a bulk transfer.
*/
void
DiskConvertDialog::Init(int fileCount)
{ {
/* allow everything */ /* allow everything */
fAllowUnadornedDOS = fAllowUnadornedProDOS = fAllowProDOS2MG = fAllowUnadornedDOS = fAllowUnadornedProDOS = fAllowProDOS2MG =
@ -144,12 +136,7 @@ DiskConvertDialog::Init(int fileCount)
fDiskDescription.Format(L"%d images selected", fBulkFileCount); fDiskDescription.Format(L"%d images selected", fBulkFileCount);
} }
BOOL DiskConvertDialog::OnInitDialog(void)
/*
* Disable unavailable options.
*/
BOOL
DiskConvertDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
@ -227,11 +214,7 @@ DiskConvertDialog::OnInitDialog(void)
return TRUE; return TRUE;
} }
/* void DiskConvertDialog::DoDataExchange(CDataExchange* pDX)
* Convert options in and out.
*/
void
DiskConvertDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_Check(pDX, IDC_DISKCONV_GZIP, fAddGzip); DDX_Check(pDX, IDC_DISKCONV_GZIP, fAddGzip);
DDX_Radio(pDX, IDC_DISKCONV_DOS, fConvertIdx); DDX_Radio(pDX, IDC_DISKCONV_DOS, fConvertIdx);
@ -264,15 +247,7 @@ DiskConvertDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
/* void DiskConvertDialog::OnChangeRadio(UINT nID)
* If the radio button selection changes, we may need to disable the gzip
* checkbox to show that NuFX can't be combined with gzip.
*
* If the underlying disk is over 32MB, disable gzip, because we won't be
* able to open the disk we create.
*/
void
DiskConvertDialog::OnChangeRadio(UINT nID)
{ {
CWnd* pGzip = GetDlgItem(IDC_DISKCONV_GZIP); CWnd* pGzip = GetDlgItem(IDC_DISKCONV_GZIP);
ASSERT(pGzip != NULL); ASSERT(pGzip != NULL);
@ -285,21 +260,13 @@ DiskConvertDialog::OnChangeRadio(UINT nID)
pGzip->EnableWindow(pNuFX->GetCheck() == BST_UNCHECKED); pGzip->EnableWindow(pNuFX->GetCheck() == BST_UNCHECKED);
} }
/* BOOL DiskConvertDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
DiskConvertDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void DiskConvertDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
DiskConvertDialog::OnHelp(void)
{ {
if (fBulkFileCount < 0) if (fBulkFileCount < 0)
WinHelp(HELP_TOPIC_DISK_CONV, HELP_CONTEXT); WinHelp(HELP_TOPIC_DISK_CONV, HELP_CONTEXT);

View File

@ -29,8 +29,15 @@ public:
} }
virtual ~DiskConvertDialog(void) {} virtual ~DiskConvertDialog(void) {}
void Init(const DiskImgLib::DiskImg* pDiskImg); // single file init /*
void Init(int fileCount); // bulk init * Initialize the set of available options based on the source image.
*/
void Init(const DiskImgLib::DiskImg* pDiskImg);
/*
* Initialize options for a bulk transfer.
*/
void Init(int fileCount);
/* must match up with dialog */ /* must match up with dialog */
enum { enum {
@ -55,13 +62,23 @@ public:
CString fExtension; CString fExtension;
private: private:
BOOL OnInitDialog(void); BOOL OnInitDialog(void) override;
void DoDataExchange(CDataExchange* pDX); void DoDataExchange(CDataExchange* pDX) override;
/*
* If the radio button selection changes, we may need to disable the gzip
* checkbox to show that NuFX can't be combined with gzip.
*
* If the underlying disk is over 32MB, disable gzip, because we won't be
* able to open the disk we create.
*/
afx_msg void OnChangeRadio(UINT nID); afx_msg void OnChangeRadio(UINT nID);
// User pressed the "Help" button.
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
BOOL OnHelpInfo(HELPINFO* lpHelpInfo); // Context help request (question mark button).
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
CString fDiskDescription; CString fDiskDescription;
bool fAllowUnadornedDOS; bool fAllowUnadornedDOS;

View File

@ -45,11 +45,7 @@ BEGIN_MESSAGE_MAP(DiskEditDialog, CDialog)
ON_WM_HELPINFO() ON_WM_HELPINFO()
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL DiskEditDialog::OnInitDialog(void)
* Initialize the controls.
*/
BOOL
DiskEditDialog::OnInitDialog(void)
{ {
ASSERT(!fFileName.IsEmpty()); ASSERT(!fFileName.IsEmpty());
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
@ -144,11 +140,7 @@ DiskEditDialog::OnInitDialog(void)
return TRUE; return TRUE;
} }
/* void DiskEditDialog::InitNibbleParmList(void)
* Initialize the nibble parm drop-list.
*/
void
DiskEditDialog::InitNibbleParmList(void)
{ {
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
DiskImg* pDiskImg = fpDiskFS->GetDiskImg(); DiskImg* pDiskImg = fpDiskFS->GetDiskImg();
@ -204,12 +196,7 @@ DiskEditDialog::InitNibbleParmList(void)
} }
} }
int DiskEditDialog::ReplaceSpinCtrl(MySpinCtrl* pNewSpin, int idSpin, int idEdit)
/*
* Replace a spin button with our improved version.
*/
int
DiskEditDialog::ReplaceSpinCtrl(MySpinCtrl* pNewSpin, int idSpin, int idEdit)
{ {
CSpinButtonCtrl* pSpin; CSpinButtonCtrl* pSpin;
// CRect rect; // CRect rect;
@ -231,11 +218,7 @@ DiskEditDialog::ReplaceSpinCtrl(MySpinCtrl* pNewSpin, int idSpin, int idEdit)
return 0; return 0;
} }
/* BOOL DiskEditDialog::PreTranslateMessage(MSG* pMsg)
* Special keypress handling.
*/
BOOL
DiskEditDialog::PreTranslateMessage(MSG* pMsg)
{ {
if (pMsg->message == WM_KEYDOWN && if (pMsg->message == WM_KEYDOWN &&
pMsg->wParam == VK_RETURN) pMsg->wParam == VK_RETURN)
@ -248,12 +231,7 @@ DiskEditDialog::PreTranslateMessage(MSG* pMsg)
return CDialog::PreTranslateMessage(pMsg); return CDialog::PreTranslateMessage(pMsg);
} }
/* BOOL DiskEditDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* F1 key hit, or '?' button in title bar used to select help for an
* item in the dialog.
*/
BOOL
DiskEditDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
LOGI("HELP: size=%d contextType=%d ctrlID=0x%x contextID=0x%08lx", LOGI("HELP: size=%d contextType=%d ctrlID=0x%x contextID=0x%08lx",
lpHelpInfo->cbSize, lpHelpInfo->iContextType, lpHelpInfo->iCtrlId, lpHelpInfo->cbSize, lpHelpInfo->iContextType, lpHelpInfo->iCtrlId,
@ -276,31 +254,18 @@ DiskEditDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
return TRUE; // indicate success?? return TRUE; // indicate success??
} }
/* void DiskEditDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
DiskEditDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_DISKEDIT, HELP_CONTEXT); WinHelp(HELP_TOPIC_DISKEDIT, HELP_CONTEXT);
} }
/* void DiskEditDialog::OnDone(void)
* Handle the "Done" button. We don't use IDOK because we don't want
* <return> to bail out of the dialog.
*/
void
DiskEditDialog::OnDone(void)
{ {
LOGI("DiskEditDialog OnDone"); LOGI("DiskEditDialog OnDone");
EndDialog(IDOK); EndDialog(IDOK);
} }
/* void DiskEditDialog::OnHexMode(void)
* Toggle the spin button / edit controls.
*/
void
DiskEditDialog::OnHexMode(void)
{ {
int base; int base;
@ -316,11 +281,7 @@ DiskEditDialog::OnHexMode(void)
SetSpinMode(IDC_DISKEDIT_SECTORSPIN, base); SetSpinMode(IDC_DISKEDIT_SECTORSPIN, base);
} }
/* void DiskEditDialog::OnSubVolume(void)
* Create a new instance of the disk edit dialog, for a sub-volume.
*/
void
DiskEditDialog::OnSubVolume(void)
{ {
SubVolumeDialog subv(this); SubVolumeDialog subv(this);
bool showAsBlocks; bool showAsBlocks;
@ -353,14 +314,7 @@ DiskEditDialog::OnSubVolume(void)
} }
} }
/* void DiskEditDialog::SetSpinMode(int id, int base)
* Change the mode of a spin button. The Windows control doesn't
* immediately update with a hex display, so we do it manually. (Our
* replacement class does this correctly, but I'm leaving the code alone
* for now.)
*/
void
DiskEditDialog::SetSpinMode(int id, int base)
{ {
CString valStr; CString valStr;
@ -389,14 +343,7 @@ DiskEditDialog::SetSpinMode(int id, int base)
LOGI("Set spin button base to %d val=%d", base, val); LOGI("Set spin button base to %d val=%d", base, val);
} }
/* int DiskEditDialog::ReadSpinner(int id, long* pVal)
* Read a value from a spin control.
*
* Returns 0 on success, -1 if the return value from the spin control was
* invalid. In the latter case, an error dialog will be displayed.
*/
int
DiskEditDialog::ReadSpinner(int id, long* pVal)
{ {
MySpinCtrl* pSpin = (MySpinCtrl*) GetDlgItem(id); MySpinCtrl* pSpin = (MySpinCtrl*) GetDlgItem(id);
ASSERT(pSpin != NULL); ASSERT(pSpin != NULL);
@ -419,11 +366,7 @@ DiskEditDialog::ReadSpinner(int id, long* pVal)
return 0; return 0;
} }
/* void DiskEditDialog::SetSpinner(int id, long val)
* Set the value of a spin control.
*/
void
DiskEditDialog::SetSpinner(int id, long val)
{ {
MySpinCtrl* pSpin = (MySpinCtrl*) GetDlgItem(id); MySpinCtrl* pSpin = (MySpinCtrl*) GetDlgItem(id);
ASSERT(pSpin != NULL); ASSERT(pSpin != NULL);
@ -436,11 +379,7 @@ DiskEditDialog::SetSpinner(int id, long val)
pSpin->SetPos(val); pSpin->SetPos(val);
} }
/* void DiskEditDialog::DisplayData(const uint8_t* srcBuf, int size)
* Convert a chunk of data into a hex dump, and stuff it into the edit control.
*/
void
DiskEditDialog::DisplayData(const uint8_t* srcBuf, int size)
{ {
WCHAR textBuf[80 * 16 * 2]; WCHAR textBuf[80 * 16 * 2];
WCHAR* cp; WCHAR* cp;
@ -517,11 +456,7 @@ DiskEditDialog::DisplayData(const uint8_t* srcBuf, int size)
pEdit->SetWindowText(textBuf); pEdit->SetWindowText(textBuf);
} }
/* void DiskEditDialog::DisplayNibbleData(const unsigned char* srcBuf, int size)
* Display a track full of nibble data.
*/
void
DiskEditDialog::DisplayNibbleData(const unsigned char* srcBuf, int size)
{ {
ASSERT(srcBuf != NULL); ASSERT(srcBuf != NULL);
ASSERT(size > 0); ASSERT(size > 0);
@ -595,17 +530,8 @@ DiskEditDialog::DisplayNibbleData(const unsigned char* srcBuf, int size)
delete[] textBuf; delete[] textBuf;
} }
DIError DiskEditDialog::OpenFile(const WCHAR* fileName, bool openRsrc,
/* A2File** ppFile, A2FileDescr** ppOpenFile)
* Open a file in a disk image.
*
* Returns a pointer to the A2File and A2FileDescr structures on success, NULL
* on failure. The pointer placed in "ppOpenFile" must be freed by invoking
* its Close function.
*/
DIError
DiskEditDialog::OpenFile(const WCHAR* fileName, bool openRsrc, A2File** ppFile,
A2FileDescr** ppOpenFile)
{ {
A2File* pFile; A2File* pFile;
A2FileDescr* pOpenFile = NULL; A2FileDescr* pOpenFile = NULL;
@ -640,14 +566,7 @@ DiskEditDialog::OpenFile(const WCHAR* fileName, bool openRsrc, A2File** ppFile,
return kDIErrNone; return kDIErrNone;
} }
void DiskEditDialog::OnNibbleParms(void)
/*
* Change the nibble parms.
*
* Assumes the parm list is linear and unbroken.
*/
void
DiskEditDialog::OnNibbleParms(void)
{ {
DiskImg* pDiskImg = fpDiskFS->GetDiskImg(); DiskImg* pDiskImg = fpDiskFS->GetDiskImg();
CComboBox* pCombo; CComboBox* pCombo;
@ -703,11 +622,7 @@ DiskEditDialog::FillWithPattern(unsigned char* buf, int size,
* =========================================================================== * ===========================================================================
*/ */
/* BOOL SectorEditDialog::OnInitDialog(void)
* Prep the dialog.
*/
BOOL
SectorEditDialog::OnInitDialog(void)
{ {
/* /*
* Do base-class construction. * Do base-class construction.
@ -747,13 +662,7 @@ SectorEditDialog::OnInitDialog(void)
return TRUE; return TRUE;
} }
/* int SectorEditDialog::LoadData(void)
* Load the current track/sector data into the edit control.
*
* Returns 0 on success, -1 on error.
*/
int
SectorEditDialog::LoadData(void)
{ {
//LOGI("SED LoadData"); //LOGI("SED LoadData");
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
@ -785,29 +694,17 @@ SectorEditDialog::LoadData(void)
return 0; return 0;
} }
/* void SectorEditDialog::OnDoRead(void)
* Read the currently specified track/sector.
*/
void
SectorEditDialog::OnDoRead(void)
{ {
LoadData(); LoadData();
} }
/* void SectorEditDialog::OnDoWrite(void)
* Write the currently loaded track/sector.
*/
void
SectorEditDialog::OnDoWrite(void)
{ {
MessageBox(L"Write!"); MessageBox(L"Write!");
} }
/* void SectorEditDialog::OnReadPrev(void)
* Back up to the previous track/sector.
*/
void
SectorEditDialog::OnReadPrev(void)
{ {
if (fTrack == 0 && fSector == 0) if (fTrack == 0 && fSector == 0)
return; return;
@ -825,11 +722,7 @@ SectorEditDialog::OnReadPrev(void)
LoadData(); LoadData();
} }
/* void SectorEditDialog::OnReadNext(void)
* Same as OnReadPrev, but moving forward.
*/
void
SectorEditDialog::OnReadNext(void)
{ {
int numTracks = fpDiskFS->GetDiskImg()->GetNumTracks(); int numTracks = fpDiskFS->GetDiskImg()->GetNumTracks();
int numSects = fpDiskFS->GetDiskImg()->GetNumSectPerTrack(); int numSects = fpDiskFS->GetDiskImg()->GetNumSectPerTrack();
@ -850,13 +743,7 @@ SectorEditDialog::OnReadNext(void)
LoadData(); LoadData();
} }
void SectorEditDialog::OnOpenFile(void)
/*
* Open a file on the disk image. If successful, open a new edit dialog
* that's in "file follow" mode.
*/
void
SectorEditDialog::OnOpenFile(void)
{ {
DEFileDialog fileDialog(this); DEFileDialog fileDialog(this);
@ -887,11 +774,7 @@ SectorEditDialog::OnOpenFile(void)
* =========================================================================== * ===========================================================================
*/ */
/* BOOL SectorFileEditDialog::OnInitDialog(void)
* Minor changes for file editing.
*/
BOOL
SectorFileEditDialog::OnInitDialog(void)
{ {
BOOL retval; BOOL retval;
@ -933,13 +816,7 @@ SectorFileEditDialog::OnInitDialog(void)
return retval; return retval;
} }
/* int SectorFileEditDialog::LoadData(void)
* Load data from the current offset into the edit control.
*
* Returns 0 on success, -1 on error.
*/
int
SectorFileEditDialog::LoadData(void)
{ {
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
ASSERT(fpDiskFS->GetDiskImg() != NULL); ASSERT(fpDiskFS->GetDiskImg() != NULL);
@ -1037,11 +914,7 @@ SectorFileEditDialog::LoadData(void)
return 0; return 0;
} }
/* void SectorFileEditDialog::OnReadPrev(void)
* Move to the previous sector in the file.
*/
void
SectorFileEditDialog::OnReadPrev(void)
{ {
if (fSectorIdx == 0) if (fSectorIdx == 0)
return; return;
@ -1051,11 +924,7 @@ SectorFileEditDialog::OnReadPrev(void)
LoadData(); LoadData();
} }
/* void SectorFileEditDialog::OnReadNext(void)
* Move to the next sector in the file.
*/
void
SectorFileEditDialog::OnReadNext(void)
{ {
if (fSectorIdx+1 >= fpOpenFile->GetSectorCount()) if (fSectorIdx+1 >= fpOpenFile->GetSectorCount())
return; return;
@ -1076,8 +945,7 @@ SectorFileEditDialog::OnReadNext(void)
* Rearrange the DiskEdit dialog (which defaults to SectorEdit mode) to * Rearrange the DiskEdit dialog (which defaults to SectorEdit mode) to
* accommodate block editing. * accommodate block editing.
*/ */
BOOL BOOL BlockEditDialog::OnInitDialog(void)
BlockEditDialog::OnInitDialog(void)
{ {
/* /*
* Get rid of the "sector" input item, and change the "track" input * Get rid of the "sector" input item, and change the "track" input
@ -1173,11 +1041,7 @@ BlockEditDialog::MoveControl(int id, int deltaX, int deltaY)
#endif #endif
/* int BlockEditDialog::LoadData(void)
* Load the current block data into the edit control.
*/
int
BlockEditDialog::LoadData(void)
{ {
//LOGI("BED LoadData"); //LOGI("BED LoadData");
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
@ -1207,30 +1071,17 @@ BlockEditDialog::LoadData(void)
return 0; return 0;
} }
/* void BlockEditDialog::OnDoRead(void)
* Read the currently specified track/sector.
*/
void
BlockEditDialog::OnDoRead(void)
{ {
LoadData(); LoadData();
} }
/* void BlockEditDialog::OnDoWrite(void)
* Write the currently loaded track/sector.
*/
void
BlockEditDialog::OnDoWrite(void)
{ {
MessageBox(L"Write!"); MessageBox(L"Write!");
} }
/* void BlockEditDialog::OnReadPrev(void)
* Back up to the previous track/sector, or (in follow-file mode) to the
* previous sector in the file.
*/
void
BlockEditDialog::OnReadPrev(void)
{ {
if (fBlock == 0) if (fBlock == 0)
return; return;
@ -1240,9 +1091,6 @@ BlockEditDialog::OnReadPrev(void)
LoadData(); LoadData();
} }
/*
* Same as OnReadPrev, but moving forward.
*/
void void
BlockEditDialog::OnReadNext(void) BlockEditDialog::OnReadNext(void)
{ {
@ -1255,12 +1103,7 @@ BlockEditDialog::OnReadNext(void)
LoadData(); LoadData();
} }
/* void BlockEditDialog::OnOpenFile(void)
* Open a file on the disk image. If successful, open a new edit dialog
* that's in "file follow" mode.
*/
void
BlockEditDialog::OnOpenFile(void)
{ {
DEFileDialog fileDialog(this); DEFileDialog fileDialog(this);
@ -1291,11 +1134,7 @@ BlockEditDialog::OnOpenFile(void)
* =========================================================================== * ===========================================================================
*/ */
/* BOOL BlockFileEditDialog::OnInitDialog(void)
* Minor changes for file editing.
*/
BOOL
BlockFileEditDialog::OnInitDialog(void)
{ {
BOOL retval; BOOL retval;
@ -1331,13 +1170,7 @@ BlockFileEditDialog::OnInitDialog(void)
return retval; return retval;
} }
/* int BlockFileEditDialog::LoadData(void)
* Load data from the current offset into the edit control.
*
* Returns 0 on success, -1 on error.
*/
int
BlockFileEditDialog::LoadData(void)
{ {
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
ASSERT(fpDiskFS->GetDiskImg() != NULL); ASSERT(fpDiskFS->GetDiskImg() != NULL);
@ -1432,11 +1265,7 @@ BlockFileEditDialog::LoadData(void)
return 0; return 0;
} }
/* void BlockFileEditDialog::OnReadPrev(void)
* Move to the previous Block in the file.
*/
void
BlockFileEditDialog::OnReadPrev(void)
{ {
if (fBlockIdx == 0) if (fBlockIdx == 0)
return; return;
@ -1446,11 +1275,7 @@ BlockFileEditDialog::OnReadPrev(void)
LoadData(); LoadData();
} }
/* void BlockFileEditDialog::OnReadNext(void)
* Move to the next Block in the file.
*/
void
BlockFileEditDialog::OnReadNext(void)
{ {
if (fBlockIdx+1 >= fpOpenFile->GetBlockCount()) if (fBlockIdx+1 >= fpOpenFile->GetBlockCount())
return; return;
@ -1467,12 +1292,7 @@ BlockFileEditDialog::OnReadNext(void)
* =========================================================================== * ===========================================================================
*/ */
/* BOOL NibbleEditDialog::OnInitDialog(void)
* Rearrange the DiskEdit dialog (which defaults to SectorEdit mode) to
* accommodate nibble editing.
*/
BOOL
NibbleEditDialog::OnInitDialog(void)
{ {
/* /*
* Get rid of the "sector" input item. * Get rid of the "sector" input item.
@ -1566,11 +1386,7 @@ NibbleEditDialog::OnInitDialog(void)
return TRUE; return TRUE;
} }
/* int NibbleEditDialog::LoadData(void)
* Load the current track data into the edit control.
*/
int
NibbleEditDialog::LoadData(void)
{ {
//LOGI("BED LoadData"); //LOGI("BED LoadData");
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
@ -1595,30 +1411,17 @@ NibbleEditDialog::LoadData(void)
return 0; return 0;
} }
/* void NibbleEditDialog::OnDoRead(void)
* Read the currently specified track/sector.
*/
void
NibbleEditDialog::OnDoRead(void)
{ {
LoadData(); LoadData();
} }
/* void NibbleEditDialog::OnDoWrite(void)
* Write the currently loaded track/sector.
*/
void
NibbleEditDialog::OnDoWrite(void)
{ {
MessageBox(L"Write!"); MessageBox(L"Write!");
} }
/* void NibbleEditDialog::OnReadPrev(void)
* Back up to the previous track/sector, or (in follow-file mode) to the
* previous sector in the file.
*/
void
NibbleEditDialog::OnReadPrev(void)
{ {
if (fTrack == 0) if (fTrack == 0)
return; return;
@ -1628,11 +1431,7 @@ NibbleEditDialog::OnReadPrev(void)
LoadData(); LoadData();
} }
/* void NibbleEditDialog::OnReadNext(void)
* Same as OnReadPrev, but moving forward.
*/
void
NibbleEditDialog::OnReadNext(void)
{ {
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
if (fTrack == fpDiskFS->GetDiskImg()->GetNumTracks() - 1) if (fTrack == fpDiskFS->GetDiskImg()->GetNumTracks() - 1)

View File

@ -49,7 +49,15 @@ public:
virtual int LoadData(void) = 0; virtual int LoadData(void) = 0;
virtual void DisplayData(void) = 0; virtual void DisplayData(void) = 0;
/*
* Convert a chunk of data into a hex dump, and stuff it into the edit control.
*/
virtual void DisplayData(const uint8_t* buf, int size); virtual void DisplayData(const uint8_t* buf, int size);
/*
* Display a track full of nibble data.
*/
virtual void DisplayNibbleData(const uint8_t* srcBuf, int size); virtual void DisplayNibbleData(const uint8_t* srcBuf, int size);
bool GetReadOnly(void) const { return fReadOnly; } bool GetReadOnly(void) const { return fReadOnly; }
@ -72,28 +80,72 @@ protected:
return ch & 0x7f; return ch & 0x7f;
} }
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void);
afx_msg virtual BOOL OnHelpInfo(HELPINFO* lpHelpInfo); // catch <return> key
virtual BOOL PreTranslateMessage(MSG* pMsg) override;
/*
* Handle the "Done" button. We don't use IDOK because we don't want
* <return> to bail out of the dialog.
*/
afx_msg virtual void OnDone(void); afx_msg virtual void OnDone(void);
/*
* Toggle the spin button / edit controls.
*/
afx_msg virtual void OnHexMode(void); afx_msg virtual void OnHexMode(void);
afx_msg virtual void OnDoRead(void) = 0; afx_msg virtual void OnDoRead(void) = 0;
afx_msg virtual void OnDoWrite(void) = 0; afx_msg virtual void OnDoWrite(void) = 0;
afx_msg virtual void OnReadPrev(void) = 0; afx_msg virtual void OnReadPrev(void) = 0;
afx_msg virtual void OnReadNext(void) = 0; afx_msg virtual void OnReadNext(void) = 0;
/*
* Create a new instance of the disk edit dialog, for a sub-volume.
*/
afx_msg virtual void OnSubVolume(void); afx_msg virtual void OnSubVolume(void);
afx_msg virtual void OnOpenFile(void) = 0; afx_msg virtual void OnOpenFile(void) = 0;
/*
* Change the nibble parms.
*
* Assumes the parm list is linear and unbroken.
*/
afx_msg virtual void OnNibbleParms(void); afx_msg virtual void OnNibbleParms(void);
afx_msg virtual void OnHelp(void); afx_msg virtual void OnHelp(void);
afx_msg virtual BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
virtual BOOL PreTranslateMessage(MSG* pMsg); /*
* Change the mode of a spin button. The Windows control doesn't
* immediately update with a hex display, so we do it manually. (Our
* replacement class does this correctly, but I'm leaving the code alone
* for now.)
*/
void SetSpinMode(int id, int base); void SetSpinMode(int id, int base);
/*
* Read a value from a spin control.
*
* Returns 0 on success, -1 if the return value from the spin control was
* invalid. In the latter case, an error dialog will be displayed.
*/
int ReadSpinner(int id, long* pVal); int ReadSpinner(int id, long* pVal);
/*
* Set the value of a spin control.
*/
void SetSpinner(int id, long val); void SetSpinner(int id, long val);
//void FillWithPattern(unsigned char* buf, int size, const char* pattern); /*
* Open a file in a disk image.
*
* Returns a pointer to the A2File and A2FileDescr structures on success, NULL
* on failure. The pointer placed in "ppOpenFile" must be freed by invoking
* its Close function.
*/
DIError OpenFile(const WCHAR* fileName, bool openRsrc, A2File** ppFile, DIError OpenFile(const WCHAR* fileName, bool openRsrc, A2File** ppFile,
A2FileDescr** ppOpenFile); A2FileDescr** ppOpenFile);
@ -104,8 +156,16 @@ protected:
int fPositionShift; int fPositionShift;
private: private:
/*
* Initialize the nibble parm drop-list.
*/
void InitNibbleParmList(void); void InitNibbleParmList(void);
/*
* Replace a spin button with our improved version.
*/
int ReplaceSpinCtrl(MySpinCtrl* pNewSpin, int idSpin, int idEdit); int ReplaceSpinCtrl(MySpinCtrl* pNewSpin, int idSpin, int idEdit);
MySpinCtrl fTrackSpinner; MySpinCtrl fTrackSpinner;
MySpinCtrl fSectorSpinner; MySpinCtrl fSectorSpinner;
bool fFirstResize; bool fFirstResize;
@ -129,22 +189,34 @@ public:
} }
virtual ~SectorEditDialog() {} virtual ~SectorEditDialog() {}
virtual int LoadData(void); // load the current track/sector virtual int LoadData(void) override; // load the current track/sector
virtual void DisplayData(void) { virtual void DisplayData(void) override {
DiskEditDialog::DisplayData(fSectorData, kSectorSize); DiskEditDialog::DisplayData(fSectorData, kSectorSize);
} }
//void SetTrack(int val) { fTrack = val; } //void SetTrack(int val) { fTrack = val; }
//void SetSector(int val) { fSector = val; } //void SetSector(int val) { fSector = val; }
// overrides
virtual BOOL OnInitDialog(void);
protected: protected:
virtual BOOL OnInitDialog(void) override;
afx_msg virtual void OnDoRead(void); afx_msg virtual void OnDoRead(void);
afx_msg virtual void OnDoWrite(void); afx_msg virtual void OnDoWrite(void);
/*
* Back up to the previous track/sector.
*/
afx_msg virtual void OnReadPrev(void); afx_msg virtual void OnReadPrev(void);
/*
* Advance to the next track/sector.
*/
afx_msg virtual void OnReadNext(void); afx_msg virtual void OnReadNext(void);
/*
* Open a file on the disk image. If successful, open a new edit dialog
* that's in "file follow" mode.
*/
afx_msg virtual void OnOpenFile(void); afx_msg virtual void OnOpenFile(void);
long fTrack; long fTrack;
@ -211,21 +283,32 @@ public:
} }
virtual ~BlockEditDialog() {} virtual ~BlockEditDialog() {}
virtual int LoadData(void); // load the current block virtual int LoadData(void) override; // load the current block
virtual void DisplayData(void) { virtual void DisplayData(void) override {
DiskEditDialog::DisplayData(fBlockData, kBlockSize); DiskEditDialog::DisplayData(fBlockData, kBlockSize);
} }
// overrides
virtual BOOL OnInitDialog(void);
protected: protected:
//void MoveControl(int id, int deltaX, int deltaY); virtual BOOL OnInitDialog(void) override;
afx_msg virtual void OnDoRead(void); afx_msg virtual void OnDoRead(void);
afx_msg virtual void OnDoWrite(void); afx_msg virtual void OnDoWrite(void);
/*
* Back up to the previous track/sector, or (in follow-file mode) to the
* previous sector in the file.
*/
afx_msg virtual void OnReadPrev(void); afx_msg virtual void OnReadPrev(void);
/*
* Same as OnReadPrev, but moving forward.
*/
afx_msg virtual void OnReadNext(void); afx_msg virtual void OnReadNext(void);
/*
* Open a file on the disk image. If successful, open a new edit dialog
* that's in "file follow" mode.
*/
afx_msg virtual void OnOpenFile(void); afx_msg virtual void OnOpenFile(void);
long fBlock; long fBlock;
@ -266,7 +349,14 @@ private:
// overrides // overrides
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void);
/*
* Move to the previous Block in the file.
*/
afx_msg virtual void OnReadPrev(void); afx_msg virtual void OnReadPrev(void);
/*
* Move to the next Block in the file.
*/
afx_msg virtual void OnReadNext(void); afx_msg virtual void OnReadNext(void);
CString fOpenFileName; CString fOpenFileName;
@ -291,15 +381,18 @@ public:
} }
virtual ~NibbleEditDialog() {} virtual ~NibbleEditDialog() {}
virtual int LoadData(void); // load the current track/sector virtual int LoadData(void) override; // load the current track/sector
virtual void DisplayData(void) { virtual void DisplayData(void) override {
DiskEditDialog::DisplayNibbleData(fNibbleData, fNibbleDataLen); DiskEditDialog::DisplayNibbleData(fNibbleData, fNibbleDataLen);
} }
// overrides
virtual BOOL OnInitDialog(void);
protected: protected:
/*
* Rearrange the DiskEdit dialog (which defaults to SectorEdit mode) to
* accommodate nibble editing.
*/
virtual BOOL OnInitDialog(void) override;
afx_msg virtual void OnDoRead(void); afx_msg virtual void OnDoRead(void);
afx_msg virtual void OnDoWrite(void); afx_msg virtual void OnDoWrite(void);
afx_msg virtual void OnReadPrev(void); afx_msg virtual void OnReadPrev(void);

View File

@ -16,8 +16,7 @@ BEGIN_MESSAGE_MAP(DiskEditOpenDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
BOOL BOOL DiskEditOpenDialog::OnInitDialog(void)
DiskEditOpenDialog::OnInitDialog(void)
{ {
if (!fArchiveOpen) { if (!fArchiveOpen) {
CButton* pButton = (CButton*) GetDlgItem(IDC_DEOW_CURRENT); CButton* pButton = (CButton*) GetDlgItem(IDC_DEOW_CURRENT);
@ -28,25 +27,19 @@ DiskEditOpenDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* user clicked "open file" button */ void DiskEditOpenDialog::OnButtonFile(void)
void
DiskEditOpenDialog::OnButtonFile(void)
{ {
fOpenWhat = kOpenFile; fOpenWhat = kOpenFile;
OnOK(); OnOK();
} }
/* user clicked "open volume" button */ void DiskEditOpenDialog::OnButtonVolume(void)
void
DiskEditOpenDialog::OnButtonVolume(void)
{ {
fOpenWhat = kOpenVolume; fOpenWhat = kOpenVolume;
OnOK(); OnOK();
} }
/* user clicked "open current" button */ void DiskEditOpenDialog::OnButtonCurrent(void)
void
DiskEditOpenDialog::OnButtonCurrent(void)
{ {
fOpenWhat = kOpenCurrent; fOpenWhat = kOpenCurrent;
OnOK(); OnOK();

View File

@ -37,7 +37,7 @@ public:
OpenWhat fOpenWhat; OpenWhat fOpenWhat;
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
afx_msg void OnButtonFile(void); afx_msg void OnButtonFile(void);
afx_msg void OnButtonVolume(void); afx_msg void OnButtonVolume(void);

View File

@ -12,11 +12,7 @@
using namespace DiskImgLib; using namespace DiskImgLib;
/* bool DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree)
* Build the tree.
*/
bool
DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree)
{ {
ASSERT(pDiskFS != NULL); ASSERT(pDiskFS != NULL);
ASSERT(pTree != NULL); ASSERT(pTree != NULL);
@ -25,16 +21,7 @@ DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree)
return AddDiskFS(pTree, TVI_ROOT, pDiskFS, 1); return AddDiskFS(pTree, TVI_ROOT, pDiskFS, 1);
} }
/* bool DiskFSTree::AddDiskFS(CTreeCtrl* pTree, HTREEITEM parent,
* Load the specified DiskFS into the tree, recursively adding any
* sub-volumes.
*
* Pass in an initial depth of 1.
*
* Returns "true" on success, "false" on failure.
*/
bool
DiskFSTree::AddDiskFS(CTreeCtrl* pTree, HTREEITEM parent,
DiskImgLib::DiskFS* pDiskFS, int depth) DiskImgLib::DiskFS* pDiskFS, int depth)
{ {
const DiskFS::SubVolume* pSubVol; const DiskFS::SubVolume* pSubVol;
@ -116,21 +103,7 @@ DiskFSTree::AddDiskFS(CTreeCtrl* pTree, HTREEITEM parent,
return true; return true;
} }
DiskImgLib::A2File* DiskFSTree::AddSubdir(CTreeCtrl* pTree, HTREEITEM parent,
/*
* Add the subdir and all of the subdirectories of the current subdir.
*
* The files are held in a linear list in the DiskFS, so we have to
* reconstruct the hierarchy from the path names. Pass in NULL for the
* root volume.
*
* Returns a pointer to the next A2File in the list (i.e. the first one
* that we couldn't digest). This assumes that the contents of a
* subdirectory are grouped together in the linear list, so that we can
* immediately bail when the first misfit is encountered.
*/
DiskImgLib::A2File*
DiskFSTree::AddSubdir(CTreeCtrl* pTree, HTREEITEM parent,
DiskImgLib::DiskFS* pDiskFS, DiskImgLib::A2File* pParentFile, DiskImgLib::DiskFS* pDiskFS, DiskImgLib::A2File* pParentFile,
int depth) int depth)
{ {
@ -212,12 +185,7 @@ DiskFSTree::AddSubdir(CTreeCtrl* pTree, HTREEITEM parent,
return pFile; return pFile;
} }
DiskFSTree::TargetData* DiskFSTree::AllocTargetData(void)
/*
* Allocate a new TargetData struct, and add it to our list.
*/
DiskFSTree::TargetData*
DiskFSTree::AllocTargetData(void)
{ {
TargetData* pNew = new TargetData; TargetData* pNew = new TargetData;
@ -232,13 +200,7 @@ DiskFSTree::AllocTargetData(void)
return pNew; return pNew;
} }
/* void DiskFSTree::FreeAllTargetData(void)
* Free up the TargetData structures we created.
*
* Rather than
*/
void
DiskFSTree::FreeAllTargetData(void)
{ {
TargetData* pTarget; TargetData* pTarget;
TargetData* pNext; TargetData* pNext;

View File

@ -52,13 +52,40 @@ public:
struct TargetData* pNext; struct TargetData* pNext;
} TargetData; } TargetData;
private: private:
/*
* Load the specified DiskFS into the tree, recursively adding any
* sub-volumes. Pass in an initial depth of 1.
*
* Returns true on success.
*/
bool AddDiskFS(CTreeCtrl* pTree, HTREEITEM root, bool AddDiskFS(CTreeCtrl* pTree, HTREEITEM root,
DiskImgLib::DiskFS* pDiskFS, int depth); DiskImgLib::DiskFS* pDiskFS, int depth);
/*
* Add the subdir and all of the subdirectories of the current subdir.
*
* The files are held in a linear list in the DiskFS, so we have to
* reconstruct the hierarchy from the path names. Pass in NULL for the
* root volume.
*
* Returns a pointer to the next A2File in the list (i.e. the first one
* that we couldn't digest). This assumes that the contents of a
* subdirectory are grouped together in the linear list, so that we can
* immediately bail when the first misfit is encountered.
*/
DiskImgLib::A2File* AddSubdir(CTreeCtrl* pTree, HTREEITEM parent, DiskImgLib::A2File* AddSubdir(CTreeCtrl* pTree, HTREEITEM parent,
DiskImgLib::DiskFS* pDiskFS, DiskImgLib::A2File* pFile, DiskImgLib::DiskFS* pDiskFS, DiskImgLib::A2File* pFile,
int depth); int depth);
/*
* Allocate a new TargetData struct, and add it to our list.
*/
TargetData* AllocTargetData(void); TargetData* AllocTargetData(void);
/*
* Free up the TargetData structures we created.
*/
void FreeAllTargetData(void); void FreeAllTargetData(void);
void LoadTreeImages(void) { void LoadTreeImages(void) {

View File

@ -17,11 +17,7 @@ BEGIN_MESSAGE_MAP(EOLScanDialog, CDialog)
ON_COMMAND(IDHELP, OnHelp) ON_COMMAND(IDHELP, OnHelp)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL EOLScanDialog::OnInitDialog(void)
* Fill in the blanks.
*/
BOOL
EOLScanDialog::OnInitDialog(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CString fmt; CString fmt;
@ -49,11 +45,7 @@ EOLScanDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void EOLScanDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
EOLScanDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_EOL_SCAN, HELP_CONTEXT); WinHelp(HELP_TOPIC_EOL_SCAN, HELP_CONTEXT);
} }

View File

@ -28,7 +28,8 @@ public:
long fCountHighASCII; long fCountHighASCII;
private: private:
BOOL OnInitDialog(void); BOOL OnInitDialog(void) override;
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for EditAssocDialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "EditAssocDialog.h" #include "EditAssocDialog.h"
#include "MyApp.h" #include "MyApp.h"
@ -24,11 +21,7 @@ END_MESSAGE_MAP()
INDEXTOSTATEIMAGEMASK((fCheck)+1), LVIS_STATEIMAGEMASK) INDEXTOSTATEIMAGEMASK((fCheck)+1), LVIS_STATEIMAGEMASK)
#endif #endif
/* BOOL EditAssocDialog::OnInitDialog(void)
* Tweak the controls.
*/
BOOL
EditAssocDialog::OnInitDialog(void)
{ {
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST); CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST);
@ -59,18 +52,9 @@ EditAssocDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void EditAssocDialog::Setup(bool loadAssoc)
* Load the list view control.
*
* This list isn't sorted, so we don't need to stuff anything into lParam to
* keep the list and source data tied.
*
* If "loadAssoc" is true, we also populate the fOurAssocations table.
*/
void
EditAssocDialog::Setup(bool loadAssoc)
{ {
LOGI("Setup!"); LOGD("Setup!");
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST); CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST);
ASSERT(pListView != NULL); ASSERT(pListView != NULL);
@ -107,11 +91,7 @@ EditAssocDialog::Setup(bool loadAssoc)
//DeleteAllItems(); // for Reload case //DeleteAllItems(); // for Reload case
} }
/* void EditAssocDialog::DoDataExchange(CDataExchange* pDX)
* Copy state in and out of dialog.
*/
void
EditAssocDialog::DoDataExchange(CDataExchange* pDX)
{ {
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST); CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST);
@ -140,20 +120,12 @@ EditAssocDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
/* BOOL EditAssocDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
EditAssocDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
return ShowContextHelp(this, lpHelpInfo); return ShowContextHelp(this, lpHelpInfo);
} }
/* void EditAssocDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
EditAssocDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_EDIT_ASSOC, HELP_CONTEXT); WinHelp(HELP_TOPIC_EDIT_ASSOC, HELP_CONTEXT);
} }

View File

@ -30,13 +30,20 @@ public:
bool* fOurAssociations; bool* fOurAssociations;
protected: protected:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void); void DoDataExchange(CDataExchange* pDX) override;
BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
void DoDataExchange(CDataExchange* pDX);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
/*
* Load the list view control.
*
* This list isn't sorted, so we don't need to stuff anything into lParam to
* keep the list and source data tied.
*
* If "loadAssoc" is true, we also populate the fOurAssocations table.
*/
void Setup(bool loadAssoc); void Setup(bool loadAssoc);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()

View File

@ -17,13 +17,11 @@ BEGIN_MESSAGE_MAP(EditCommentDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL EditCommentDialog::OnInitDialog(void)
* Set up the control. If this is a new comment, don't show the delete
* button.
*/
BOOL
EditCommentDialog::OnInitDialog(void)
{ {
/*
* If this is a new comment, don't show the delete button.
*/
if (fNewComment) { if (fNewComment) {
CWnd* pWnd = GetDlgItem(IDC_COMMENT_DELETE); CWnd* pWnd = GetDlgItem(IDC_COMMENT_DELETE);
pWnd->EnableWindow(FALSE); pWnd->EnableWindow(FALSE);
@ -32,20 +30,12 @@ EditCommentDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void EditCommentDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
EditCommentDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_Text(pDX, IDC_COMMENT_EDIT, fComment); DDX_Text(pDX, IDC_COMMENT_EDIT, fComment);
} }
/* void EditCommentDialog::OnDelete(void)
* User wants to delete the comment. Verify first.
*/
void
EditCommentDialog::OnDelete(void)
{ {
CString question, title; CString question, title;
int result; int result;
@ -59,21 +49,13 @@ EditCommentDialog::OnDelete(void)
EndDialog(kDeleteCommentID); EndDialog(kDeleteCommentID);
} }
/* BOOL EditCommentDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
EditCommentDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void EditCommentDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
EditCommentDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_EDIT_COMMENT, HELP_CONTEXT); WinHelp(HELP_TOPIC_EDIT_COMMENT, HELP_CONTEXT);
} }

View File

@ -21,7 +21,6 @@ public:
EditCommentDialog(CWnd* pParentWnd = NULL) : EditCommentDialog(CWnd* pParentWnd = NULL) :
CDialog(IDD_COMMENT_EDIT, pParentWnd) CDialog(IDD_COMMENT_EDIT, pParentWnd)
{ {
//fComment = "";
fNewComment = false; fNewComment = false;
} }
virtual ~EditCommentDialog(void) {} virtual ~EditCommentDialog(void) {}
@ -32,12 +31,15 @@ public:
bool fNewComment; // entry doesn't already have one bool fNewComment; // entry doesn't already have one
protected: protected:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void); virtual void DoDataExchange(CDataExchange* pDX) override;
virtual void DoDataExchange(CDataExchange* pDX);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
/*
* User wants to delete the comment. Verify first.
*/
afx_msg void OnDelete(void); afx_msg void OnDelete(void);
private: private:

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for file properties edit dialog.
*/
#include "StdAfx.h" #include "StdAfx.h"
#include "EditPropsDialog.h" #include "EditPropsDialog.h"
#include "FileNameConv.h" #include "FileNameConv.h"
@ -25,11 +22,7 @@ BEGIN_MESSAGE_MAP(EditPropsDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* void EditPropsDialog::InitProps(GenericEntry* pEntry)
* Initialize fProps from the stuff in pEntry.
*/
void
EditPropsDialog::InitProps(GenericEntry* pEntry)
{ {
fPathName = pEntry->GetPathName(); fPathName = pEntry->GetPathName();
fProps.fileType = pEntry->GetFileType(); fProps.fileType = pEntry->GetFileType();
@ -66,8 +59,7 @@ EditPropsDialog::InitProps(GenericEntry* pEntry)
* If this is a disk archive, we might want to make the aux type read-only, * If this is a disk archive, we might want to make the aux type read-only,
* though this would provide a way for users to fix badly-formed archives. * though this would provide a way for users to fix badly-formed archives.
*/ */
BOOL BOOL EditPropsDialog::OnInitDialog(void)
EditPropsDialog::OnInitDialog(void)
{ {
static const int kPascalTypes[] = { static const int kPascalTypes[] = {
0x00 /*NON*/, 0x01 /*BAD*/, 0x02 /*PCD*/, 0x03 /*PTX*/, 0x00 /*NON*/, 0x01 /*BAD*/, 0x02 /*PCD*/, 0x03 /*PTX*/,
@ -197,11 +189,7 @@ EditPropsDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void EditPropsDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
EditPropsDialog::DoDataExchange(CDataExchange* pDX)
{ {
int fileTypeIdx; int fileTypeIdx;
BOOL accessR, accessW, accessI, accessB, accessN, accessD; BOOL accessR, accessW, accessI, accessB, accessN, accessD;
@ -342,17 +330,7 @@ EditPropsDialog::DoDataExchange(CDataExchange* pDX)
DDX_Text(pDX, IDC_PROPS_PATHNAME, fPathName); DDX_Text(pDX, IDC_PROPS_PATHNAME, fPathName);
} }
/* void EditPropsDialog::OnTypeChange(void)
* This is called when the file type selection changes or something is
* typed in the aux type box.
*
* We use this notification to configure the type description field.
*
* Typing in the ProDOS aux type box causes us to nuke the HFS values.
* If we were in "HFS mode" we reset the file type to zero.
*/
void
EditPropsDialog::OnTypeChange(void)
{ {
static const WCHAR kUnknownFileType[] = L"Unknown file type"; static const WCHAR kUnknownFileType[] = L"Unknown file type";
CComboBox* pCombo; CComboBox* pCombo;
@ -388,20 +366,12 @@ EditPropsDialog::OnTypeChange(void)
} }
} }
/* void EditPropsDialog::OnHFSTypeChange(void)
* Called when something is typed in one of the HFS type boxes.
*/
void
EditPropsDialog::OnHFSTypeChange(void)
{ {
assert(fAllowedTypes == kAllowedHFS); assert(fAllowedTypes == kAllowedHFS);
} }
/* void EditPropsDialog::UpdateHFSMode(void)
* Called initially and when switching modes.
*/
void
EditPropsDialog::UpdateHFSMode(void)
{ {
CButton* pButton = (CButton*) GetDlgItem(IDC_PROPS_HFS_MODE); CButton* pButton = (CButton*) GetDlgItem(IDC_PROPS_HFS_MODE);
CComboBox* pCombo; CComboBox* pCombo;
@ -449,13 +419,7 @@ EditPropsDialog::UpdateHFSMode(void)
} }
} }
/* void EditPropsDialog::UpdateSimpleAccess(void)
* For "simple" access formats, i.e. DOS 3.2/3.3, the "write" button acts
* as a "locked" flag. We want the other rename/delete flags to track this
* one.
*/
void
EditPropsDialog::UpdateSimpleAccess(void)
{ {
if (!fSimpleAccess) if (!fSimpleAccess)
return; return;
@ -472,15 +436,7 @@ EditPropsDialog::UpdateSimpleAccess(void)
pButton->SetCheck(checked); pButton->SetCheck(checked);
} }
long EditPropsDialog::GetAuxType(void)
/*
* Get the aux type.
*
* Returns -1 if something was wrong with the string (e.g. empty or has
* invalid chars).
*/
long
EditPropsDialog::GetAuxType(void)
{ {
CWnd* pWnd = GetDlgItem(IDC_PROPS_AUXTYPE); CWnd* pWnd = GetDlgItem(IDC_PROPS_AUXTYPE);
ASSERT(pWnd != NULL); ASSERT(pWnd != NULL);
@ -505,21 +461,13 @@ EditPropsDialog::GetAuxType(void)
return val; return val;
} }
/* BOOL EditPropsDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
EditPropsDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void EditPropsDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
EditPropsDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_EDIT_PROPS, HELP_CONTEXT); WinHelp(HELP_TOPIC_EDIT_PROPS, HELP_CONTEXT);
} }

View File

@ -50,19 +50,46 @@ public:
bool fReadOnly; bool fReadOnly;
private: private:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void); virtual void DoDataExchange(CDataExchange* pDX) override;
virtual void DoDataExchange(CDataExchange* pDX);
/*
* This is called when the file type selection changes or something is
* typed in the aux type box.
*
* We use this notification to configure the type description field.
*
* Typing in the ProDOS aux type box causes us to nuke the HFS values.
* If we were in "HFS mode" we reset the file type to zero.
*/
afx_msg void OnTypeChange(void); afx_msg void OnTypeChange(void);
/*
* Called when something is typed in one of the HFS type boxes.
*/
afx_msg void OnHFSTypeChange(void); afx_msg void OnHFSTypeChange(void);
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
/*
* For "simple" access formats, i.e. DOS 3.2/3.3, the "write" button acts
* as a "locked" flag. We want the other rename/delete flags to track this
* one.
*/
void UpdateSimpleAccess(void); void UpdateSimpleAccess(void);
/*
* Called initially and when switching modes.
*/
void UpdateHFSMode(void); void UpdateHFSMode(void);
/*
* Get the aux type.
*
* Returns -1 if something was wrong with the string (e.g. empty or has
* invalid chars).
*/
long GetAuxType(void); long GetAuxType(void);
//void ShowHFSType(void);
/* what sort of type changes do we allow? */ /* what sort of type changes do we allow? */
AllowedTypes fAllowedTypes; AllowedTypes fAllowedTypes;

View File

@ -23,8 +23,7 @@ END_MESSAGE_MAP()
/* /*
* Disable the "OK" button initially. * Disable the "OK" button initially.
*/ */
BOOL BOOL EnterRegDialog::OnInitDialog(void)
EnterRegDialog::OnInitDialog(void)
{ {
//CWnd* pWnd = GetDlgItem(IDOK); //CWnd* pWnd = GetDlgItem(IDOK);
//ASSERT(pWnd != NULL); //ASSERT(pWnd != NULL);
@ -53,8 +52,7 @@ EnterRegDialog::OnInitDialog(void)
* Shuffle data in and out of the edit fields. We do an extra validation * Shuffle data in and out of the edit fields. We do an extra validation
* step on the registration key before accepting it. * step on the registration key before accepting it.
*/ */
void void EnterRegDialog::DoDataExchange(CDataExchange* pDX)
EnterRegDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_Text(pDX, IDC_REGENTER_USER, fUserName); DDX_Text(pDX, IDC_REGENTER_USER, fUserName);
DDX_Text(pDX, IDC_REGENTER_COMPANY, fCompanyName); DDX_Text(pDX, IDC_REGENTER_COMPANY, fCompanyName);
@ -85,14 +83,7 @@ EnterRegDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
/* void EnterRegDialog::HandleEditChange(int editID, int crcID)
* Call this when the text in an edit field has changed.
*
* If there's nothing in the "user name" or "reg key" fields, dim the OK
* button.
*/
void
EnterRegDialog::HandleEditChange(int editID, int crcID)
{ {
CString userStr, regStr; CString userStr, regStr;
CEdit* pEdit; CEdit* pEdit;
@ -127,45 +118,29 @@ EnterRegDialog::HandleEditChange(int editID, int crcID)
pWnd->EnableWindow(!userStr.IsEmpty() && !regStr.IsEmpty()); pWnd->EnableWindow(!userStr.IsEmpty() && !regStr.IsEmpty());
} }
/* void EnterRegDialog::OnUserChange(void)
* Handle changes in the three edit fields.
*/
void
EnterRegDialog::OnUserChange(void)
{ {
HandleEditChange(IDC_REGENTER_USER, IDC_REGENTER_USERCRC); HandleEditChange(IDC_REGENTER_USER, IDC_REGENTER_USERCRC);
} }
void
EnterRegDialog::OnCompanyChange(void) void EnterRegDialog::OnCompanyChange(void)
{ {
HandleEditChange(IDC_REGENTER_COMPANY, IDC_REGENTER_COMPCRC); HandleEditChange(IDC_REGENTER_COMPANY, IDC_REGENTER_COMPCRC);
} }
void
EnterRegDialog::OnRegChange(void) void EnterRegDialog::OnRegChange(void)
{ {
HandleEditChange(IDC_REGENTER_REG, IDC_REGENTER_REGCRC); HandleEditChange(IDC_REGENTER_REG, IDC_REGENTER_REGCRC);
} }
/* void EnterRegDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
EnterRegDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_ENTER_REG_DATA, HELP_CONTEXT); WinHelp(HELP_TOPIC_ENTER_REG_DATA, HELP_CONTEXT);
} }
/* /*static*/ int EnterRegDialog::GetRegInfo(CWnd* pWnd)
* Get registration info from the user. This is a static utility function
* that can be called from elsewhere in the app.
*
* Returns 0 on successful registration, nonzero on failure or if the user
* cancels out of the dialog.
*/
/*static*/ int
EnterRegDialog::GetRegInfo(CWnd* pWnd)
{ {
CString user, company, reg, versions, expire; CString user, company, reg, versions, expire;
@ -208,4 +183,4 @@ EnterRegDialog::GetRegInfo(CWnd* pWnd)
return result; return result;
} }
#endif /*0*/ #endif /*0*/

View File

@ -16,29 +16,43 @@
* Straightforward dialog. We validate the registration key in the DDX * Straightforward dialog. We validate the registration key in the DDX
* function, so an IDOK is a guarantee that they have entered valid data. It * function, so an IDOK is a guarantee that they have entered valid data. It
* is up to the caller to store the values in the registry. * is up to the caller to store the values in the registry.
*
* [ This was only used in the shareware product. ]
*/ */
class EnterRegDialog : public CDialog { class EnterRegDialog : public CDialog {
public: public:
EnterRegDialog(CWnd* pParent = NULL) : CDialog(IDD_REGISTRATION, pParent) EnterRegDialog(CWnd* pParent = NULL) : CDialog(IDD_REGISTRATION, pParent)
{ fDepth = 0; } { fDepth = 0; }
virtual ~EnterRegDialog(void) {} virtual ~EnterRegDialog(void) {}
CString fUserName; CString fUserName;
CString fCompanyName; CString fCompanyName;
CString fRegKey; CString fRegKey;
/*
* Get registration info from the user. This is a static utility function
* that can be called from elsewhere in the app.
*
* Returns 0 on successful registration, nonzero on failure or if the user
* cancels out of the dialog.
*/
static int GetRegInfo(CWnd* pWnd); static int GetRegInfo(CWnd* pWnd);
private: private:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void); virtual void DoDataExchange(CDataExchange* pDX) override;
virtual void DoDataExchange(CDataExchange* pDX);
afx_msg void OnUserChange(void); afx_msg void OnUserChange(void);
afx_msg void OnCompanyChange(void); afx_msg void OnCompanyChange(void);
afx_msg void OnRegChange(void); afx_msg void OnRegChange(void);
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
/*
* Call this when the text in an edit field has changed.
*
* If there's nothing in the "user name" or "reg key" fields, dim the OK
* button.
*/
void HandleEditChange(int editID, int crcID); void HandleEditChange(int editID, int crcID);
MyEdit fMyEdit; MyEdit fMyEdit;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for ExtractOptionsDialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "ExtractOptionsDialog.h" #include "ExtractOptionsDialog.h"
#include "HelpTopics.h" #include "HelpTopics.h"
@ -30,8 +27,7 @@ END_MESSAGE_MAP()
* All we really need to do is update the string that indicates how many * All we really need to do is update the string that indicates how many
* files have been selected. * files have been selected.
*/ */
BOOL BOOL ExtractOptionsDialog::OnInitDialog(void)
ExtractOptionsDialog::OnInitDialog(void)
{ {
CString countFmt; CString countFmt;
CString selStr; CString selStr;
@ -68,15 +64,12 @@ ExtractOptionsDialog::OnInitDialog(void)
//return TRUE; // let Windows set the focus //return TRUE; // let Windows set the focus
} }
/* void ExtractOptionsDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*
* Should probably verify that fFilesToExtract is not set to kExtractSelection
* when fSelectedCount is zero.
*/
void
ExtractOptionsDialog::DoDataExchange(CDataExchange* pDX)
{ {
/*
* Should probably verify that fFilesToExtract is not set to kExtractSelection
* when fSelectedCount is zero.
*/
DDX_Text(pDX, IDC_EXT_PATH, fExtractPath); DDX_Text(pDX, IDC_EXT_PATH, fExtractPath);
DDX_Radio(pDX, IDC_EXT_SELECTED, fFilesToExtract); DDX_Radio(pDX, IDC_EXT_SELECTED, fFilesToExtract);
@ -98,11 +91,7 @@ ExtractOptionsDialog::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_EXT_OVERWRITE_EXIST, fOverwriteExisting); DDX_Check(pDX, IDC_EXT_OVERWRITE_EXIST, fOverwriteExisting);
} }
/* void ExtractOptionsDialog::OnConfigPreserve(void)
* Reconfigure controls for best preservation of Apple II formats.
*/
void
ExtractOptionsDialog::OnConfigPreserve(void)
{ {
// IDC_EXT_PATH, IDC_EXT_SELECTED // IDC_EXT_PATH, IDC_EXT_SELECTED
SetDlgButtonCheck(this, IDC_EXT_DATAFORK, BST_CHECKED); SetDlgButtonCheck(this, IDC_EXT_DATAFORK, BST_CHECKED);
@ -123,11 +112,7 @@ ExtractOptionsDialog::OnConfigPreserve(void)
OnChangeTextConv(); OnChangeTextConv();
} }
/* void ExtractOptionsDialog::OnConfigConvert(void)
* Reconfigure controls for easiest viewing under Windows.
*/
void
ExtractOptionsDialog::OnConfigConvert(void)
{ {
// IDC_EXT_PATH, IDC_EXT_SELECTED // IDC_EXT_PATH, IDC_EXT_SELECTED
SetDlgButtonCheck(this, IDC_EXT_DATAFORK, BST_CHECKED); SetDlgButtonCheck(this, IDC_EXT_DATAFORK, BST_CHECKED);
@ -148,12 +133,7 @@ ExtractOptionsDialog::OnConfigConvert(void)
OnChangeTextConv(); OnChangeTextConv();
} }
/* void ExtractOptionsDialog::OnChangeTextConv(void)
* Enable or disable the "Convert high ASCII" button based on the current
* setting of the radio button above it.
*/
void
ExtractOptionsDialog::OnChangeTextConv(void)
{ {
CButton* pButton = (CButton*) GetDlgItem(IDC_EXT_CONVEOLNONE); CButton* pButton = (CButton*) GetDlgItem(IDC_EXT_CONVEOLNONE);
ASSERT(pButton != NULL); ASSERT(pButton != NULL);
@ -164,11 +144,7 @@ ExtractOptionsDialog::OnChangeTextConv(void)
pWnd->EnableWindow(!convDisabled); pWnd->EnableWindow(!convDisabled);
} }
/* void ExtractOptionsDialog::OnChooseFolder(void)
* They want to choose the folder from a tree.
*/
void
ExtractOptionsDialog::OnChooseFolder(void)
{ {
ChooseDirDialog chooseDir(this); ChooseDirDialog chooseDir(this);
CWnd* pEditWnd; CWnd* pEditWnd;
@ -188,21 +164,13 @@ ExtractOptionsDialog::OnChooseFolder(void)
} }
} }
/* BOOL ExtractOptionsDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
ExtractOptionsDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void ExtractOptionsDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
ExtractOptionsDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_EXT_OPTIONS, HELP_CONTEXT); WinHelp(HELP_TOPIC_EXT_OPTIONS, HELP_CONTEXT);
} }

View File

@ -68,14 +68,34 @@ public:
} }
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* Reconfigure controls for best preservation of Apple II formats.
*/
afx_msg void OnConfigPreserve(void); afx_msg void OnConfigPreserve(void);
/*
* Reconfigure controls for easiest viewing under Windows.
*/
afx_msg void OnConfigConvert(void); afx_msg void OnConfigConvert(void);
/*
* Enable or disable the "Convert high ASCII" button based on the current
* setting of the radio button above it.
*/
afx_msg void OnChangeTextConv(void); afx_msg void OnChangeTextConv(void);
/*
* They want to choose the folder from a tree.
*/
afx_msg void OnChooseFolder(void); afx_msg void OnChooseFolder(void);
// Context help request (question mark button).
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
// User pressed the "Help" button.
afx_msg void OnHelp(void); afx_msg void OnHelp(void);
MyBitmapButton fChooseFolderButton; MyBitmapButton fChooseFolderButton;

View File

@ -15,6 +15,7 @@
#define WINDOWS_LIKE #define WINDOWS_LIKE
/* replace unsupported chars with '%xx' */ /* replace unsupported chars with '%xx' */
#define kForeignIndic '%' #define kForeignIndic '%'
@ -80,6 +81,18 @@ static const WCHAR gFileTypeNames[256][4] = {
L"$F8", L"OS ", L"INT", L"IVR", L"BAS", L"VAR", L"REL", L"SYS" L"$F8", L"OS ", L"INT", L"IVR", L"BAS", L"VAR", L"REL", L"SYS"
}; };
static const WCHAR kUnknownTypeStr[] = L"???";
/*static*/ const WCHAR* PathProposal::FileTypeString(unsigned long fileType)
{
// Note to self: code down below tests first char for '?'.
if (fileType < NELEM(gFileTypeNames))
return gFileTypeNames[fileType];
else
return kUnknownTypeStr;
}
/* /*
* Some file extensions we recognize. When adding files with "extended" * Some file extensions we recognize. When adding files with "extended"
* preservation mode, we try to assign types to files that weren't * preservation mode, we try to assign types to files that weren't
@ -111,21 +124,6 @@ static const struct {
{ L"SHK", 0xe0, 0x8002, 0 }, /* ShrinkIt archive */ { L"SHK", 0xe0, 0x8002, 0 }, /* ShrinkIt archive */
}; };
/*
* Return a pointer to the three-letter representation of the file type name.
*
* Note to self: code down below tests first char for '?'.
*/
/*static*/ const WCHAR*
PathProposal::FileTypeString(unsigned long fileType)
{
if (fileType < NELEM(gFileTypeNames))
return gFileTypeNames[fileType];
else
return kUnknownTypeStr;
}
/* /*
* Description table. * Description table.
* *
@ -589,16 +587,10 @@ static const struct {
/*OS */ { 0xff, 0x0000, 0xffff, L"ProDOS 8 application" }, /*OS */ { 0xff, 0x0000, 0xffff, L"ProDOS 8 application" },
}; };
/* /*static*/ const WCHAR* PathProposal::FileTypeDescription(long fileType,
* Find an entry in the type description table that matches both file type and long auxType)
* aux type. If no match is found, NULL is returned.
*/
/*static*/ const WCHAR*
PathProposal::FileTypeDescription(long fileType, long auxType)
{ {
int i; for (int i = NELEM(gTypeDescriptions)-1; i >= 0; i--) {
for (i = NELEM(gTypeDescriptions)-1; i >= 0; i--) {
if (fileType == gTypeDescriptions[i].fileType && if (fileType == gTypeDescriptions[i].fileType &&
auxType >= gTypeDescriptions[i].minAuxType && auxType >= gTypeDescriptions[i].minAuxType &&
auxType <= gTypeDescriptions[i].maxAuxType) auxType <= gTypeDescriptions[i].maxAuxType)
@ -617,15 +609,7 @@ PathProposal::FileTypeDescription(long fileType, long auxType)
* =========================================================================== * ===========================================================================
*/ */
/* void PathProposal::ArchiveToLocal(void)
* Convert a pathname pulled out of an archive to something suitable for the
* local filesystem.
*
* The new pathname may be shorter (because characters were removed) or
* longer (if we add a "#XXYYYYZ" extension or replace chars with '%' codes).
*/
void
PathProposal::ArchiveToLocal(void)
{ {
WCHAR* pathBuf; WCHAR* pathBuf;
const WCHAR* startp; const WCHAR* startp;
@ -736,17 +720,14 @@ static const WCHAR* gFatReservedNames4[] = {
NULL NULL
}; };
/* void PathProposal::Win32NormalizeFileName(const WCHAR* srcp, long srcLen,
* Filename normalization for Win32 filesystems. You can't use [ \/:*?"<>| ]
* or control characters, and we're currently avoiding high-ASCII stuff.
* TODO: consider supporting the "Mac Roman" characters
*
* TODO: don't allow the filename to end with a space or period
*/
void
PathProposal::Win32NormalizeFileName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen) char fssep, WCHAR** pDstp, long dstLen)
{ {
/*
* TODO: consider supporting the "Mac Roman" characters
* TODO: don't allow the filename to end with a space or period (Windows
* requirement)
*/
WCHAR* dstp = *pDstp; WCHAR* dstp = *pDstp;
const WCHAR* startp = srcp; const WCHAR* startp = srcp;
static const WCHAR* kInvalid = L"\\/:*?\"<>|"; static const WCHAR* kInvalid = L"\\/:*?\"<>|";
@ -823,18 +804,7 @@ PathProposal::Win32NormalizeFileName(const WCHAR* srcp, long srcLen,
} }
#endif #endif
void PathProposal::NormalizeFileName(const WCHAR* srcp, long srcLen,
/*
* Normalize a file name to local filesystem conventions. The input
* is quite possibly *NOT* null-terminated, since it may represent a
* substring of a full pathname. Use "srcLen".
*
* The output filename is copied to *pDstp, which is advanced forward.
*
* The output buffer must be able to hold 3x the original string length.
*/
void
PathProposal::NormalizeFileName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen) char fssep, WCHAR** pDstp, long dstLen)
{ {
ASSERT(srcp != NULL); ASSERT(srcp != NULL);
@ -852,12 +822,7 @@ PathProposal::NormalizeFileName(const WCHAR* srcp, long srcLen,
#endif #endif
} }
void PathProposal::NormalizeDirectoryName(const WCHAR* srcp, long srcLen,
/*
* Normalize a directory name to local filesystem conventions.
*/
void
PathProposal::NormalizeDirectoryName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen) char fssep, WCHAR** pDstp, long dstLen)
{ {
/* in general, directories and filenames are the same */ /* in general, directories and filenames are the same */
@ -865,15 +830,7 @@ PathProposal::NormalizeDirectoryName(const WCHAR* srcp, long srcLen,
NormalizeFileName(srcp, srcLen, fssep, pDstp, dstLen); NormalizeFileName(srcp, srcLen, fssep, pDstp, dstLen);
} }
void PathProposal::AddPreservationString(const WCHAR* pathBuf, WCHAR* extBuf)
/*
* Add a preservation string.
*
* "pathBuf" is assumed to have enough space to hold the current path
* plus kMaxPathGrowth more. It will be modified in place.
*/
void
PathProposal::AddPreservationString(const WCHAR* pathBuf, WCHAR* extBuf)
{ {
WCHAR* cp; WCHAR* cp;
@ -905,14 +862,7 @@ PathProposal::AddPreservationString(const WCHAR* pathBuf, WCHAR* extBuf)
*cp = '\0'; *cp = '\0';
} }
/* void PathProposal::AddTypeExtension(const WCHAR* pathBuf, WCHAR* extBuf)
* Add a ".foo" extension to the filename.
*
* We either need to retain the existing extension (possibly obscured by file
* type preservation) or append an extension based on the ProDOS file type.
*/
void
PathProposal::AddTypeExtension(const WCHAR* pathBuf, WCHAR* extBuf)
{ {
const WCHAR* pPathExt = NULL; const WCHAR* pPathExt = NULL;
const WCHAR* pWantedExt = NULL; const WCHAR* pWantedExt = NULL;
@ -1024,18 +974,7 @@ know_ext:
typedef bool Boolean; typedef bool Boolean;
/* void PathProposal::LocalToArchive(const AddFilesDialog* pAddOpts)
* Convert a local path into something suitable for storage in an archive.
* Type preservation strings are interpreted and stripped as appropriate.
*
* This does *not* do filesystem-specific normalization here. (It could, but
* it's better to leave that for later so we can do uniqueification.)
*
* In the current implementation, fStoredPathName will always get smaller,
* but it would be unwise to rely on that.
*/
void
PathProposal::LocalToArchive(const AddFilesDialog* pAddOpts)
{ {
Boolean wasPreserved; Boolean wasPreserved;
Boolean doJunk = false; Boolean doJunk = false;
@ -1173,12 +1112,7 @@ PathProposal::LocalToArchive(const AddFilesDialog* pAddOpts)
fStoredPathName.ReleaseBuffer(); fStoredPathName.ReleaseBuffer();
} }
/* void PathProposal::ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst)
* Replace "oldc" with "newc". If we find an instance of "newc" already
* in the string, replace it with "newSubst".
*/
void
PathProposal::ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst)
{ {
while (*str != '\0') { while (*str != '\0') {
if (*str == oldc) if (*str == oldc)
@ -1189,15 +1123,7 @@ PathProposal::ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst)
} }
} }
void PathProposal::LookupExtension(const WCHAR* ext)
/*
* Try to figure out what file type is associated with a filename extension.
*
* This checks the standard list of ProDOS types (which should catch things
* like "TXT" and "BIN") and the separate list of recognized extensions.
*/
void
PathProposal::LookupExtension(const WCHAR* ext)
{ {
WCHAR uext3[4]; WCHAR uext3[4];
int i, extLen; int i, extLen;
@ -1242,11 +1168,7 @@ bail:
return; return;
} }
/* void PathProposal::InterpretExtension(const WCHAR* pathName)
* Try to associate some meaning with the file extension.
*/
void
PathProposal::InterpretExtension(const WCHAR* pathName)
{ {
const WCHAR* pExt; const WCHAR* pExt;
@ -1257,18 +1179,12 @@ PathProposal::InterpretExtension(const WCHAR* pathName)
LookupExtension(pExt+1); LookupExtension(pExt+1);
} }
Boolean PathProposal::ExtractPreservationString(WCHAR* pathname)
/*
* Check to see if there's a preservation string on the filename. If so,
* set the filetype and auxtype information, and trim the preservation
* string off.
*
* We have to be careful not to trip on false-positive occurrences of '#'
* in the filename.
*/
Boolean
PathProposal::ExtractPreservationString(WCHAR* pathname)
{ {
/*
* We have to be careful not to trip on false-positive occurrences of '#'
* in the filename.
*/
WCHAR numBuf[9]; WCHAR numBuf[9];
unsigned long fileType, auxType; unsigned long fileType, auxType;
int threadMask; int threadMask;
@ -1352,15 +1268,7 @@ PathProposal::ExtractPreservationString(WCHAR* pathname)
return true; return true;
} }
void PathProposal::DenormalizePath(WCHAR* pathBuf)
/*
* Remove NuLib2's normalization magic (e.g. "%2f" for '/').
*
* This always results in the filename staying the same length or getting
* smaller, so we can do it in place in the buffer.
*/
void
PathProposal::DenormalizePath(WCHAR* pathBuf)
{ {
const WCHAR* srcp; const WCHAR* srcp;
WCHAR* dstp; WCHAR* dstp;
@ -1402,14 +1310,7 @@ PathProposal::DenormalizePath(WCHAR* pathBuf)
ASSERT(dstp <= srcp); ASSERT(dstp <= srcp);
} }
/* void PathProposal::StripDiskImageSuffix(WCHAR* pathName)
* Remove a disk image suffix.
*
* Useful when adding disk images directly from a .SDK or .2MG file. We
* don't want them to retain their original suffix.
*/
void
PathProposal::StripDiskImageSuffix(WCHAR* pathName)
{ {
static const WCHAR diskExt[][4] = { static const WCHAR diskExt[][4] = {
L"SHK", L"SDK", L"IMG", L"PO", L"DO", L"2MG", L"DSK" L"SHK", L"SDK", L"IMG", L"PO", L"DO", L"2MG", L"DSK"

View File

@ -11,7 +11,6 @@
#include "GenericArchive.h" #include "GenericArchive.h"
#define kUnknownTypeStr L"???"
/* /*
* Proposal for an output pathname, based on the contents of a GenericEntry. * Proposal for an output pathname, based on the contents of a GenericEntry.
@ -78,9 +77,25 @@ public:
ASSERT(!fJunkPaths); ASSERT(!fJunkPaths);
} }
// Convert a partial pathname from the archive to a local partial path. /*
* Convert a pathname pulled out of an archive to something suitable for the
* local filesystem.
*
* The new pathname may be shorter (because characters were removed) or
* longer (if we add a "#XXYYYYZ" extension or replace chars with '%' codes).
*/
void ArchiveToLocal(void); void ArchiveToLocal(void);
// Same thing, other direction.
/*
* Convert a local path into something suitable for storage in an archive.
* Type preservation strings are interpreted and stripped as appropriate.
*
* This does *not* do filesystem-specific normalization here. (It could, but
* it's better to leave that for later so we can do uniqueification.)
*
* In the current implementation, fStoredPathName will always get smaller,
* but it would be unwise to rely on that.
*/
void LocalToArchive(const AddFilesDialog* pAddOpts); void LocalToArchive(const AddFilesDialog* pAddOpts);
/* /*
@ -113,26 +128,98 @@ public:
bool fStripDiskImageSuffix; bool fStripDiskImageSuffix;
/* /*
* Misc utility functions. * Return a pointer to the three-letter representation of the file type name.
*/ */
static const WCHAR* FileTypeString(unsigned long fileType); static const WCHAR* FileTypeString(unsigned long fileType);
/*
* Find an entry in the type description table that matches both file type and
* aux type. If no match is found, NULL is returned.
*/
static const WCHAR* FileTypeDescription(long fileType, long auxType); static const WCHAR* FileTypeDescription(long fileType, long auxType);
private: private:
/*
* Filename normalization for Win32 filesystems. You can't use [ \/:*?"<>| ]
* or control characters, and we're currently avoiding high-ASCII stuff.
*/
void Win32NormalizeFileName(const WCHAR* srcp, long srcLen, void Win32NormalizeFileName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen); char fssep, WCHAR** pDstp, long dstLen);
/*
* Normalize a file name to local filesystem conventions. The input
* is quite possibly *NOT* null-terminated, since it may represent a
* substring of a full pathname. Use "srcLen".
*
* The output filename is copied to *pDstp, which is advanced forward.
*
* The output buffer must be able to hold 3x the original string length.
*/
void NormalizeFileName(const WCHAR* srcp, long srcLen, void NormalizeFileName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen); char fssep, WCHAR** pDstp, long dstLen);
/*
* Normalize a directory name to local filesystem conventions.
*/
void NormalizeDirectoryName(const WCHAR* srcp, long srcLen, void NormalizeDirectoryName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen); char fssep, WCHAR** pDstp, long dstLen);
/*
* Add a preservation string.
*
* "pathBuf" is assumed to have enough space to hold the current path
* plus kMaxPathGrowth more. It will be modified in place.
*/
void AddPreservationString(const WCHAR* pathBuf, WCHAR* extBuf); void AddPreservationString(const WCHAR* pathBuf, WCHAR* extBuf);
/*
* Add a ".type" extension to the filename.
*
* We either need to retain the existing extension (possibly obscured by file
* type preservation) or append an extension based on the ProDOS file type.
*/
void AddTypeExtension(const WCHAR* pathBuf, WCHAR* extBuf); void AddTypeExtension(const WCHAR* pathBuf, WCHAR* extBuf);
/*
* Replace "oldc" with "newc". If we find an instance of "newc" already
* in the string, replace it with "newSubst".
*/
void ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst); void ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst);
/*
* Try to figure out what file type is associated with a filename extension.
*
* This checks the standard list of ProDOS types (which should catch things
* like "TXT" and "BIN") and the separate list of recognized extensions.
*/
void LookupExtension(const WCHAR* ext); void LookupExtension(const WCHAR* ext);
bool ExtractPreservationString(WCHAR* pathName);
/*
* Try to associate some meaning with the file extension.
*/
void InterpretExtension(const WCHAR* pathName); void InterpretExtension(const WCHAR* pathName);
/*
* Check to see if there's a preservation string on the filename. If so,
* set the filetype and auxtype information, and trim the preservation
* string off.
*/
bool ExtractPreservationString(WCHAR* pathName);
/*
* Remove NuLib2's normalization magic (e.g. "%2f" for '/').
*
* This always results in the filename staying the same length or getting
* smaller, so we can do it in place in the buffer.
*/
void DenormalizePath(WCHAR* pathBuf); void DenormalizePath(WCHAR* pathBuf);
/*
* Remove a disk image suffix.
*
* Useful when adding disk images directly from a .SDK or .2MG file. We
* don't want them to retain their original suffix.
*/
void StripDiskImageSuffix(WCHAR* pathName); void StripDiskImageSuffix(WCHAR* pathName);
}; };

View File

@ -45,9 +45,6 @@
* =========================================================================== * ===========================================================================
*/ */
/*
* Initialize all data members.
*/
GenericEntry::GenericEntry(void) GenericEntry::GenericEntry(void)
{ {
fPathName = NULL; fPathName = NULL;
@ -81,9 +78,6 @@ GenericEntry::GenericEntry(void)
fDamaged = fSuspicious = false; fDamaged = fSuspicious = false;
} }
/*
* Throw out anything we allocated.
*/
GenericEntry::~GenericEntry(void) GenericEntry::~GenericEntry(void)
{ {
delete[] fPathName; delete[] fPathName;
@ -91,11 +85,7 @@ GenericEntry::~GenericEntry(void)
delete[] fDisplayName; delete[] fDisplayName;
} }
/* void GenericEntry::SetPathName(const WCHAR* path)
* Pathname getters and setters.
*/
void
GenericEntry::SetPathName(const WCHAR* path)
{ {
ASSERT(path != NULL && wcslen(path) > 0); ASSERT(path != NULL && wcslen(path) > 0);
if (fPathName != NULL) if (fPathName != NULL)
@ -117,29 +107,29 @@ GenericEntry::SetPathName(const WCHAR* path)
if (pPreferences->GetPrefBool(kPrSpacesToUnder)) if (pPreferences->GetPrefBool(kPrSpacesToUnder))
SpacesToUnderscores(fPathName); SpacesToUnderscores(fPathName);
} }
const WCHAR*
GenericEntry::GetFileName(void) const WCHAR* GenericEntry::GetFileName(void)
{ {
ASSERT(fPathName != NULL); ASSERT(fPathName != NULL);
if (fFileName == NULL) if (fFileName == NULL)
fFileName = PathName::FilenameOnly(fPathName, fFssep); fFileName = PathName::FilenameOnly(fPathName, fFssep);
return fFileName; return fFileName;
} }
const WCHAR*
GenericEntry::GetFileNameExtension(void) const WCHAR* GenericEntry::GetFileNameExtension(void)
{ {
ASSERT(fPathName != NULL); ASSERT(fPathName != NULL);
if (fFileNameExtension == NULL) if (fFileNameExtension == NULL)
fFileNameExtension = PathName::FindExtension(fPathName, fFssep); fFileNameExtension = PathName::FindExtension(fPathName, fFssep);
return fFileNameExtension; return fFileNameExtension;
} }
CStringA
GenericEntry::GetFileNameExtensionA(void) CStringA GenericEntry::GetFileNameExtensionA(void)
{ {
return GetFileNameExtension(); return GetFileNameExtension();
} }
void
GenericEntry::SetSubVolName(const WCHAR* name) void GenericEntry::SetSubVolName(const WCHAR* name)
{ {
delete[] fSubVolName; delete[] fSubVolName;
fSubVolName = NULL; fSubVolName = NULL;
@ -147,8 +137,8 @@ GenericEntry::SetSubVolName(const WCHAR* name)
fSubVolName = wcsdup(name); fSubVolName = wcsdup(name);
} }
} }
const WCHAR*
GenericEntry::GetDisplayName(void) const const WCHAR* GenericEntry::GetDisplayName(void) const
{ {
ASSERT(fPathName != NULL); ASSERT(fPathName != NULL);
if (fDisplayName != NULL) if (fDisplayName != NULL)
@ -172,20 +162,12 @@ GenericEntry::GetDisplayName(void) const
return pThis->fDisplayName; return pThis->fDisplayName;
} }
/* const WCHAR* GenericEntry::GetFileTypeString(void) const
* Get a string for this entry's filetype.
*/
const WCHAR*
GenericEntry::GetFileTypeString(void) const
{ {
return PathProposal::FileTypeString(fFileType); return PathProposal::FileTypeString(fFileType);
} }
/* /*static*/ void GenericEntry::SpacesToUnderscores(WCHAR* buf)
* Convert spaces to underscores.
*/
/*static*/ void
GenericEntry::SpacesToUnderscores(WCHAR* buf)
{ {
while (*buf != '\0') { while (*buf != '\0') {
if (*buf == ' ') if (*buf == ' ')
@ -194,24 +176,22 @@ GenericEntry::SpacesToUnderscores(WCHAR* buf)
} }
} }
/*static*/ bool GenericEntry::CheckHighASCII(const uint8_t* buffer,
/*
* (Pulled from NufxLib Funnel.c.)
*
* Check to see if this is a high-ASCII file. To qualify, EVERY
* character must have its high bit set, except for spaces (0x20,
* courtesy Glen Bredon's "Merlin") and nulls (0x00, because of random-
* access text files).
*
* The test for 0x00 is actually useless in many circumstances because the
* NULLs will cause the text file auto-detector to flunk the file. It will,
* however, allow the user to select "convert ALL files" and still have the
* stripping enabled.
*/
/*static*/ bool
GenericEntry::CheckHighASCII(const unsigned char* buffer,
unsigned long count) unsigned long count)
{ {
/*
* (Pulled from NufxLib Funnel.c.)
*
* Check to see if this is a high-ASCII file. To qualify, EVERY
* character must have its high bit set, except for spaces (0x20,
* courtesy Glen Bredon's "Merlin") and nulls (0x00, because of random-
* access text files).
*
* The test for 0x00 is actually useless in many circumstances because the
* NULLs will cause the text file auto-detector to flunk the file. It will,
* however, allow the user to select "convert ALL files" and still have the
* stripping enabled.
*/
bool isHighASCII; bool isHighASCII;
ASSERT(buffer != NULL); ASSERT(buffer != NULL);
@ -268,42 +248,38 @@ static const char gIsBinary[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xf0 */
}; };
#define kNuMaxUpperASCII 1 /* max #of binary chars per 100 bytes */ static const int kNuMaxUpperASCII = 1; /* max #of binary chars per 100 bytes */
#define kMinConvThreshold 40 /* min of 40 chars for auto-detect */ static const int kMinConvThreshold = 40; /* min of 40 chars for auto-detect */
#define kCharLF '\n' static const char kCharLF = '\n';
#define kCharCR '\r' static const char kCharCR = '\r';
/*
* Decide, based on the contents of the buffer, whether we should do an /*static*/ GenericEntry::ConvertEOL GenericEntry::DetermineConversion(
* EOL conversion on the data. const uint8_t* buffer, long count,
*
* We need to decide if we are looking at text data, and if so, what kind
* of line terminator is in use.
*
* If we don't have enough data to make a determination, don't mess with it.
* (Thought for the day: add a "bias" flag, based on the NuRecord fileType,
* that causes us to handle borderline or sub-min-threshold cases more
* reasonably. If it's of type TXT, it's probably text.)
*
* We try to figure out whether it's CR, LF, or CRLF, so that we can
* skip the CPU-intensive conversion process if it isn't necessary.
*
* We will also investigate enabling a "high-ASCII" stripper if requested.
* This is only enabled when EOL conversions are enabled. Set "*pConvHA"
* to on/off/auto before calling. If it's initially set to "off", no
* attempt to evaluate high ASCII will be made. If "on" or "auto", the
* buffer will be scanned, and if the input appears to be high ASCII then
* it will be stripped *before* the EOL determination is made.
*
* Returns kConvEOLOff or kConvEOLOn.
*/
/*static*/ GenericEntry::ConvertEOL
GenericEntry::DetermineConversion(const unsigned char* buffer, long count,
EOLType* pSourceType, ConvertHighASCII* pConvHA) EOLType* pSourceType, ConvertHighASCII* pConvHA)
{ {
/*
* We need to decide if we are looking at text data, and if so, what kind
* of line terminator is in use.
*
* If we don't have enough data to make a determination, don't mess with it.
* (Thought for the day: add a "bias" flag, based on the NuRecord fileType,
* that causes us to handle borderline or sub-min-threshold cases more
* reasonably. If it's of type TXT, it's probably text.)
*
* We try to figure out whether it's CR, LF, or CRLF, so that we can
* skip the CPU-intensive conversion process if it isn't necessary.
*
* We will also investigate enabling a "high-ASCII" stripper if requested.
* This is only enabled when EOL conversions are enabled. Set "*pConvHA"
* to on/off/auto before calling. If it's initially set to "off", no
* attempt to evaluate high ASCII will be made. If "on" or "auto", the
* buffer will be scanned, and if the input appears to be high ASCII then
* it will be stripped *before* the EOL determination is made.
*/
ConvertHighASCII wantConvHA = *pConvHA; ConvertHighASCII wantConvHA = *pConvHA;
long bufCount, numBinary, numLF, numCR; long bufCount, numBinary, numLF, numCR;
bool isHighASCII; bool isHighASCII;
unsigned char val; uint8_t val;
*pSourceType = kEOLUnknown; *pSourceType = kEOLUnknown;
*pConvHA = kConvertHAOff; *pConvHA = kConvertHAOff;
@ -380,29 +356,13 @@ GenericEntry::DetermineConversion(const unsigned char* buffer, long count,
/* /*
* Output CRLF. * Output CRLF.
*/ */
static inline void static inline void PutEOL(FILE* fp)
PutEOL(FILE* fp)
{ {
putc(kCharCR, fp); putc(kCharCR, fp);
putc(kCharLF, fp); putc(kCharLF, fp);
} }
/* /*static*/ int GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
* Write data to a file, possibly converting EOL markers to Windows CRLF
* and stripping high ASCII.
*
* If "*pConv" is kConvertEOLAuto, this will try to auto-detect whether
* the input is a text file or not by scanning the input buffer.
*
* Ditto for "*pConvHA".
*
* "fp" is the output file, "buf" is the input, "len" is the buffer length.
* "*pLastCR" should initially be "false", and carried across invocations.
*
* Returns 0 on success, or an errno value on error.
*/
/*static*/ int
GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
ConvertEOL* pConv, ConvertHighASCII* pConvHA, bool* pLastCR) ConvertEOL* pConv, ConvertHighASCII* pConvHA, bool* pLastCR)
{ {
int err = 0; int err = 0;
@ -417,7 +377,7 @@ GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
/* if we're in "auto" mode, scan the input for EOL and high ASCII */ /* if we're in "auto" mode, scan the input for EOL and high ASCII */
if (*pConv == kConvertEOLAuto) { if (*pConv == kConvertEOLAuto) {
EOLType sourceType; EOLType sourceType;
*pConv = DetermineConversion((unsigned char*)buf, len, &sourceType, *pConv = DetermineConversion((uint8_t*)buf, len, &sourceType,
pConvHA); pConvHA);
if (*pConv == kConvertEOLOn && sourceType == kEOLCRLF) { if (*pConv == kConvertEOLOn && sourceType == kEOLCRLF) {
LOGI(" Auto-detected text conversion from CRLF; disabling"); LOGI(" Auto-detected text conversion from CRLF; disabling");
@ -427,7 +387,7 @@ GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
} else if (*pConvHA == kConvertHAAuto) { } else if (*pConvHA == kConvertHAAuto) {
if (*pConv == kConvertEOLOn) { if (*pConv == kConvertEOLOn) {
/* definitely converting EOL, test for high ASCII */ /* definitely converting EOL, test for high ASCII */
if (CheckHighASCII((unsigned char*)buf, len)) if (CheckHighASCII((uint8_t*)buf, len))
*pConvHA = kConvertHAOn; *pConvHA = kConvertHAOn;
else else
*pConvHA = kConvertHAOff; *pConvHA = kConvertHAOff;
@ -449,7 +409,7 @@ GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
} else { } else {
ASSERT(*pConv == kConvertEOLOn); ASSERT(*pConv == kConvertEOLOn);
bool lastCR = *pLastCR; bool lastCR = *pLastCR;
unsigned char uch; uint8_t uch;
int mask; int mask;
if (*pConvHA == kConvertHAOn) if (*pConvHA == kConvertHAOn)
@ -486,11 +446,7 @@ GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
* =========================================================================== * ===========================================================================
*/ */
/* void GenericArchive::AddEntry(GenericEntry* pEntry)
* Add a new entry to the end of the list.
*/
void
GenericArchive::AddEntry(GenericEntry* pEntry)
{ {
if (fEntryHead == NULL) { if (fEntryHead == NULL) {
ASSERT(fEntryTail == NULL); ASSERT(fEntryTail == NULL);
@ -516,11 +472,7 @@ GenericArchive::AddEntry(GenericEntry* pEntry)
//} //}
} }
/* void GenericArchive::DeleteEntries(void)
* Delete the "entries" list.
*/
void
GenericArchive::DeleteEntries(void)
{ {
GenericEntry* pEntry; GenericEntry* pEntry;
GenericEntry* pNext; GenericEntry* pNext;
@ -567,20 +519,17 @@ GenericArchive::CreateIndex(void)
} }
#endif #endif
/* /*static*/ CString GenericArchive::GenDerivedTempName(const WCHAR* filename)
* Generate a temp name from a file name.
*
* The key is to come up with the name of a temp file in the same directory
* (or at least on the same disk volume) so that the temp file can be
* renamed on top of the original.
*
* Windows _mktemp does appear to test for the existence of the file, which
* is good. It doesn't actually open the file, which creates a small window
* in which bad things could happen, but it should be okay.
*/
/*static*/ CString
GenericArchive::GenDerivedTempName(const WCHAR* filename)
{ {
/*
* The key is to come up with the name of a temp file in the same directory
* (or at least on the same disk volume) so that the temp file can be
* renamed on top of the original.
*
* Windows _mktemp does appear to test for the existence of the file, which
* is good. It doesn't actually open the file, which creates a small window
* in which bad things could happen, but it should be okay.
*/
static const WCHAR kTmpTemplate[] = L"CPtmp_XXXXXX"; static const WCHAR kTmpTemplate[] = L"CPtmp_XXXXXX";
CString mangle(filename); CString mangle(filename);
int idx, len; int idx, len;
@ -602,23 +551,7 @@ GenericArchive::GenDerivedTempName(const WCHAR* filename)
return mangle; return mangle;
} }
/*static*/ int GenericArchive::ComparePaths(const CString& name1, char fssep1,
/*
* Do a strcasecmp-like comparison, taking equivalent fssep chars into
* account.
*
* The tricky part is with files like "foo:bar" ':' -- "foo:bar" '/'. The
* names appear to match, but the fssep chars are different, so they don't.
* If we just return (char1 - char2), though, we'll be returning 0 because
* the ASCII values match even if the character *meanings* don't.
*
* This assumes that the fssep char is not affected by tolower().
*
* [This may not sort correctly...haven't verified that I'm returning the
* right thing for ascending ASCII sort.]
*/
/*static*/ int
GenericArchive::ComparePaths(const CString& name1, char fssep1,
const CString& name2, char fssep2) const CString& name2, char fssep2)
{ {
const WCHAR* cp1 = name1; const WCHAR* cp1 = name1;
@ -668,11 +601,8 @@ GenericArchive::ComparePaths(const CString& name1, char fssep1,
typedef bool Boolean; typedef bool Boolean;
/* /*static*/ void GenericArchive::UNIXTimeToDateTime(const time_t* pWhen,
* Convert from time in seconds to Apple IIgs DateTime format. NuDateTime* pDateTime)
*/
/*static*/ void
GenericArchive::UNIXTimeToDateTime(const time_t* pWhen, NuDateTime* pDateTime)
{ {
struct tm* ptm; struct tm* ptm;
@ -695,16 +625,7 @@ GenericArchive::UNIXTimeToDateTime(const time_t* pWhen, NuDateTime* pDateTime)
pDateTime->weekDay = ptm->tm_wday +1; pDateTime->weekDay = ptm->tm_wday +1;
} }
NuError GenericArchive::GetFileDetails(const AddFilesDialog* pAddOpts,
/*
* Set the contents of a NuFileDetails structure, based on the pathname
* and characteristics of the file.
*
* For efficiency and simplicity, the pathname fields are set to CStrings in
* the GenericArchive object instead of newly-allocated storage.
*/
NuError
GenericArchive::GetFileDetails(const AddFilesDialog* pAddOpts,
const WCHAR* pathname, struct _stat* psb, FileDetails* pDetails) const WCHAR* pathname, struct _stat* psb, FileDetails* pDetails)
{ {
//char* livePathStr; //char* livePathStr;
@ -809,13 +730,7 @@ typedef struct Win32dirent {
static const WCHAR kWildMatchAll[] = L"*.*"; static const WCHAR kWildMatchAll[] = L"*.*";
/* Win32dirent* GenericArchive::OpenDir(const WCHAR* name)
* Prepare a directory for reading.
*
* Allocates a Win32dirent struct that must be freed by the caller.
*/
Win32dirent*
GenericArchive::OpenDir(const WCHAR* name)
{ {
Win32dirent* dir = NULL; Win32dirent* dir = NULL;
WCHAR* tmpStr = NULL; WCHAR* tmpStr = NULL;
@ -858,13 +773,7 @@ failed:
goto bail; goto bail;
} }
/* Win32dirent* GenericArchive::ReadDir(Win32dirent* dir)
* Get an entry from an open directory.
*
* Returns a NULL pointer after the last entry has been read.
*/
Win32dirent*
GenericArchive::ReadDir(Win32dirent* dir)
{ {
if (dir->d_first) if (dir->d_first)
dir->d_first = 0; dir->d_first = 0;
@ -880,11 +789,7 @@ GenericArchive::ReadDir(Win32dirent* dir)
return dir; return dir;
} }
/* void GenericArchive::CloseDir(Win32dirent* dir)
* Close a directory.
*/
void
GenericArchive::CloseDir(Win32dirent* dir)
{ {
if (dir == NULL) if (dir == NULL)
return; return;
@ -893,13 +798,7 @@ GenericArchive::CloseDir(Win32dirent* dir)
free(dir); free(dir);
} }
/* NuError GenericArchive::Win32AddDirectory(const AddFilesDialog* pAddOpts,
* Win32 recursive directory descent. Scan the contents of a directory.
* If a subdirectory is found, follow it; otherwise, call Win32AddFile to
* add the file.
*/
NuError
GenericArchive::Win32AddDirectory(const AddFilesDialog* pAddOpts,
const WCHAR* dirName, CString* pErrMsg) const WCHAR* dirName, CString* pErrMsg)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -961,15 +860,7 @@ bail:
return err; return err;
} }
/* NuError GenericArchive::Win32AddFile(const AddFilesDialog* pAddOpts,
* Add a file to the list we're adding to the archive. If it's a directory,
* and the recursive descent feature is enabled, call Win32AddDirectory to
* add the contents of the dir.
*
* Returns with an error if the file doesn't exist or isn't readable.
*/
NuError
GenericArchive::Win32AddFile(const AddFilesDialog* pAddOpts,
const WCHAR* pathname, CString* pErrMsg) const WCHAR* pathname, CString* pErrMsg)
{ {
NuError err = kNuErrNone; NuError err = kNuErrNone;
@ -1036,21 +927,10 @@ bail:
return err; return err;
} }
/* NuError GenericArchive::AddFile(const AddFilesDialog* pAddOpts,
* External entry point; just calls the system-specific version. const WCHAR* pathname, CString* pErrMsg)
*
* [ I figure the GS/OS version will want to pass a copy of the file
* info from the GSOSAddDirectory function back into GSOSAddFile, so we'd
* want to call it from here with a NULL pointer indicating that we
* don't yet have the file info. That way we can get the file info
* from the directory read call and won't have to check it again in
* GSOSAddFile. ]
*/
NuError
GenericArchive::AddFile(const AddFilesDialog* pAddOpts, const WCHAR* pathname,
CString* pErrMsg)
{ {
*pErrMsg = ""; *pErrMsg = L"";
return Win32AddFile(pAddOpts, pathname, pErrMsg); return Win32AddFile(pAddOpts, pathname, pErrMsg);
} }
@ -1060,9 +940,6 @@ GenericArchive::AddFile(const AddFilesDialog* pAddOpts, const WCHAR* pathname,
* =========================================================================== * ===========================================================================
*/ */
/*
* Constructor.
*/
GenericArchive::FileDetails::FileDetails(void) GenericArchive::FileDetails::FileDetails(void)
{ {
//threadID = 0; //threadID = 0;
@ -1075,12 +952,6 @@ GenericArchive::FileDetails::FileDetails(void)
memset(&archiveWhen, 0, sizeof(archiveWhen)); memset(&archiveWhen, 0, sizeof(archiveWhen));
} }
/*
* Automatic cast conversion to NuFileDetails.
*
* Note the NuFileDetails will have a string pointing into our storage.
* This is not a good thing, but it's tough to work around.
*/
GenericArchive::FileDetails::operator const NuFileDetails() const GenericArchive::FileDetails::operator const NuFileDetails() const
{ {
NuFileDetails details; NuFileDetails details;
@ -1155,13 +1026,7 @@ GenericArchive::FileDetails::operator const NuFileDetails() const
return details; return details;
} }
/* /*static*/ void GenericArchive::FileDetails::CopyFields(FileDetails* pDst,
* Copy the contents of our object to a new object.
*
* Useful for operator= and copy construction.
*/
/*static*/ void
GenericArchive::FileDetails::CopyFields(FileDetails* pDst,
const FileDetails* pSrc) const FileDetails* pSrc)
{ {
//pDst->threadID = pSrc->threadID; //pDst->threadID = pSrc->threadID;
@ -1186,16 +1051,13 @@ GenericArchive::FileDetails::CopyFields(FileDetails* pDst,
* =========================================================================== * ===========================================================================
*/ */
/* void SelectionSet::CreateFromSelection(ContentList* pContentList, int threadMask)
* Create a selection set from the selected items in a ContentList.
*
* This grabs the items in the order in which they appear in the display
* (at least under Win2K), which is a good thing. It appears that, if you
* just grab indices 0..N, you will get them in order.
*/
void
SelectionSet::CreateFromSelection(ContentList* pContentList, int threadMask)
{ {
/*
* This grabs the items in the order in which they appear in the display
* (at least under Win2K), which is a good thing. It appears that, if you
* just grab indices 0..N, you will get them in order.
*/
LOGI("CreateFromSelection (threadMask=0x%02x)", threadMask); LOGI("CreateFromSelection (threadMask=0x%02x)", threadMask);
POSITION posn; POSITION posn;
@ -1211,11 +1073,7 @@ SelectionSet::CreateFromSelection(ContentList* pContentList, int threadMask)
} }
} }
/* void SelectionSet::CreateFromAll(ContentList* pContentList, int threadMask)
* Like CreateFromSelection, but includes the entire list.
*/
void
SelectionSet::CreateFromAll(ContentList* pContentList, int threadMask)
{ {
LOGI("CreateFromAll (threadMask=0x%02x)", threadMask); LOGI("CreateFromAll (threadMask=0x%02x)", threadMask);
@ -1227,12 +1085,7 @@ SelectionSet::CreateFromAll(ContentList* pContentList, int threadMask)
} }
} }
/* void SelectionSet::AddToSet(GenericEntry* pEntry, int threadMask)
* Add a GenericEntry to the set, but only if we can find a thread that
* matches the flags in "threadMask".
*/
void
SelectionSet::AddToSet(GenericEntry* pEntry, int threadMask)
{ {
SelectionEntry* pSelEntry; SelectionEntry* pSelEntry;
@ -1280,11 +1133,7 @@ SelectionSet::AddToSet(GenericEntry* pEntry, int threadMask)
} }
} }
/* void SelectionSet::AddEntry(SelectionEntry* pEntry)
* Add a new entry to the end of the list.
*/
void
SelectionSet::AddEntry(SelectionEntry* pEntry)
{ {
if (fEntryHead == NULL) { if (fEntryHead == NULL) {
ASSERT(fEntryTail == NULL); ASSERT(fEntryTail == NULL);
@ -1304,11 +1153,7 @@ SelectionSet::AddEntry(SelectionEntry* pEntry)
fNumEntries++; fNumEntries++;
} }
/* void SelectionSet::DeleteEntries(void)
* Delete the "entries" list.
*/
void
SelectionSet::DeleteEntries(void)
{ {
SelectionEntry* pEntry; SelectionEntry* pEntry;
SelectionEntry* pNext; SelectionEntry* pNext;
@ -1323,11 +1168,7 @@ SelectionSet::DeleteEntries(void)
} }
} }
/* int SelectionSet::CountMatchingPrefix(const WCHAR* prefix)
* Count the #of entries whose display name matches the prefix string.
*/
int
SelectionSet::CountMatchingPrefix(const WCHAR* prefix)
{ {
SelectionEntry* pEntry; SelectionEntry* pEntry;
int count = 0; int count = 0;
@ -1346,11 +1187,7 @@ SelectionSet::CountMatchingPrefix(const WCHAR* prefix)
return count; return count;
} }
/* void SelectionSet::Dump(void)
* Dump the contents of a selection set.
*/
void
SelectionSet::Dump(void)
{ {
const SelectionEntry* pEntry; const SelectionEntry* pEntry;

View File

@ -4,7 +4,8 @@
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/* /*
* Generic Apple II archive handling. * Generic Apple II archive handling. In the beginning we only handled
* NuFX archives, and the code continues to reflect that heritage.
* *
* These are abstract base classes. * These are abstract base classes.
*/ */
@ -39,11 +40,11 @@ const int kFileTypeBAS = 0xfc;
* Set of data allowed in file property "set file info" calls. * Set of data allowed in file property "set file info" calls.
*/ */
typedef struct FileProps { typedef struct FileProps {
unsigned long fileType; uint32_t fileType;
unsigned long auxType; uint32_t auxType;
unsigned long access; uint32_t access;
time_t createWhen; time_t createWhen;
time_t modWhen; time_t modWhen;
} FileProps; } FileProps;
/* /*
@ -148,9 +149,34 @@ public:
kFeatureHasInvisibleFlag, kFeatureHasInvisibleFlag,
} Feature; } Feature;
// retrieve thread (or filesystem) data /*
* Extract data from an archive (NuFX, disk image, etc).
*
* If "*ppText" is non-NULL, the data will be read into the pointed-to buffer
* so long as it's shorter than *pLength bytes. The value in "*pLength"
* will be set to the actual length used.
*
* If "*ppText" is NULL, the uncompressed data will be placed into a buffer
* allocated with "new[]".
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pErrMsg" holds an error
* message.
*
* "which" is an anonymous GenericArchive enum (e.g. "kDataThread").
*/
virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength, virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const = 0; CString* pErrMsg) const = 0;
/*
* Extract data from a thread or disk file to a Windows file. Since we're
* not copying to a buffer we can't assume that we're able to hold the
* entire file in memory all at once.
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pMsg" holds an
* error message.
*/
virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv, virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const = 0; ConvertHighASCII convHA, CString* pErrMsg) const = 0;
@ -226,18 +252,48 @@ public:
GenericEntry* GetNext(void) const { return fpNext; } GenericEntry* GetNext(void) const { return fpNext; }
void SetNext(GenericEntry* pEntry) { fpNext = pEntry; } void SetNext(GenericEntry* pEntry) { fpNext = pEntry; }
// Utility functions. /*
* Get a string for this entry's filetype.
*/
const WCHAR* GetFileTypeString(void) const; const WCHAR* GetFileTypeString(void) const;
/*
* Check to see if this is a high-ASCII file.
*/
static bool CheckHighASCII(const uint8_t* buffer, static bool CheckHighASCII(const uint8_t* buffer,
unsigned long count); unsigned long count);
/*
* Decide, based on the contents of the buffer, whether we should do an
* EOL conversion on the data.
*
* Returns kConvEOLOff or kConvEOLOn.
*/
static ConvertEOL DetermineConversion(const uint8_t* buffer, static ConvertEOL DetermineConversion(const uint8_t* buffer,
long count, EOLType* pSourceType, ConvertHighASCII* pConvHA); long count, EOLType* pSourceType, ConvertHighASCII* pConvHA);
/*
* Write data to a file, possibly converting EOL markers to Windows CRLF
* and stripping high ASCII.
*
* If "*pConv" is kConvertEOLAuto, this will try to auto-detect whether
* the input is a text file or not by scanning the input buffer.
*
* Ditto for "*pConvHA".
*
* "fp" is the output file, "buf" is the input, "len" is the buffer length.
* "*pLastCR" should initially be "false", and carried across invocations.
*
* Returns 0 on success, or an errno value on error.
*/
static int GenericEntry::WriteConvert(FILE* fp, const char* buf, static int GenericEntry::WriteConvert(FILE* fp, const char* buf,
size_t len, ConvertEOL* pConv, ConvertHighASCII* pConvHA, size_t len, ConvertEOL* pConv, ConvertHighASCII* pConvHA,
bool* pLastCR); bool* pLastCR);
protected: protected:
/*
* Convert spaces to underscores, modifying the string.
*/
static void SpacesToUnderscores(WCHAR* buf); static void SpacesToUnderscores(WCHAR* buf);
private: private:
@ -303,12 +359,6 @@ public:
virtual long GetNumEntries(void) const { virtual long GetNumEntries(void) const {
return fNumEntries; return fNumEntries;
} }
//virtual GenericEntry* GetEntry(long num) {
// ASSERT(num >= 0 && num < fNumEntries);
// if (fEntryIndex == NULL)
// CreateIndex();
// return fEntryIndex[num];
//}
typedef enum { typedef enum {
kResultUnknown = 0, kResultUnknown = 0,
@ -353,10 +403,12 @@ public:
// Do a bulk add. // Do a bulk add.
virtual bool BulkAdd(ActionProgressDialog* pActionProgress, virtual bool BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) = 0; const AddFilesDialog* pAddOpts) = 0;
// Do a disk add.
// Add a single disk to the archive.
virtual bool AddDisk(ActionProgressDialog* pActionProgress, virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) = 0; const AddFilesDialog* pAddOpts) = 0;
// Create a subdirectory.
// Create a subdirectory with name newName in pParentEntry.
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry, virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName) = 0; const WCHAR* newName) = 0;
@ -368,6 +420,13 @@ public:
// Rename a set of files. // Rename a set of files.
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) = 0; virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) = 0;
// Verify that a name is suitable. Called by RenameEntryDialog and
// CreateSubdirDialog.
//
// Tests for context-specific syntax and checks for duplicates.
//
// Returns an empty string on success, or an error message on failure.
virtual CString TestPathName(const GenericEntry* pGenericEntry, virtual CString TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const = 0; const CString& basePath, const CString& newName, char newFssep) const = 0;
@ -381,26 +440,33 @@ public:
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts) = 0; const RecompressOptionsDialog* pRecompOpts) = 0;
// Transfer files out of this archive and into another. // return result from XferSelection()
typedef enum { typedef enum {
kXferOK = 0, kXferFailed = 1, kXferCancelled = 2, kXferOutOfSpace = 3 kXferOK = 0, kXferFailed = 1, kXferCancelled = 2, kXferOutOfSpace = 3
} XferStatus; } XferStatus;
// Transfer selected files out of this archive and into another.
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, ActionProgressDialog* pActionProgress,
const XferFileOptions* pXferOpts) = 0; const XferFileOptions* pXferOpts) = 0;
// Get, set, or delete the comment on an entry. // Extract a comment from the archive, converting line terminators to CRLF.
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry, virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr) = 0; CString* pStr) = 0;
// Set a comment on an entry.
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str) = 0; const CString& str) = 0;
// Delete the comment from the entry.
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) = 0; virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) = 0;
// Set ProDOS file properties (e.g. file type, access flags). // Set ProDOS file properties (file type, aux type, access flags).
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps) = 0; const FileProps* pProps) = 0;
// Preferences have changed, update library state as needed. // Preferences have changed, update library state as needed. Also called
// the first time though.
virtual void PreferencesChanged(void) = 0; virtual void PreferencesChanged(void) = 0;
// Determine an archive's capabilities. This is specific to the object // Determine an archive's capabilities. This is specific to the object
@ -422,11 +488,31 @@ public:
// Get the pathname of the file we opened. // Get the pathname of the file we opened.
const WCHAR* GetPathName(void) const { return fPathName; } const WCHAR* GetPathName(void) const { return fPathName; }
// Generic utility function. /*
* Generate a temp name from a file name.
*/
static CString GenDerivedTempName(const WCHAR* filename); static CString GenDerivedTempName(const WCHAR* filename);
/*
* Do a strcasecmp-like comparison, taking equivalent fssep chars into
* account.
*
* The tricky part is with files like "foo:bar" ':' -- "foo:bar" '/'. The
* names appear to match, but the fssep chars are different, so they don't.
* If we just return (char1 - char2), though, we'll be returning 0 because
* the ASCII values match even if the character *meanings* don't.
*
* This assumes that the fssep char is not affected by tolower().
*
* [This may not sort correctly...haven't verified that I'm returning the
* right thing for ascending ASCII sort.]
*/
static int ComparePaths(const CString& name1, char fssep1, static int ComparePaths(const CString& name1, char fssep1,
const CString& name2, char fssep2); const CString& name2, char fssep2);
/*
* Add a new entry to the end of the list.
*/
void AddEntry(GenericEntry* pEntry); void AddEntry(GenericEntry* pEntry);
/* /*
@ -505,41 +591,108 @@ public:
//NuFileSysID fileSysID; //NuFileSysID fileSysID;
DiskImg::FSFormat fileSysFmt; DiskImg::FSFormat fileSysFmt;
unsigned short fileSysInfo; /* fssep lurks here */ uint16_t fileSysInfo; /* fssep lurks here */
unsigned long access; uint32_t access;
unsigned long fileType; uint32_t fileType;
unsigned long extraType; uint32_t extraType;
unsigned short storageType; /* "Unknown" or disk block size */ uint16_t storageType; /* "Unknown" or disk block size */
NuDateTime createWhen; NuDateTime createWhen;
NuDateTime modWhen; NuDateTime modWhen;
NuDateTime archiveWhen; NuDateTime archiveWhen;
private: private:
/*
* Copy the contents of our object to a new object.
*
* Useful for operator= and copy construction.
*/
static void CopyFields(FileDetails* pDst, const FileDetails* pSrc); static void CopyFields(FileDetails* pDst, const FileDetails* pSrc);
}; };
// Transfer files, one at a time, into this archive from another. // Prepare for file transfers.
virtual void XferPrepare(const XferFileOptions* pXferOpts) = 0; virtual void XferPrepare(const XferFileOptions* pXferOpts) = 0;
// Transfer files, one at a time, into this archive from another. Called
// from XferSelection and clipboard "paste".
//
// "dataLen" and "rsrcLen" will be -1 if the corresponding fork doesn't exist.
// Returns 0 on success, nonzero on failure.
//
// On success, *pDataBuf and *pRsrcBuf are freed and set to NULL. (It's
// necessary for the interface to work this way because the NufxArchive
// version just tucks the pointers into NufxLib structures.)
virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf, virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen) = 0; long dataLen, uint8_t** pRsrcBuf, long rsrcLen) = 0;
// Abort progress. Not all subclasses are capable of "undo".
virtual void XferAbort(CWnd* pMsgWnd) = 0; virtual void XferAbort(CWnd* pMsgWnd) = 0;
// Transfer is finished.
virtual void XferFinish(CWnd* pMsgWnd) = 0; virtual void XferFinish(CWnd* pMsgWnd) = 0;
/*
* Convert from time in seconds to Apple IIgs DateTime format.
*/
static void UNIXTimeToDateTime(const time_t* pWhen, NuDateTime *pDateTime); static void UNIXTimeToDateTime(const time_t* pWhen, NuDateTime *pDateTime);
protected: protected:
/*
* Delete the "entries" list.
*/
virtual void DeleteEntries(void); virtual void DeleteEntries(void);
/* NuLib2-derived recursive directory add functions */
void ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst); void ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst);
/*
* Set the contents of a NuFileDetails structure, based on the pathname
* and characteristics of the file.
*
* For efficiency and simplicity, the pathname fields are set to CStrings in
* the GenericArchive object instead of newly-allocated storage.
*/
NuError GetFileDetails(const AddFilesDialog* pAddOpts, const WCHAR* pathname, NuError GetFileDetails(const AddFilesDialog* pAddOpts, const WCHAR* pathname,
struct _stat* psb, FileDetails* pDetails); struct _stat* psb, FileDetails* pDetails);
/*
* Prepare a directory for reading.
*
* Allocates a Win32dirent struct that must be freed by the caller.
*/
Win32dirent* OpenDir(const WCHAR* name); Win32dirent* OpenDir(const WCHAR* name);
/*
* Get an entry from an open directory.
*
* Returns a NULL pointer after the last entry has been read.
*/
Win32dirent* ReadDir(Win32dirent* dir); Win32dirent* ReadDir(Win32dirent* dir);
/*
* Close a directory.
*/
void CloseDir(Win32dirent* dir); void CloseDir(Win32dirent* dir);
/*
* Win32 recursive directory descent. Scan the contents of a directory.
* If a subdirectory is found, follow it; otherwise, call Win32AddFile to
* add the file.
*/
NuError Win32AddDirectory(const AddFilesDialog* pAddOpts, NuError Win32AddDirectory(const AddFilesDialog* pAddOpts,
const WCHAR* dirName, CString* pErrMsg); const WCHAR* dirName, CString* pErrMsg);
/*
* Add a file to the list we're adding to the archive. If it's a directory,
* and the recursive descent feature is enabled, call Win32AddDirectory to
* add the contents of the dir.
*
* Returns with an error if the file doesn't exist or isn't readable.
*/
NuError Win32AddFile(const AddFilesDialog* pAddOpts, NuError Win32AddFile(const AddFilesDialog* pAddOpts,
const WCHAR* pathname, CString* pErrMsg); const WCHAR* pathname, CString* pErrMsg);
/*
* External entry point; just calls the system-specific version.
*/
NuError AddFile(const AddFilesDialog* pAddOpts, const WCHAR* pathname, NuError AddFile(const AddFilesDialog* pAddOpts, const WCHAR* pathname,
CString* pErrMsg); CString* pErrMsg);
@ -687,13 +840,24 @@ public:
// count the #of entries whose display name matches "prefix" // count the #of entries whose display name matches "prefix"
int CountMatchingPrefix(const WCHAR* prefix); int CountMatchingPrefix(const WCHAR* prefix);
// debug dump // debug dump the contents of the selection set
void Dump(void); void Dump(void);
private: private:
/*
* Add a GenericEntry to the set, but only if we can find a thread that
* matches the flags in "threadMask".
*/
void AddToSet(GenericEntry* pEntry, int threadMask); void AddToSet(GenericEntry* pEntry, int threadMask);
/*
* Add a new entry to the end of the list.
*/
void AddEntry(SelectionEntry* pEntry); void AddEntry(SelectionEntry* pEntry);
/*
* Delete the "entries" list.
*/
void DeleteEntries(void); void DeleteEntries(void);
int fNumEntries; int fNumEntries;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Implementation of ImageFormatDialog class.
*/
#include "stdafx.h" #include "stdafx.h"
#include "ImageFormatDialog.h" #include "ImageFormatDialog.h"
#include "HelpTopics.h" #include "HelpTopics.h"
@ -111,11 +108,7 @@ static const ConvTable gFSFormats[] = {
}; };
/* void ImageFormatDialog::InitializeValues(const DiskImg* pImg)
* Initialize our members by querying the associated DiskImg.
*/
void
ImageFormatDialog::InitializeValues(const DiskImg* pImg)
{ {
fOuterFormat = pImg->GetOuterFormat(); fOuterFormat = pImg->GetOuterFormat();
fFileFormat = pImg->GetFileFormat(); fFileFormat = pImg->GetFileFormat();
@ -141,12 +134,7 @@ ImageFormatDialog::InitializeValues(const DiskImg* pImg)
fInitialized = true; fInitialized = true;
} }
BOOL ImageFormatDialog::OnInitDialog(void)
/*
* Configure the combo boxes.
*/
BOOL
ImageFormatDialog::OnInitDialog(void)
{ {
ASSERT(fInitialized); ASSERT(fInitialized);
@ -155,15 +143,7 @@ ImageFormatDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); // do DDX/DDV return CDialog::OnInitDialog(); // do DDX/DDV
} }
/* void ImageFormatDialog::LoadComboBoxes(void)
* Load the combo boxes with every possible entry, and set the current
* value appropriately.
*
* While we're at it, initialize the "source" edit text box and the
* "show as blocks" checkbox.
*/
void
ImageFormatDialog::LoadComboBoxes(void)
{ {
CWnd* pWnd; CWnd* pWnd;
CButton* pButton; CButton* pButton;
@ -209,12 +189,8 @@ ImageFormatDialog::LoadComboBoxes(void)
LoadComboBox(IDC_DECONF_FSFORMAT, gFSFormats, fFSFormat); LoadComboBox(IDC_DECONF_FSFORMAT, gFSFormats, fFSFormat);
} }
/* void ImageFormatDialog::LoadComboBox(int boxID, const ConvTable* pTable,
* Load the strings from ConvTable into the combo box, setting the int dflt)
* entry matching "default" as the current entry.
*/
void
ImageFormatDialog::LoadComboBox(int boxID, const ConvTable* pTable, int dflt)
{ {
CComboBox* pCombo; CComboBox* pCombo;
// const ConvTable* pBaseTable = pTable; // const ConvTable* pBaseTable = pTable;
@ -251,14 +227,9 @@ ImageFormatDialog::LoadComboBox(int boxID, const ConvTable* pTable, int dflt)
} else { } else {
LOGI(" No matching default for %d (%d)", boxID, dflt); LOGI(" No matching default for %d (%d)", boxID, dflt);
} }
} }
/* int ImageFormatDialog::ConvComboSel(int boxID, const ConvTable* pTable)
* Find the enum value for the specified index.
*/
int
ImageFormatDialog::ConvComboSel(int boxID, const ConvTable* pTable)
{ {
CComboBox* pCombo; CComboBox* pCombo;
int idx, enumval; int idx, enumval;
@ -287,12 +258,7 @@ ImageFormatDialog::ConvComboSel(int boxID, const ConvTable* pTable)
return enumval; return enumval;
} }
/* void ImageFormatDialog::OnOK(void)
* Handle the "OK" button by extracting values from the dialog and
* verifying that reasonable settings are in place.
*/
void
ImageFormatDialog::OnOK(void)
{ {
CButton* pButton; CButton* pButton;
@ -338,22 +304,13 @@ ImageFormatDialog::OnOK(void)
CDialog::OnOK(); CDialog::OnOK();
} }
/* BOOL ImageFormatDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* F1 key hit, or '?' button in title bar used to select help for an
* item in the dialog.
*/
BOOL
ImageFormatDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp(lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp(lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // indicate success?? return TRUE; // indicate success??
} }
/* void ImageFormatDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
ImageFormatDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_DISK_IMAGES, HELP_CONTEXT); WinHelp(HELP_TOPIC_DISK_IMAGES, HELP_CONTEXT);
} }

View File

@ -3,18 +3,16 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Dialog asking the user to confirm certain details of a disk image.
*/
#ifndef APP_IMAGEFORMATDIALOG_H #ifndef APP_IMAGEFORMATDIALOG_H
#define APP_IMAGEFORMATDIALOG_H #define APP_IMAGEFORMATDIALOG_H
//#include <afxwin.h>
#include "resource.h" #include "resource.h"
#include "../diskimg/DiskImg.h" #include "../diskimg/DiskImg.h"
using namespace DiskImgLib; using namespace DiskImgLib;
/* /*
* Dialog asking the user to confirm certain details of a disk image.
*
* The default values can be initialized individually or from a prepped * The default values can be initialized individually or from a prepped
* DiskImg structure. * DiskImg structure.
*/ */
@ -38,7 +36,9 @@ public:
fHasSectors = fHasBlocks = fHasNibbles = false; fHasSectors = fHasBlocks = fHasNibbles = false;
} }
// initialize values from a DiskImg /*
* Initialize our members by querying the associated DiskImg.
*/
void InitializeValues(const DiskImg* pImg); void InitializeValues(const DiskImg* pImg);
bool fInitialized; bool fInitialized;
@ -58,15 +58,37 @@ public:
void SetAllowGenericFormats(bool val) { fAllowGenericFormats = val; } void SetAllowGenericFormats(bool val) { fAllowGenericFormats = val; }
protected: protected:
//virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void);
void OnOK(void); /*
* Handle the "OK" button by extracting values from the dialog and
* verifying that reasonable settings are in place.
*/
void OnOK(void) override;
afx_msg virtual void OnHelp(void); afx_msg virtual void OnHelp(void);
afx_msg virtual BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg virtual BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
struct ConvTable; struct ConvTable;
/*
* Load the combo boxes with every possible entry, and set the current
* value appropriately.
*
* While we're at it, initialize the "source" edit text box and the
* "show as blocks" checkbox.
*/
void LoadComboBoxes(void); void LoadComboBoxes(void);
/*
* Load the strings from ConvTable into the combo box, setting the
* entry matching "default" as the current entry.
*/
void LoadComboBox(int boxID, const ConvTable* pTable, int dflt); void LoadComboBox(int boxID, const ConvTable* pTable, int dflt);
/*
* Find the enum value for the specified index.
*/
int ConvComboSel(int boxID, const ConvTable* pTable); int ConvComboSel(int boxID, const ConvTable* pTable);
bool fQueryDisplayFormat; bool fQueryDisplayFormat;

File diff suppressed because it is too large Load Diff

View File

@ -44,9 +44,17 @@ public:
MainWindow(void); MainWindow(void);
~MainWindow(void); ~MainWindow(void);
// Overridden functions /*
BOOL PreCreateWindow(CREATESTRUCT& cs); * Override the pre-create function to tweak the window style.
//BOOL OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext ); */
BOOL PreCreateWindow(CREATESTRUCT& cs) override;
/*
* Override GetClientRect so we can factor in the status and tool bars.
*
* (The method in question isn't declared virtual, so we're not actually
* overriding it.)
*/
void GetClientRect(LPRECT lpRect) const; void GetClientRect(LPRECT lpRect) const;
// get a pointer to the preferences // get a pointer to the preferences
@ -65,22 +73,50 @@ public:
const WCHAR* newName); const WCHAR* newName);
void SetProgressEnd(void); void SetProgressEnd(void);
// update the progress counter /*
* Set a number in the "progress counter". Useful for loading large archives
* where we're not sure how much stuff is left, so showing a percentage is
* hard.
*
* Pass in -1 to erase the counter.
*
* Returns "true" if we'd like things to continue.
*/
bool SetProgressCounter(const WCHAR* fmt, long val); bool SetProgressCounter(const WCHAR* fmt, long val);
// handle a double-click in the content view /*
* Handle a double-click in the content view.
*
* Individual items get special treatment, multiple items just get handed off
* to the file viewer.
*/
void HandleDoubleClick(void); void HandleDoubleClick(void);
// do some idle processing // do some idle processing
void DoIdle(void); void DoIdle(void);
// return the title to put at the top of a printout /*
* Come up with a title to put at the top of a printout. This is essentially
* the same as the window title, but without some flags (e.g. "read-only").
*/
CString GetPrintTitle(void); CString GetPrintTitle(void);
// raise flag to abort the current print job // raise flag to abort the current print job
void SetAbortPrinting(bool val) { fAbortPrinting = val; } void SetAbortPrinting(bool val) { fAbortPrinting = val; }
bool GetAbortPrinting(void) const { return fAbortPrinting; } bool GetAbortPrinting(void) const { return fAbortPrinting; }
/*
* Printer abort procedure; allows us to abort a print job. The DC
* SetAbortProc() function calls here periodically. The return value from
* this function determine whether or not printing halts.
*
* This checks a global "print cancel" variable, which is set by our print
* cancel button dialog.
*
* If this returns TRUE, printing continues; FALSE, and printing aborts.
*/
static BOOL CALLBACK PrintAbortProc(HDC hDC, int nCode); static BOOL CALLBACK PrintAbortProc(HDC hDC, int nCode);
bool fAbortPrinting; bool fAbortPrinting;
// track printer choice // track printer choice
HANDLE fhDevMode; HANDLE fhDevMode;
@ -90,7 +126,10 @@ public:
//void SetAbortOperation(bool val) { fAbortOperation = val; } //void SetAbortOperation(bool val) { fAbortOperation = val; }
//bool fAbortOperation; //bool fAbortOperation;
// pause, for debugging /*
* Go to sleep for a little bit, waking up 100x per second to check
* the idle loop. Used for debugging.
*/
void EventPause(int duration); void EventPause(int duration);
ContentList* GetContentList(void) const { return fpContentList; } ContentList* GetContentList(void) const { return fpContentList; }
@ -103,41 +142,103 @@ public:
} }
GenericArchive* GetOpenArchive(void) const { return fpOpenArchive; } GenericArchive* GetOpenArchive(void) const { return fpOpenArchive; }
/*
* Extract every part of the file into "ReformatHolder". Does not try to
* reformat anything, just extracts the parts.
*
* Returns IDOK on success, IDCANCEL if the user cancelled, or -1 on error.
* On error, the reformatted text buffer gets the error message.
*/
int GetFileParts(const GenericEntry* pEntry, int GetFileParts(const GenericEntry* pEntry,
ReformatHolder** ppHolder) const; ReformatHolder** ppHolder) const;
// force processing of pending messages /*
* Allow events to flow through the message queue whenever the
* progress meter gets updated. This will allow us to redraw with
* reasonable frequency.
*
* Calling this can result in other code being called, such as Windows
* message handlers, which can lead to reentrancy problems. Make sure
* you're adequately semaphored before calling here.
*
* Returns TRUE if all is well, FALSE if we're trying to quit.
*/
BOOL PeekAndPump(); BOOL PeekAndPump();
// make a happy noise after successful execution of a command /*
* After successful completion of a command, make a happy noise (but only
* if we're configured to do so).
*/
void SuccessBeep(void); void SuccessBeep(void);
// make a not-so-happy noise
/*
* If something fails, make noise if we're configured for loudness.
*/
void FailureBeep(void); void FailureBeep(void);
// remove a file, returning a helpful message on failure /*
* Remove a file. Returns a helpful error string on failure.
*
* The absence of the file is not considered an error.
*/
CString RemoveFile(const WCHAR* fileName); CString RemoveFile(const WCHAR* fileName);
// choose the place to put a file /*
* Figure out where they want to add files.
*
* If the volume directory of a disk is chosen, *ppTargetSubdir will
* be set to NULL.
*/
bool ChooseAddTarget(DiskImgLib::A2File** ppTargetSubdir, bool ChooseAddTarget(DiskImgLib::A2File** ppTargetSubdir,
DiskImgLib::DiskFS** ppDiskFS); DiskImgLib::DiskFS** ppDiskFS);
// try a disk image override dialog /*
* Put up the ImageFormatDialog and apply changes to "pImg".
*
* "*pDisplayFormat" gets the result of user changes to the display format.
* If "pDisplayFormat" is NULL, the "query image format" feature will be
* disabled.
*
* Returns IDCANCEL if the user cancelled out of the dialog, IDOK otherwise.
* On error, "*pErrMsg" will be non-empty.
*/
int TryDiskImgOverride(DiskImg* pImg, const WCHAR* fileSource, int TryDiskImgOverride(DiskImg* pImg, const WCHAR* fileSource,
DiskImg::FSFormat defaultFormat, int* pDisplayFormat, DiskImg::FSFormat defaultFormat, int* pDisplayFormat,
bool allowUnknown, CString* pErrMsg); bool allowUnknown, CString* pErrMsg);
// copy all blocks from one disk image to another
/*
* Do a block copy or track copy from one disk image to another.
*
* If "bulk" is set, warning dialogs are suppressed. If "partial" is set,
* copies between volumes of different sizes are allowed.
*/
DIError CopyDiskImage(DiskImg* pDstImg, DiskImg* pSrcImg, bool bulk, DIError CopyDiskImage(DiskImg* pDstImg, DiskImg* pSrcImg, bool bulk,
bool partial, ProgressCancelDialog* pPCDialog); bool partial, ProgressCancelDialog* pPCDialog);
// does the currently open archive pathname match? // Determine whether path matches the pathname of the currently open archive.
bool IsOpenPathName(const WCHAR* path); bool IsOpenPathName(const WCHAR* path);
// raise a flag to cause a full reload of the open file // raise a flag to cause a full reload of the open file
void SetReopenFlag(void) { fNeedReopen = true; } void SetReopenFlag(void) { fNeedReopen = true; }
/*
* Configure a ReformatHolder based on the current preferences.
*/
static void ConfigureReformatFromPreferences(ReformatHolder* pReformat); static void ConfigureReformatFromPreferences(ReformatHolder* pReformat);
/*
* Convert a DiskImg format spec into a ReformatHolder SourceFormat.
*/
static ReformatHolder::SourceFormat ReformatterSourceFormat(DiskImg::FSFormat format); static ReformatHolder::SourceFormat ReformatterSourceFormat(DiskImg::FSFormat format);
// save a buffer of data as a file in a disk image or file archive /*
* Saves a buffer of data as a file in a disk image or file archive.
* Utility function used by cassette import.
*
* May modify contents of *pDetails.
*
* On failure, returns with an error message in errMsg.
*/
static bool SaveToArchive(GenericArchive::FileDetails* pDetails, static bool SaveToArchive(GenericArchive::FileDetails* pDetails,
const uint8_t* dataBuf, long dataLen, const uint8_t* dataBuf, long dataLen,
const uint8_t* rsrcBuf, long rsrcLen, const uint8_t* rsrcBuf, long rsrcLen,
@ -159,17 +260,14 @@ private:
// Command handlers // Command handlers
afx_msg int OnCreate(LPCREATESTRUCT lpcs); afx_msg int OnCreate(LPCREATESTRUCT lpcs);
afx_msg LONG OnLateInit(UINT, LONG); afx_msg LONG OnLateInit(UINT, LONG);
//afx_msg LONG OnCloseMainDialog(UINT, LONG);
afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI); afx_msg void OnGetMinMaxInfo(MINMAXINFO* pMMI);
afx_msg void OnPaint(void); afx_msg void OnPaint(void);
//afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg BOOL OnQueryEndSession(void); afx_msg BOOL OnQueryEndSession(void);
afx_msg void OnEndSession(BOOL bEnding); afx_msg void OnEndSession(BOOL bEnding);
afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
//afx_msg LONG OnHelp(UINT wParam, LONG lParam);
afx_msg void OnFileNewArchive(void); afx_msg void OnFileNewArchive(void);
afx_msg void OnFileOpen(void); afx_msg void OnFileOpen(void);
afx_msg void OnFileOpenVolume(void); afx_msg void OnFileOpenVolume(void);
@ -185,12 +283,26 @@ private:
afx_msg void OnFilePrint(void); afx_msg void OnFilePrint(void);
afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI); afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
afx_msg void OnFileExit(void); afx_msg void OnFileExit(void);
/*
* Copy data to the clipboard.
*/
afx_msg void OnEditCopy(void); afx_msg void OnEditCopy(void);
afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI); afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
/*
* Paste data from the clipboard, using the configured defaults.
*/
afx_msg void OnEditPaste(void); afx_msg void OnEditPaste(void);
afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI); afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
/*
* Paste data from the clipboard, giving the user the opportunity to select
* how the files are handled.
*/
afx_msg void OnEditPasteSpecial(void); afx_msg void OnEditPasteSpecial(void);
afx_msg void OnUpdateEditPasteSpecial(CCmdUI* pCmdUI); afx_msg void OnUpdateEditPasteSpecial(CCmdUI* pCmdUI);
afx_msg void OnEditFind(void); afx_msg void OnEditFind(void);
afx_msg void OnUpdateEditFind(CCmdUI* pCmdUI); afx_msg void OnUpdateEditFind(CCmdUI* pCmdUI);
afx_msg void OnEditSelectAll(void); afx_msg void OnEditSelectAll(void);
@ -200,50 +312,157 @@ private:
afx_msg void OnEditPreferences(void); afx_msg void OnEditPreferences(void);
afx_msg void OnEditSort(UINT id); afx_msg void OnEditSort(UINT id);
afx_msg void OnUpdateEditSort(CCmdUI* pCmdUI); afx_msg void OnUpdateEditSort(CCmdUI* pCmdUI);
/*
* View a file stored in the archive.
*
* Control bounces back through Get*FileText() to get the actual
* data to view.
*/
afx_msg void OnActionsView(void); afx_msg void OnActionsView(void);
afx_msg void OnUpdateActionsView(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsView(CCmdUI* pCmdUI);
/*
* View a file stored in the archive.
*
* Control bounces back through Get*FileText() to get the actual
* data to view.
*/
afx_msg void OnActionsOpenAsDisk(void); afx_msg void OnActionsOpenAsDisk(void);
afx_msg void OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI);
/*
* Add files to an archive.
*/
afx_msg void OnActionsAddFiles(void); afx_msg void OnActionsAddFiles(void);
afx_msg void OnUpdateActionsAddFiles(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsAddFiles(CCmdUI* pCmdUI);
/*
* Add a disk to an archive. Not all archive formats support disk images.
*
* We open a single disk archive file as a DiskImg, get the format
* figured out, then write it block-by-block into a file chosen by the user.
* Standard open/save dialogs work fine here.
*/
afx_msg void OnActionsAddDisks(void); afx_msg void OnActionsAddDisks(void);
afx_msg void OnUpdateActionsAddDisks(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsAddDisks(CCmdUI* pCmdUI);
/*
* Create a subdirectory inside another subdirectory (or volume directory).
*
* Simply asserting that an existing subdir be selected in the list does
* away with all sorts of testing. Creating subdirs on DOS disks and NuFX
* archives is impossible because neither has subdirs. Nested volumes are
* selected for us by the user.
*/
afx_msg void OnActionsCreateSubdir(void); afx_msg void OnActionsCreateSubdir(void);
afx_msg void OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI);
/*
* Extract files.
*/
afx_msg void OnActionsExtract(void); afx_msg void OnActionsExtract(void);
afx_msg void OnUpdateActionsExtract(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsExtract(CCmdUI* pCmdUI);
/*
* Test files.
*/
afx_msg void OnActionsTest(void); afx_msg void OnActionsTest(void);
afx_msg void OnUpdateActionsTest(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsTest(CCmdUI* pCmdUI);
/*
* Delete archive entries.
*/
afx_msg void OnActionsDelete(void); afx_msg void OnActionsDelete(void);
afx_msg void OnUpdateActionsDelete(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsDelete(CCmdUI* pCmdUI);
/*
* Rename archive entries. Depending on the structure of the underlying
* archive, we may only allow the user to alter the filename component.
* Anything else would constitute moving the file around in the filesystem.
*/
afx_msg void OnActionsRename(void); afx_msg void OnActionsRename(void);
afx_msg void OnUpdateActionsRename(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsRename(CCmdUI* pCmdUI);
/*
* Edit a comment, creating it if necessary.
*/
afx_msg void OnActionsEditComment(void); afx_msg void OnActionsEditComment(void);
afx_msg void OnUpdateActionsEditComment(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsEditComment(CCmdUI* pCmdUI);
/*
* Edit file properties.
*
* This causes a reload of the list, which isn't really necessary. We
* do need to re-evaluate the sort order if one of the fields they modified
* is the current sort key, but it would be nice if we could at least retain
* the selection. Since we're not reloading the GenericArchive, we *can*
* remember the selection.
*/
afx_msg void OnActionsEditProps(void); afx_msg void OnActionsEditProps(void);
afx_msg void OnUpdateActionsEditProps(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsEditProps(CCmdUI* pCmdUI);
/*
* Change a volume name or volume number.
*/
afx_msg void OnActionsRenameVolume(void); afx_msg void OnActionsRenameVolume(void);
afx_msg void OnUpdateActionsRenameVolume(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsRenameVolume(CCmdUI* pCmdUI);
/*
* Recompress files.
*/
afx_msg void OnActionsRecompress(void); afx_msg void OnActionsRecompress(void);
afx_msg void OnUpdateActionsRecompress(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsRecompress(CCmdUI* pCmdUI);
/*
* Select files to convert.
*/
afx_msg void OnActionsConvDisk(void); afx_msg void OnActionsConvDisk(void);
afx_msg void OnUpdateActionsConvDisk(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsConvDisk(CCmdUI* pCmdUI);
/*
* Select files to convert.
*/
afx_msg void OnActionsConvFile(void); afx_msg void OnActionsConvFile(void);
afx_msg void OnUpdateActionsConvFile(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsConvFile(CCmdUI* pCmdUI);
/*
* Convert BAS, INT, or BIN to a cassette-audio WAV file.
* (not implemented)
*/
afx_msg void OnActionsConvToWav(void); afx_msg void OnActionsConvToWav(void);
afx_msg void OnUpdateActionsConvToWav(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsConvToWav(CCmdUI* pCmdUI);
/*
* Convert a WAV file with a digitized Apple II cassette tape into an
* Apple II file, and add it to the current disk.
*/
afx_msg void OnActionsConvFromWav(void); afx_msg void OnActionsConvFromWav(void);
afx_msg void OnUpdateActionsConvFromWav(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsConvFromWav(CCmdUI* pCmdUI);
/*
* Import an Applesoft BASIC program from a text file.
*
* We currently allow the user to select a single file for import. Someday
* we may want to allow multi-file import.
*/
afx_msg void OnActionsImportBAS(void); afx_msg void OnActionsImportBAS(void);
afx_msg void OnUpdateActionsImportBAS(CCmdUI* pCmdUI); afx_msg void OnUpdateActionsImportBAS(CCmdUI* pCmdUI);
// edit a disk
afx_msg void OnToolsDiskEdit(void); afx_msg void OnToolsDiskEdit(void);
// convert a disk image from one format to another
afx_msg void OnToolsDiskConv(void); afx_msg void OnToolsDiskConv(void);
// bulk disk conversion
afx_msg void OnToolsBulkDiskConv(void); afx_msg void OnToolsBulkDiskConv(void);
// merge two SST images into a single NIB image
afx_msg void OnToolsSSTMerge(void); afx_msg void OnToolsSSTMerge(void);
afx_msg void OnToolsVolumeCopierVolume(void); afx_msg void OnToolsVolumeCopierVolume(void);
afx_msg void OnToolsVolumeCopierFile(void); afx_msg void OnToolsVolumeCopierFile(void);
// scan and report on the end-of-line markers found in a file
afx_msg void OnToolsEOLScanner(void); afx_msg void OnToolsEOLScanner(void);
// edit the properties (but not the disk image inside) a .2MG disk image
afx_msg void OnToolsTwoImgProps(void); afx_msg void OnToolsTwoImgProps(void);
// create a new disk image
afx_msg void OnToolsDiskImageCreator(void); afx_msg void OnToolsDiskImageCreator(void);
afx_msg void OnHelpContents(void); afx_msg void OnHelpContents(void);
afx_msg void OnHelpWebSite(void); afx_msg void OnHelpWebSite(void);
@ -251,83 +470,352 @@ private:
afx_msg void OnHelpAbout(void); afx_msg void OnHelpAbout(void);
afx_msg void OnRtClkDefault(void); afx_msg void OnRtClkDefault(void);
// Handle command-line arguments.
void ProcessCommandLine(void); void ProcessCommandLine(void);
void ResizeClientArea(void); void ResizeClientArea(void);
/*
* Draw what looks like an empty client area.
*/
void DrawEmptyClientArea(CDC* pDC, const CRect& clientRect); void DrawEmptyClientArea(CDC* pDC, const CRect& clientRect);
/*
* Extract a record to the temp folder and open it with a new instance of
* CiderPress. We might want to extract disk images as 2MG files to take
* the mystery out of opening them, but since they're coming out of a
* ShrinkIt archive they're pretty un-mysterious anyway.
*
* We tell the new instance to open it read-only, and flag it for
* deletion on exit.
*
* Returns 0 on success, nonzero error status on failure.
*/
int TmpExtractAndOpen(GenericEntry* pEntry, int threadKind, int TmpExtractAndOpen(GenericEntry* pEntry, int threadKind,
const WCHAR* modeStr); const WCHAR* modeStr);
/*
* Extract a record to the temp folder and open it with an external viewer.
* The file must be created with the correct extension so ShellExecute
* does the right thing.
*
* The files will be added to the "delete on exit" list, so that they will
* be cleaned up when CiderPress exits (assuming the external viewer no longer
* has them open).
*
* The GetTempFileName function creates a uniquely-named temp file. We
* create a file that has that name plus an extension. To ensure that we
* don't try to use the same temp filename twice, we have to hold off on
* deleting the unused .tmp files until we're ready to delete the
* corresponding .gif (or whatever) files. Thus, each invocation of this
* function creates two files and two entries in the delete-on-exit set.
*
* Returns 0 on success, nonzero error status on failure.
*/
int TmpExtractForExternal(GenericEntry* pEntry); int TmpExtractForExternal(GenericEntry* pEntry);
void DoOpenArchive(const WCHAR* pathName, const WCHAR* ext, void DoOpenArchive(const WCHAR* pathName, const WCHAR* ext,
int filterIndex, bool readOnly); int filterIndex, bool readOnly);
/*
* Load an archive, using the appropriate GenericArchive subclass. If
* "createFile" is "true", a new archive file will be created (and must
* not already exist!).
*
* "filename" is the full path to the file, "extension" is the
* filetype component of the name (without the leading '.'), "filterIndex"
* is the offset into the set of filename filters used in the standard
* file dialog, "readOnly" reflects the state of the stdfile dialog
* checkbox, and "createFile" is set to true by the "New Archive" command.
*
* Returns 0 on success, nonzero on failure.
*/
int LoadArchive(const WCHAR* filename, const WCHAR* extension, int LoadArchive(const WCHAR* filename, const WCHAR* extension,
int filterIndex, bool readOnly, bool createFile); int filterIndex, bool readOnly, bool createFile);
/*
* Open a raw disk volume. Useful for ProDOS-formatted 1.44MB floppy disks
* and CFFA flash cards.
*
* Assume it's a disk image -- it'd be a weird place for a ShrinkIt archive.
* CFFA cards can actually hold multiple volumes, but that's all taken care
* of inside the diskimg DLL.
*
* Returns 0 on success, nonzero on failure.
*/
int DoOpenVolume(CString drive, bool readOnly); int DoOpenVolume(CString drive, bool readOnly);
/*
* Switch the content list to a new archive, closing the previous if one
* was already open.
*/
void SwitchContentList(GenericArchive* pOpenArchive); void SwitchContentList(GenericArchive* pOpenArchive);
/*
* Close the existing archive file, but don't try to shut down the child
* windows. This should only be used from the destructor.
*/
void CloseArchiveWOControls(void); void CloseArchiveWOControls(void);
/*
* Close the existing archive file, and throw out the control we're
* using to display it.
*/
void CloseArchive(void); void CloseArchive(void);
/*
* Set the title bar on the main window.
*
* "pathname" is often different from pOpenArchive->GetPathName(), especially
* when we were launched from another instance of CiderPress and handed a
* temp file whose name we're trying to conceal.
*/
void SetCPTitle(const WCHAR* pathname, GenericArchive* pArchive); void SetCPTitle(const WCHAR* pathname, GenericArchive* pArchive);
/*
* Set the title bar to something boring when nothing is open.
*/
void SetCPTitle(void); void SetCPTitle(void);
/*
* Get the one selected item from the current display. Primarily useful
* for the double-click handler, but also used for "action" menu items
* that insist on operating on a single menu item (edit prefs, create subdir).
*
* Returns NULL if the item couldn't be found or if more than one item was
* selected.
*/
GenericEntry* GetSelectedItem(ContentList* pContentList); GenericEntry* GetSelectedItem(ContentList* pContentList);
/*
* Handle a request to view stuff.
*
* If "query" pref is set, we ask the user to confirm some choices. If
* not, we just go with the defaults.
*
* We include "damaged" files so that we can show the user a nice message
* about how the file is damaged.
*/
void HandleView(void); void HandleView(void);
void DeleteFileOnExit(const WCHAR* name); void DeleteFileOnExit(const WCHAR* name);
/*
* Close and re-open the current archive.
*/
void ReopenArchive(void); void ReopenArchive(void);
/* some stuff from Actions.cpp */ /*
//int GetFileText(SelectionEntry* pSelEntry, ReformatHolder* pHolder, * ===== Actions.cpp =====
// CString* pTitle); */
/*
* Load the requested part.
*/
void GetFilePart(const GenericEntry* pEntry, int whichThread, void GetFilePart(const GenericEntry* pEntry, int whichThread,
ReformatHolder* pHolder) const; ReformatHolder* pHolder) const;
/** /*
* this is a test * Handle a bulk extraction.
* of whatever the hell this does */
* whee.
*/
void DoBulkExtract(SelectionSet* pSelSet, void DoBulkExtract(SelectionSet* pSelSet,
const ExtractOptionsDialog* pExtOpts); const ExtractOptionsDialog* pExtOpts);
/*
* Extract a single entry.
*
* If pHolder is non-NULL, it holds the data from the file, and can be
* used for formatted or non-formatted output. If it's NULL, we need to
* extract the data ourselves.
*
* Returns true on success, false on failure.
*/
bool ExtractEntry(GenericEntry* pEntry, int thread, bool ExtractEntry(GenericEntry* pEntry, int thread,
ReformatHolder* pHolder, const ExtractOptionsDialog* pExtOpts, ReformatHolder* pHolder, const ExtractOptionsDialog* pExtOpts,
bool* pOverwriteExisting, bool* pOvwrForAll); bool* pOverwriteExisting, bool* pOvwrForAll);
/*
* Open an output file.
*
* "outputPath" holds the name of the file to create. "origPath" is the
* name as it was stored in the archive. "pOverwriteExisting" tells us
* if we should just go ahead and overwrite the existing file, while
* "pOvwrForAll" tells us if a "To All" button was hit previously.
*
* If the file exists, *pOverwriteExisting is false, and *pOvwrForAll
* is false, then we will put up the "do you want to overwrite?" dialog.
* One possible outcome of the dialog is renaming the output path.
*
* On success, *pFp will be non-NULL, and IDOK will be returned. On
* failure, IDCANCEL will be returned. The values in *pOverwriteExisting
* and *pOvwrForAll may be updated, and *pOutputPath will change if
* the user chose to rename the file.
*/
int OpenOutputFile(CString* pOutputPath, const PathProposal& pathProp, int OpenOutputFile(CString* pOutputPath, const PathProposal& pathProp,
time_t arcFileModWhen, bool* pOverwriteExisting, bool* pOvwrForAll, time_t arcFileModWhen, bool* pOverwriteExisting, bool* pOvwrForAll,
FILE** pFp); FILE** pFp);
bool DoBulkRecompress(ActionProgressDialog* pActionProgress, bool DoBulkRecompress(ActionProgressDialog* pActionProgress,
SelectionSet* pSelSet, const RecompressOptionsDialog* pRecompOpts); SelectionSet* pSelSet, const RecompressOptionsDialog* pRecompOpts);
/*
* Compute the total size of all files in the GenericArchive.
*/
void CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const; void CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const;
/* some stuff from Clipboard.cpp */ /*
* Print a ContentList.
*/
void PrintListing(const ContentList* pContentList);
/*
* ===== Clipboard.cpp =====
*/
/*
* Create a list of selected files.
*
* The returned string uses tab-delineated fields with CSV-style quoting
* around the filename (so that double quotes in the filename don't confuse
* applications like MS Excel).
*/
CString CreateFileList(SelectionSet* pSelSet); CString CreateFileList(SelectionSet* pSelSet);
/*
* Double-up all double quotes.
*/
static CString DblDblQuote(const WCHAR* str); static CString DblDblQuote(const WCHAR* str);
/*
* Compute the size of everything currently on the clipboard.
*/
long GetClipboardContentLen(void); long GetClipboardContentLen(void);
/*
* Create the file collection.
*/
HGLOBAL CreateFileCollection(SelectionSet* pSelSet); HGLOBAL CreateFileCollection(SelectionSet* pSelSet);
/*
* Copy the contents of the file referred to by "pEntry" into the buffer
* "*pBuf", which has "*pBufLen" bytes in it.
*
* The call fails if "*pBufLen" isn't large enough.
*
* Returns an empty string on success, or an error message on failure.
* On success, "*pBuf" will be advanced past the data added, and "*pBufLen"
* will be reduced by the amount of data copied into "buf".
*/
CString CopyToCollection(GenericEntry* pEntry, void** pBuf, long* pBufLen); CString CopyToCollection(GenericEntry* pEntry, void** pBuf, long* pBufLen);
/*
* Do some prep work and then call ProcessClipboard to copy files in.
*/
void DoPaste(bool pasteJunkPaths); void DoPaste(bool pasteJunkPaths);
/*
* Process the data in the clipboard.
*
* Returns an empty string on success, or an error message on failure.
*/
CString ProcessClipboard(const void* vbuf, long bufLen, CString ProcessClipboard(const void* vbuf, long bufLen,
bool pasteJunkPaths); bool pasteJunkPaths);
CString ProcessClipboardEntry(const FileCollectionEntry* pCollEnt,
const WCHAR* pathName, const unsigned char* buf, long remLen);
/* some stuff from Tools.cpp */ /*
* Process a single clipboard entry.
*
* On entry, "buf" points to the start of the first chunk of data (either
* data fork or resource fork). If the file has empty forks or is a
* subdirectory, then "buf" is actually pointing at the start of the
* next entry.
*/
CString ProcessClipboardEntry(const FileCollectionEntry* pCollEnt,
const WCHAR* pathName, const uint8_t* buf, long remLen);
/*
* ===== Tools.cpp =====
*/
/*
* Determines the settings we need to pass into DiskImgLib to create the
* desired disk image format.
*
* Returns 0 on success, -1 on failure.
*/
int DetermineImageSettings(int convertIdx, bool addGzip, int DetermineImageSettings(int convertIdx, bool addGzip,
DiskImg::OuterFormat* pOuterFormat, DiskImg::FileFormat* pFileFormat, DiskImg::OuterFormat* pOuterFormat, DiskImg::FileFormat* pFileFormat,
DiskImg::PhysicalFormat* pPhysicalFormat, DiskImg::PhysicalFormat* pPhysicalFormat,
DiskImg::SectorOrder* pSectorOrder); DiskImg::SectorOrder* pSectorOrder);
/*
* Converts one image during a bulk conversion.
*
* On failure, the reason for failure is stuffed into "*pErrMsg".
*/
void BulkConvertImage(const WCHAR* pathName, const WCHAR* targetDir, void BulkConvertImage(const WCHAR* pathName, const WCHAR* targetDir,
const DiskConvertDialog& convDlg, CString* pErrMsg); const DiskConvertDialog& convDlg, CString* pErrMsg);
/*
* Opens one of the SST images. Configures "pDiskImg" appropriately.
*
* Returns 0 on success, nonzero on failure.
*/
int SSTOpenImage(int seqNum, DiskImg* pDiskImg); int SSTOpenImage(int seqNum, DiskImg* pDiskImg);
/*
* Copies 17.5 tracks of data from the SST image to a .NIB image.
*
* Data is stored in all 16 sectors of track 0, followed by the first
* 12 sectors of track 1, then on to track 2. Total of $1a00 bytes.
*
* Returns 0 on success, -1 on failure.
*/
int SSTLoadData(int seqNum, DiskImg* pDiskImg, uint8_t* trackBuf, int SSTLoadData(int seqNum, DiskImg* pDiskImg, uint8_t* trackBuf,
long* pBadCount); long* pBadCount);
/*
* Compute the destination file offset for a particular source track. The
* track number ranges from 0 to 69 inclusive. Sectors from two adjacent
* "cooked" tracks are combined into a single "raw nibbilized" track.
*
* The data is ordered like this:
* track 1 sector 15 --> track 1 sector 4 (12 sectors)
* track 0 sector 13 --> track 0 sector 0 (14 sectors)
*
* Total of 26 sectors, or $1a00 bytes.
*/
long SSTGetBufOffset(int track); long SSTGetBufOffset(int track);
/*
* Count the number of "bad" bytes in the sector.
*
* Strictly speaking, a "bad" byte is anything that doesn't appear in the
* 6&2 decoding table, 5&3 decoding table, special list (D5, AA), and
* can't be used as a 4+4 encoding value.
*
* We just use $80 - $92, which qualify for all of the above.
*/
long SSTCountBadBytes(const uint8_t* sctBuf, int count); long SSTCountBadBytes(const uint8_t* sctBuf, int count);
/*
* Run through the data, adding 0x80 everywhere and re-aligning the
* tracks so that the big clump of sync bytes is at the end.
*/
void SSTProcessTrackData(uint8_t* trackBuf); void SSTProcessTrackData(uint8_t* trackBuf);
/*
* Select a volume and then invoke the volcopy dialog.
*/
void VolumeCopier(bool openFile); void VolumeCopier(bool openFile);
/*
* Edit the properties of a 2MG file.
*
* Returns "true" if the file was modified, "false" if not.
*/
bool EditTwoImgProps(const WCHAR* fileName); bool EditTwoImgProps(const WCHAR* fileName);
void PrintListing(const ContentList* pContentList);
// set when one of the tools modifies the file we have open // set when one of the tools modifies the file we have open
bool fNeedReopen; bool fNeedReopen;

View File

@ -17,15 +17,17 @@
/* magic global that MFC finds (or that finds MFC) */ /* magic global that MFC finds (or that finds MFC) */
MyApp gMyApp; MyApp gMyApp;
/* used for debug logging */
DebugLog* gDebugLog; DebugLog* gDebugLog;
/* /*
* Constructor. This is the closest thing to "main" that we have, but we * This is the closest thing to "main" that we have, but we
* should wait for InitInstance for most things. * should wait for InitInstance for most things.
*/ */
MyApp::MyApp(LPCTSTR lpszAppName) : CWinApp(lpszAppName) MyApp::MyApp(LPCTSTR lpszAppName) : CWinApp(lpszAppName)
{ {
gDebugLog = new DebugLog(L"C:\\src\\cplog.txt"); gDebugLog = new DebugLog(L"C:\\src\\cplog.txt");
time_t now = time(NULL); time_t now = time(NULL);
@ -54,19 +56,9 @@ MyApp::~MyApp(void)
delete gDebugLog; delete gDebugLog;
} }
BOOL MyApp::InitInstance(void)
/*
* It all begins here.
*
* Create a main window.
*/
BOOL
MyApp::InitInstance(void)
{ {
//fclose(fopen("c:\\cp-initinstance.txt", "w")); // Create the main window.
//_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
m_pMainWnd = new MainWindow; m_pMainWnd = new MainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow(); m_pMainWnd->UpdateWindow();
@ -146,13 +138,7 @@ MyApp::InitInstance(void)
return TRUE; return TRUE;
} }
/* void MyApp::LogModuleLocation(const WCHAR* name)
* Show where we got something from. Handy for checking DLL load locations.
*
* If "name" is NULL, we show the EXE info.
*/
void
MyApp::LogModuleLocation(const WCHAR* name)
{ {
HMODULE hModule; HMODULE hModule;
WCHAR fileNameBuf[256]; WCHAR fileNameBuf[256];
@ -167,11 +153,7 @@ MyApp::LogModuleLocation(const WCHAR* name)
} }
} }
/* BOOL MyApp::OnIdle(LONG lCount)
* Do some idle processing.
*/
BOOL
MyApp::OnIdle(LONG lCount)
{ {
BOOL bMore = CWinApp::OnIdle(lCount); BOOL bMore = CWinApp::OnIdle(lCount);

View File

@ -32,10 +32,14 @@ public:
const WCHAR* GetExeBaseName(void) const { return fExeBaseName; } const WCHAR* GetExeBaseName(void) const { return fExeBaseName; }
private: private:
// Overridden functions virtual BOOL InitInstance(void) override;
virtual BOOL InitInstance(void); virtual BOOL OnIdle(LONG lCount) override;
virtual BOOL OnIdle(LONG lCount);
/*
* Show where we got something from. Handy for checking DLL load locations.
*
* If "name" is NULL, we show the EXE info.
*/
void LogModuleLocation(const WCHAR* name); void LogModuleLocation(const WCHAR* name);
CString fExeFileName; CString fExeFileName;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Functions and data to support the "new disk size" radio buttons.
*/
#include "stdafx.h" #include "stdafx.h"
#include "NewDiskSize.h" #include "NewDiskSize.h"
#include "resource.h" #include "resource.h"
@ -27,27 +24,18 @@
}; };
static const int kEditBoxID = IDC_CONVDISK_SPECIFY_EDIT; static const int kEditBoxID = IDC_CONVDISK_SPECIFY_EDIT;
/* /*static*/ unsigned int NewDiskSize::GetNumSizeEntries(void)
* Return the #of entries in the table.
*/
/*static*/ unsigned int
NewDiskSize::GetNumSizeEntries(void)
{ {
return NELEM(kCtrlMap); return NELEM(kCtrlMap);
} }
/* /*static*/ long NewDiskSize::GetDiskSizeByIndex(int idx)
* Return the "size" field from an array entry.
*/
/*static*/ long
NewDiskSize::GetDiskSizeByIndex(int idx)
{ {
ASSERT(idx >= 0 && idx < NELEM(kCtrlMap)); ASSERT(idx >= 0 && idx < NELEM(kCtrlMap));
return kCtrlMap[idx].blocks; return kCtrlMap[idx].blocks;
} }
/*static*/ void /*static*/ void NewDiskSize::EnableButtons(CDialog* pDialog, BOOL state)
NewDiskSize::EnableButtons(CDialog* pDialog, BOOL state /*=true*/)
{ {
CWnd* pWnd; CWnd* pWnd;
@ -58,22 +46,8 @@ NewDiskSize::EnableButtons(CDialog* pDialog, BOOL state /*=true*/)
} }
} }
/* /*static*/ void NewDiskSize::EnableButtons_ProDOS(CDialog* pDialog,
* Run through the set of radio buttons, disabling any that don't have enough long totalBlocks, long blocksUsed)
* space to hold the ProDOS volume with the specified parameters.
*
* The space required is equal to the blocks required for data plus the blocks
* required for the free-space bitmap. Since the free-space bitmap size is
* smaller for smaller volumes, we have to adjust it for each.
*
* Pass in the total blocks and #of blocks used on a particular ProDOS volume.
* This will compute how much space would be required for larger and smaller
* volumes, and enable or disable radio buttons as appropriate. (You can get
* these values from DiskFS::GetFreeBlockCount()).
*/
/*static*/ void
NewDiskSize::EnableButtons_ProDOS(CDialog* pDialog, long totalBlocks,
long blocksUsed)
{ {
CButton* pButton; CButton* pButton;
long usedWithoutBitmap = blocksUsed - GetNumBitmapBlocks_ProDOS(totalBlocks); long usedWithoutBitmap = blocksUsed - GetNumBitmapBlocks_ProDOS(totalBlocks);
@ -116,23 +90,14 @@ NewDiskSize::EnableButtons_ProDOS(CDialog* pDialog, long totalBlocks,
UpdateSpecifyEdit(pDialog); UpdateSpecifyEdit(pDialog);
} }
/* /*static*/ long NewDiskSize::GetNumBitmapBlocks_ProDOS(long totalBlocks) {
* Compute the #of blocks needed to hold the ProDOS block bitmap.
*/
/*static*/long
NewDiskSize::GetNumBitmapBlocks_ProDOS(long totalBlocks) {
ASSERT(totalBlocks > 0); ASSERT(totalBlocks > 0);
const int kBitsPerBlock = 512 * 8; const int kBitsPerBlock = 512 * 8;
int numBlocks = (totalBlocks + kBitsPerBlock-1) / kBitsPerBlock; int numBlocks = (totalBlocks + kBitsPerBlock-1) / kBitsPerBlock;
return numBlocks; return numBlocks;
} }
/*static*/ void NewDiskSize::UpdateSpecifyEdit(CDialog* pDialog)
/*
* Update the "specify size" edit box.
*/
/*static*/ void
NewDiskSize::UpdateSpecifyEdit(CDialog* pDialog)
{ {
CEdit* pEdit = (CEdit*) pDialog->GetDlgItem(kEditBoxID); CEdit* pEdit = (CEdit*) pDialog->GetDlgItem(kEditBoxID);
int i; int i;

View File

@ -16,14 +16,44 @@ class NewDiskSize {
public: public:
NewDiskSize(void) { ASSERT(false); } NewDiskSize(void) { ASSERT(false); }
/*
* Return the #of entries in the table.
*/
static unsigned int GetNumSizeEntries(void); static unsigned int GetNumSizeEntries(void);
/*
* Return the "size" field from an array entry.
*/
static long GetDiskSizeByIndex(int idx); static long GetDiskSizeByIndex(int idx);
enum { kSpecified = -1 }; enum { kSpecified = -1 };
static void EnableButtons(CDialog* pDialog, BOOL state = true); static void EnableButtons(CDialog* pDialog, BOOL state = true);
/*
* Run through the set of radio buttons, disabling any that don't have enough
* space to hold the ProDOS volume with the specified parameters.
*
* The space required is equal to the blocks required for data plus the blocks
* required for the free-space bitmap. Since the free-space bitmap size is
* smaller for smaller volumes, we have to adjust it for each.
*
* Pass in the total blocks and #of blocks used on a particular ProDOS volume.
* This will compute how much space would be required for larger and smaller
* volumes, and enable or disable radio buttons as appropriate. (You can get
* these values from DiskFS::GetFreeBlockCount()).
*/
static void EnableButtons_ProDOS(CDialog* pDialog, long totalBlocks, static void EnableButtons_ProDOS(CDialog* pDialog, long totalBlocks,
long blocksUsed); long blocksUsed);
/*
* Compute the #of blocks needed to hold the ProDOS block bitmap.
*/
static long GetNumBitmapBlocks_ProDOS(long totalBlocks); static long GetNumBitmapBlocks_ProDOS(long totalBlocks);
/*
* Update the "specify size" edit box.
*/
static void UpdateSpecifyEdit(CDialog* pDialog); static void UpdateSpecifyEdit(CDialog* pDialog);
private: private:

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Allow the user to create a new folder.
*/
#include "stdafx.h" #include "stdafx.h"
#include "NewFolderDialog.h" #include "NewFolderDialog.h"
@ -13,24 +10,22 @@ BEGIN_MESSAGE_MAP(NewFolderDialog, CDialog)
ON_WM_HELPINFO() ON_WM_HELPINFO()
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* void NewFolderDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*
* It is very important to keep '\\' out of the folder path, because it allows
* for all sorts of behavior (like "..\foo" or "D:\ack") that the caller
* might not be expecting. For example, if it's displaying a tree, it
* might assume that the folder goes under the currently selected node.
*
* Under WinNT, '/' is regarded as equivalent to '\', so we have to block
* that as well.
*
* Other characters (':') are also dangerous, but so long as we start with
* a valid path, Windows will prevent them from being used where they are
* inappropriate.
*/
void
NewFolderDialog::DoDataExchange(CDataExchange* pDX)
{ {
/*
* It is very important to keep '\\' out of the folder path, because it allows
* for all sorts of behavior (like "..\foo" or "D:\ack") that the caller
* might not be expecting. For example, if it's displaying a tree, it
* might assume that the folder goes under the currently selected node.
*
* Under WinNT, '/' is regarded as equivalent to '\', so we have to block
* that as well.
*
* Other characters (':') are also dangerous, but so long as we start with
* a valid path, Windows will prevent them from being used where they are
* inappropriate.
*/
if (!pDX->m_bSaveAndValidate) if (!pDX->m_bSaveAndValidate)
DDX_Text(pDX, IDC_NEWFOLDER_CURDIR, fCurrentFolder); DDX_Text(pDX, IDC_NEWFOLDER_CURDIR, fCurrentFolder);
@ -72,12 +67,7 @@ NewFolderDialog::DoDataExchange(CDataExchange* pDX)
} }
} }
BOOL NewFolderDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
/*
* Context help request (question mark button).
*/
BOOL
NewFolderDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it

View File

@ -38,8 +38,9 @@ public:
CString fNewFullPath; CString fNewFullPath;
protected: protected:
void DoDataExchange(CDataExchange* pDX); void DoDataExchange(CDataExchange* pDX) override;
BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
// on exit, set to "true" if we created the folder in "fNewFolder" // on exit, set to "true" if we created the folder in "fNewFolder"
bool fFolderCreated; bool fFolderCreated;

View File

@ -29,24 +29,7 @@ const unsigned char kNufxNoFssep = 0xff;
* =========================================================================== * ===========================================================================
*/ */
/* int NufxEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
* Extract data from a thread into a buffer.
*
* If "*ppText" is non-NULL and "*pLength" is > 0, the data will be read into
* the pointed-to buffer so long as it's shorter than *pLength bytes. The
* value in "*pLength" will be set to the actual length used.
*
* If "*ppText" is NULL or the length is <= 0, the uncompressed data will be
* placed into a buffer allocated with "new[]".
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*ppText" and "*pLength" will
* be valid but point at an error message.
*
* "which" is an anonymous GenericArchive enum.
*/
int
NufxEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const CString* pErrMsg) const
{ {
NuError nerr; NuError nerr;
@ -148,16 +131,7 @@ bail:
return result; return result;
} }
/* int NufxEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
* Extract data from a thread to a file. Since we're not copying to memory,
* we can't assume that we're able to hold the entire file all at once.
*
* Returns IDOK on success, IDCANCEL if the operation was cancelled by the
* user, and -1 value on failure. On failure, "*pMsg" holds an
* error message.
*/
int
NufxEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const ConvertHighASCII convHA, CString* pErrMsg) const
{ {
NuDataSink* pDataSink = NULL; NuDataSink* pDataSink = NULL;
@ -259,18 +233,7 @@ bail:
return result; return result;
} }
/* void NufxEntry::FindThreadInfo(int which, NuThread* pRetThread,
* Find info for the thread we're about to extract.
*
* Given the NuRecordIdx stored in the object, find the thread whose
* ThreadID matches "which". Copies the NuThread structure into
* "*pThread".
*
* On failure, "pErrMsg" will have a nonzero length, and contain an error
* message describing the problem.
*/
void
NufxEntry::FindThreadInfo(int which, NuThread* pRetThread,
CString* pErrMsg) const CString* pErrMsg) const
{ {
NuError nerr; NuError nerr;
@ -334,29 +297,24 @@ static const WCHAR* gFormatNames[] = {
L"LZC-16", L"Deflate", L"Bzip2" L"LZC-16", L"Deflate", L"Bzip2"
}; };
/* void NufxEntry::AnalyzeRecord(const NuRecord* pRecord)
* Analyze the contents of a record to determine if it's a disk, file,
* or "other". Compute the total compressed and uncompressed lengths
* of all data threads. Return the "best" format.
*
* The "best format" and "record type" stuff assume that the entire
* record contains only a disk thread or a file thread, and that any
* format is interesting so long as it isn't "no compression". In
* general these will be true, because ShrinkIt and NuLib create files
* this way.
*
* You could, of course, create a single record with a data thread and
* a disk image thread, but it's a fair bet ShrinkIt would ignore one
* or the other.
*
* NOTE: we don't currently work around the GSHK zero-length file bug.
* Such records, which have a filename thread but no data threads at all,
* will be categorized as "unknown". We could detect the situation and
* correct it, but we might as well flag it in a user-visible way.
*/
void
NufxEntry::AnalyzeRecord(const NuRecord* pRecord)
{ {
/*
* The "best format" and "record type" stuff assume that the entire
* record contains only a disk thread or a file thread, and that any
* format is interesting so long as it isn't "no compression". In
* general these will be true, because ShrinkIt and NuLib create files
* this way.
*
* You could, of course, create a single record with a data thread and
* a disk image thread, but it's a fair bet ShrinkIt would ignore one
* or the other.
*
* NOTE: we don't currently work around the GSHK zero-length file bug.
* Such records, which have a filename thread but no data threads at all,
* will be categorized as "unknown". We could detect the situation and
* correct it, but we might as well flag it in a user-visible way.
*/
const NuThread* pThread; const NuThread* pThread;
NuThreadID threadID; NuThreadID threadID;
unsigned long idx; unsigned long idx;
@ -442,17 +400,7 @@ NufxEntry::AnalyzeRecord(const NuRecord* pRecord)
* =========================================================================== * ===========================================================================
*/ */
/* /*static*/ CString NufxArchive::AppInit(void)
* Perform one-time initialization of the NufxLib library.
*
* Returns with an error if the NufxLib version is off. Major version must
* match (since it indicates an interface change), minor version must be
* >= what we expect (in case we're relying on recent behavior changes).
*
* Returns 0 on success, nonzero on error.
*/
/*static*/ CString
NufxArchive::AppInit(void)
{ {
NuError nerr; NuError nerr;
CString result(""); CString result("");
@ -483,15 +431,7 @@ bail:
return result; return result;
} }
/*static*/ bool NufxArchive::IsCompressionSupported(NuThreadFormat format)
/*
* Determine whether a particular kind of compression is supported by
* NufxLib.
*
* Returns "true" if supported, "false" if not.
*/
/*static*/ bool
NufxArchive::IsCompressionSupported(NuThreadFormat format)
{ {
NuFeature feature; NuFeature feature;
@ -529,11 +469,7 @@ NufxArchive::IsCompressionSupported(NuThreadFormat format)
return false; return false;
} }
/* NuResult NufxArchive::NufxErrorMsgHandler(NuArchive*, void* vErrorMessage)
* Display error messages... or not.
*/
NuResult
NufxArchive::NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage)
{ {
const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage; const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage;
@ -544,14 +480,10 @@ NufxArchive::NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage)
return kNuOK; return kNuOK;
} }
/* /*static*/NuResult NufxArchive::ProgressUpdater(NuArchive* pArchive,
* Display our progress. void* vpProgress)
*
* "oldName" ends up on top, "newName" on bottom.
*/
/*static*/NuResult
NufxArchive::ProgressUpdater(NuArchive* pArchive, void* vpProgress)
{ {
// "oldName" ends up on top, "newName" on bottom.
const NuProgressData* pProgress = (const NuProgressData*) vpProgress; const NuProgressData* pProgress = (const NuProgressData*) vpProgress;
NufxArchive* pThis; NufxArchive* pThis;
MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd(); MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd();
@ -608,14 +540,8 @@ NufxArchive::ProgressUpdater(NuArchive* pArchive, void* vpProgress)
return kNuOK; return kNuOK;
} }
GenericArchive::OpenResult NufxArchive::Open(const WCHAR* filename,
/* bool readOnly, CString* pErrMsg)
* Finish instantiating a NufxArchive object by opening an existing file.
*
* Returns an error string on failure, or NULL on success.
*/
GenericArchive::OpenResult
NufxArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
{ {
NuError nerr; NuError nerr;
CString errMsg; CString errMsg;
@ -669,14 +595,7 @@ bail:
return kResultSuccess; return kResultSuccess;
} }
CString NufxArchive::New(const WCHAR* filename, const void* options)
/*
* Finish instantiating a NufxArchive object by creating a new archive.
*
* Returns an error string on failure, or "" on success.
*/
CString
NufxArchive::New(const WCHAR* filename, const void* options)
{ {
NuError nerr; NuError nerr;
CString retmsg; CString retmsg;
@ -710,11 +629,7 @@ bail:
return retmsg; return retmsg;
} }
/* NuError NufxArchive::SetCallbacks(void)
* Set some standard callbacks and feature flags.
*/
NuError
NufxArchive::SetCallbacks(void)
{ {
NuError nerr; NuError nerr;
@ -745,13 +660,7 @@ bail:
return nerr; return nerr;
} }
/* void NufxArchive::PreferencesChanged(void)
* User has updated their preferences. Take note.
*
* (This is also called the first time through.)
*/
void
NufxArchive::PreferencesChanged(void)
{ {
NuError nerr; NuError nerr;
const Preferences* pPreferences = GET_PREFERENCES(); const Preferences* pPreferences = GET_PREFERENCES();
@ -774,11 +683,7 @@ NufxArchive::PreferencesChanged(void)
NuSetValue(fpArchive, kNuValueHandleBadMac, val); NuSetValue(fpArchive, kNuValueHandleBadMac, val);
} }
/* long NufxArchive::GetCapability(Capability cap)
* Report on what NuFX is capable of.
*/
long
NufxArchive::GetCapability(Capability cap)
{ {
switch (cap) { switch (cap) {
case kCapCanTest: case kCapCanTest:
@ -812,15 +717,12 @@ NufxArchive::GetCapability(Capability cap)
} }
} }
/* NuError NufxArchive::LoadContents(void)
* Load the contents of an archive into the GenericEntry/NufxEntry list.
*
* We will need to set an error handler if we want to be able to do things
* like "I found a bad CRC, did you want me to keep trying anyway?".
*/
NuError
NufxArchive::LoadContents(void)
{ {
/*
* We will need to set an error handler if we want to be able to do things
* like "I found a bad CRC, did you want me to keep trying anyway?".
*/
long counter = 0; long counter = 0;
NuError result; NuError result;
@ -846,11 +748,7 @@ NufxArchive::LoadContents(void)
return result; return result;
} }
/* CString NufxArchive::Reload(void)
* Reload the contents.
*/
CString
NufxArchive::Reload(void)
{ {
NuError nerr; NuError nerr;
CString errMsg; CString errMsg;
@ -871,12 +769,7 @@ NufxArchive::Reload(void)
return errMsg; return errMsg;
} }
/* NuError NufxArchive::InternalReload(CWnd* pMsgWnd)
* Reload the contents of the archive, showing an error message if the
* reload fails.
*/
NuError
NufxArchive::InternalReload(CWnd* pMsgWnd)
{ {
CString errMsg; CString errMsg;
@ -890,11 +783,7 @@ NufxArchive::InternalReload(CWnd* pMsgWnd)
return kNuErrNone; return kNuErrNone;
} }
/* NuResult NufxArchive::ContentFunc(NuArchive* pArchive, void* vpRecord)
* Static callback function. Used for scanning the contents of an archive.
*/
NuResult
NufxArchive::ContentFunc(NuArchive* pArchive, void* vpRecord)
{ {
const NuRecord* pRecord = (const NuRecord*) vpRecord; const NuRecord* pRecord = (const NuRecord*) vpRecord;
NufxArchive* pThis; NufxArchive* pThis;
@ -933,11 +822,7 @@ NufxArchive::ContentFunc(NuArchive* pArchive, void* vpRecord)
return kNuOK; return kNuOK;
} }
/* /*static*/ time_t NufxArchive::DateTimeToSeconds(const NuDateTime* pDateTime)
* Convert a NuDateTime structure to a time_t.
*/
/*static*/ time_t
NufxArchive::DateTimeToSeconds(const NuDateTime* pDateTime)
{ {
if (pDateTime->second == 0 && if (pDateTime->second == 0 &&
pDateTime->minute == 0 && pDateTime->minute == 0 &&
@ -983,12 +868,7 @@ NufxArchive::DateTimeToSeconds(const NuDateTime* pDateTime)
return (time_t) modTime.GetTime(); return (time_t) modTime.GetTime();
} }
/* /*static*/ NuResult NufxArchive::ArrayDeleteHandler(NuArchive* pArchive, void* ptr)
* Callback from a DataSource that is done with a buffer. Use for memory
* allocated with new[].
*/
/*static*/ NuResult
NufxArchive::ArrayDeleteHandler(NuArchive* pArchive, void* ptr)
{ {
delete[] ptr; delete[] ptr;
return kNuOK; return kNuOK;
@ -1001,19 +881,14 @@ NufxArchive::ArrayDeleteHandler(NuArchive* pArchive, void* ptr)
* =========================================================================== * ===========================================================================
*/ */
/* bool NufxArchive::BulkAdd(ActionProgressDialog* pActionProgress,
* Process a bulk "add" request.
*
* This calls into the GenericArchive "AddFile" function, which does
* Win32-specific processing. That function calls our DoAddFile function,
* which does the NuFX stuff.
*
* Returns "true" on success, "false" on failure.
*/
bool
NufxArchive::BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts)
{ {
/*
* This calls into the GenericArchive "AddFile" function, which does
* Win32-specific processing. That function calls our DoAddFile function,
* which does the NuFX stuff.
*/
NuError nerr; NuError nerr;
CString errMsg; CString errMsg;
WCHAR curDir[MAX_PATH] = L""; WCHAR curDir[MAX_PATH] = L"";
@ -1103,11 +978,7 @@ bail:
return retVal; return retVal;
} }
/* bool NufxArchive::AddDisk(ActionProgressDialog* pActionProgress,
* Add a single disk to the archive.
*/
bool
NufxArchive::AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) const AddFilesDialog* pAddOpts)
{ {
NuError nerr; NuError nerr;
@ -1279,13 +1150,7 @@ bail:
return retVal; return retVal;
} }
/* NuError NufxArchive::DoAddFile(const AddFilesDialog* pAddOpts,
* Do the archive-dependent part of the file add, including things like
* adding comments. This is eventually called by AddFile() during bulk
* adds.
*/
NuError
NufxArchive::DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails) FileDetails* pDetails)
{ {
NuError err; NuError err;
@ -1337,11 +1202,7 @@ bail_quiet:
return err; return err;
} }
/* void NufxArchive::AddPrep(CWnd* pMsgWnd, const AddFilesDialog* pAddOpts)
* Prepare to add files.
*/
void
NufxArchive::AddPrep(CWnd* pMsgWnd, const AddFilesDialog* pAddOpts)
{ {
NuError nerr; NuError nerr;
const Preferences* pPreferences = GET_PREFERENCES(); const Preferences* pPreferences = GET_PREFERENCES();
@ -1375,13 +1236,7 @@ NufxArchive::AddPrep(CWnd* pMsgWnd, const AddFilesDialog* pAddOpts)
NuSetExtraData(fpArchive, this); NuSetExtraData(fpArchive, this);
} }
/* void NufxArchive::AddFinish(void)
* Reset some things after we finish adding files. We don't necessarily
* want these to stay in effect for other operations, e.g. extracting
* (though that is currently handled within CiderPress).
*/
void
NufxArchive::AddFinish(void)
{ {
NuSetErrorHandler(fpArchive, NULL); NuSetErrorHandler(fpArchive, NULL);
NuSetValue(fpArchive, kNuValueHandleExisting, kNuMaybeOverwrite); NuSetValue(fpArchive, kNuValueHandleExisting, kNuMaybeOverwrite);
@ -1390,12 +1245,8 @@ NufxArchive::AddFinish(void)
//fBulkProgress = false; //fBulkProgress = false;
} }
/*static*/ NuResult NufxArchive::BulkAddErrorHandler(NuArchive* pArchive,
/* void* vErrorStatus)
* Error handler callback for "bulk" adds.
*/
/*static*/ NuResult
NufxArchive::BulkAddErrorHandler(NuArchive* pArchive, void* vErrorStatus)
{ {
const NuErrorStatus* pErrorStatus = (const NuErrorStatus*)vErrorStatus; const NuErrorStatus* pErrorStatus = (const NuErrorStatus*)vErrorStatus;
NufxArchive* pThis; NufxArchive* pThis;
@ -1437,12 +1288,7 @@ NufxArchive::BulkAddErrorHandler(NuArchive* pArchive, void* vErrorStatus)
return result; return result;
} }
/* NuResult NufxArchive::HandleReplaceExisting(const NuErrorStatus* pErrorStatus)
* Decide whether or not to replace an existing file (during extract)
* or record (during add).
*/
NuResult
NufxArchive::HandleReplaceExisting(const NuErrorStatus* pErrorStatus)
{ {
NuResult result = kNuOK; NuResult result = kNuOK;
@ -1498,13 +1344,7 @@ bail:
return result; return result;
} }
/* NuResult NufxArchive::HandleAddNotFound(const NuErrorStatus* pErrorStatus)
* A file that used to be there isn't anymore.
*
* This should be exceedingly rare.
*/
NuResult
NufxArchive::HandleAddNotFound(const NuErrorStatus* pErrorStatus)
{ {
CString errMsg; CString errMsg;
@ -1522,11 +1362,7 @@ NufxArchive::HandleAddNotFound(const NuErrorStatus* pErrorStatus)
* =========================================================================== * ===========================================================================
*/ */
/* bool NufxArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
* Test the records represented in the selection set.
*/
bool
NufxArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{ {
NuError nerr; NuError nerr;
NufxEntry* pEntry; NufxEntry* pEntry;
@ -1579,11 +1415,7 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* bool NufxArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
* Delete the records represented in the selection set.
*/
bool
NufxArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{ {
NuError nerr; NuError nerr;
NufxEntry* pEntry; NufxEntry* pEntry;
@ -1638,11 +1470,7 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* bool NufxArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
* Rename the records represented in the selection set.
*/
bool
NufxArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{ {
CString errMsg; CString errMsg;
NuError nerr; NuError nerr;
@ -1733,16 +1561,7 @@ NufxArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
return retVal; return retVal;
} }
CString NufxArchive::TestPathName(const GenericEntry* pGenericEntry,
/*
* Verify that the a name is suitable. Called by RenameEntryDialog.
*
* Tests for context-specific syntax and checks for duplicates.
*
* Returns an empty string on success, or an error message on failure.
*/
CString
NufxArchive::TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const const CString& basePath, const CString& newName, char newFssep) const
{ {
CString errMsg; CString errMsg;
@ -1796,24 +1615,21 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* bool NufxArchive::RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
* Recompress the files in the selection set.
*
* We have to uncompress the files into memory and then recompress them.
* We don't want to flush after every file (too slow), but we can't wait
* until they're expanded (unbounded memory requirements). So we have
* to keep expanding until we reach a certain limit, then call flush to
* push the changes out.
*
* Since we're essentially making the changes in place (it's actually
* all getting routed through the temp file), we need to delete the thread
* and re-add it. This isn't quite as thorough as "launder", which
* actually reconstructs the entire record.
*/
bool
NufxArchive::RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts) const RecompressOptionsDialog* pRecompOpts)
{ {
/*
* We have to uncompress the files into memory and then recompress them.
* We don't want to flush after every file (too slow), but we can't wait
* until they're expanded (unbounded memory requirements). So we have
* to keep expanding until we reach a certain limit, then call flush to
* push the changes out.
*
* Since we're essentially making the changes in place (it's actually
* all getting routed through the temp file), we need to delete the thread
* and re-add it. This isn't quite as thorough as "launder", which
* actually reconstructs the entire record.
*/
const int kMaxSizeInMemory = 2 * 1024 * 1024; // 2MB const int kMaxSizeInMemory = 2 * 1024 * 1024; // 2MB
CString errMsg; CString errMsg;
NuError nerr; NuError nerr;
@ -1934,13 +1750,7 @@ bail:
return retVal; return retVal;
} }
/* bool NufxArchive::RecompressThread(NufxEntry* pEntry, int threadKind,
* Recompress one thread.
*
* Returns "true" if things went okay, "false" on a fatal failure.
*/
bool
NufxArchive::RecompressThread(NufxEntry* pEntry, int threadKind,
const RecompressOptionsDialog* pRecompOpts, long* pSizeInMemory, const RecompressOptionsDialog* pRecompOpts, long* pSizeInMemory,
CString* pErrMsg) CString* pErrMsg)
{ {
@ -2032,18 +1842,16 @@ bail:
* =========================================================================== * ===========================================================================
*/ */
/* GenericArchive::XferStatus NufxArchive::XferSelection(CWnd* pMsgWnd,
* Transfer the selected files out of this archive and into another. SelectionSet* pSelSet, ActionProgressDialog* pActionProgress,
* const XferFileOptions* pXferOpts)
* We get one entry in the selection set per record.
*
* I think this now throws kXferCancelled whenever it's supposed to. Not
* 100% sure, but it looks good.
*/
GenericArchive::XferStatus
NufxArchive::XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts)
{ {
/*
* We get one entry in the selection set per record.
*
* I think this now throws kXferCancelled whenever it's supposed to. Not
* 100% sure, but it looks good.
*/
LOGI("NufxArchive XferSelection!"); LOGI("NufxArchive XferSelection!");
XferStatus retval = kXferFailed; XferStatus retval = kXferFailed;
unsigned char* dataBuf = NULL; unsigned char* dataBuf = NULL;
@ -2202,31 +2010,17 @@ bail:
return retval; return retval;
} }
/* void NufxArchive::XferPrepare(const XferFileOptions* pXferOpts)
* Prepare to transfer files into a NuFX archive.
*
* We set the "allow duplicates" flag because DOS 3.3 volumes can have
* files with duplicate names.
*/
void
NufxArchive::XferPrepare(const XferFileOptions* pXferOpts)
{ {
/*
* We set the "allow duplicates" flag because DOS 3.3 volumes can have
* files with duplicate names.
*/
LOGI(" NufxArchive::XferPrepare"); LOGI(" NufxArchive::XferPrepare");
(void) NuSetValue(fpArchive, kNuValueAllowDuplicates, true); (void) NuSetValue(fpArchive, kNuValueAllowDuplicates, true);
} }
/* CString NufxArchive::XferFile(FileDetails* pDetails, unsigned char** pDataBuf,
* Transfer the data and optional resource fork of a single file into the
* NuFX archive.
*
* "dataLen" and "rsrcLen" will be -1 if the corresponding fork doesn't
* exist.
*
* Returns 0 on success, -1 on failure. On success, "*pDataBuf" and
* "*pRsrcBuf" are set to NULL (ownership transfers to NufxLib).
*/
CString
NufxArchive::XferFile(FileDetails* pDetails, unsigned char** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen) long dataLen, unsigned char** pRsrcBuf, long rsrcLen)
{ {
NuError nerr; NuError nerr;
@ -2360,15 +2154,12 @@ bail:
return errMsg; return errMsg;
} }
/* void NufxArchive::XferAbort(CWnd* pMsgWnd)
* Abort the transfer.
*
* Since we don't do any interim flushes, we can just call NuAbort. If that
* weren't the case, we would need to delete all records and flush.
*/
void
NufxArchive::XferAbort(CWnd* pMsgWnd)
{ {
/*
* Since we don't do any interim flushes, we can just call NuAbort. If that
* weren't the case, we would need to delete all records and flush.
*/
NuError nerr; NuError nerr;
CString errMsg; CString errMsg;
@ -2381,11 +2172,7 @@ NufxArchive::XferAbort(CWnd* pMsgWnd)
} }
} }
/* void NufxArchive::XferFinish(CWnd* pMsgWnd)
* Flush all changes to the archive.
*/
void
NufxArchive::XferFinish(CWnd* pMsgWnd)
{ {
NuError nerr; NuError nerr;
CString errMsg; CString errMsg;
@ -2425,8 +2212,7 @@ bail:
* *
* Returns "true" on success, "false" on failure. * Returns "true" on success, "false" on failure.
*/ */
bool bool NufxArchive::GetComment(CWnd* pMsgWnd, const GenericEntry* pGenericEntry,
NufxArchive::GetComment(CWnd* pMsgWnd, const GenericEntry* pGenericEntry,
CString* pStr) CString* pStr)
{ {
NufxEntry* pEntry = (NufxEntry*) pGenericEntry; NufxEntry* pEntry = (NufxEntry*) pGenericEntry;
@ -2472,24 +2258,21 @@ NufxArchive::GetComment(CWnd* pMsgWnd, const GenericEntry* pGenericEntry,
return true; return true;
} }
/* bool NufxArchive::SetComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
* Set the comment. This requires either adding a new comment or updating
* an existing one. The latter is constrained by the maximum size of the
* comment buffer.
*
* We want to update in place whenever possible because it's faster (don't
* have to rewrite the entire archive), but that really only holds for new
* archives or if we foolishly set the kNuValueModifyOrig flag.
*
* Cleanest approach is to delete the existing thread and add a new one.
* If somebody complains we can try to be smarter about it.
*
* Returns "true" on success, "false" on failure.
*/
bool
NufxArchive::SetComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
const CString& str) const CString& str)
{ {
/*
* Set the comment. This requires either adding a new comment or updating
* an existing one. The latter is constrained by the maximum size of the
* comment buffer.
*
* We want to update in place whenever possible because it's faster (don't
* have to rewrite the entire archive), but that really only holds for new
* archives or if we foolishly set the kNuValueModifyOrig flag.
*
* Cleanest approach is to delete the existing thread and add a new one.
* If somebody complains we can try to be smarter about it.
*/
NuDataSource* pSource = NULL; NuDataSource* pSource = NULL;
NufxEntry* pEntry = (NufxEntry*) pGenericEntry; NufxEntry* pEntry = (NufxEntry*) pGenericEntry;
NuError nerr; NuError nerr;
@ -2578,13 +2361,7 @@ bail:
return retVal; return retVal;
} }
/* bool NufxArchive::DeleteComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry)
* Remove a comment.
*
* Returns "true" on success, "false" on failure.
*/
bool
NufxArchive::DeleteComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry)
{ {
CString errMsg; CString errMsg;
NuError nerr; NuError nerr;
@ -2626,21 +2403,18 @@ bail:
} }
/* bool NufxArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
* Set file properties via the NuSetRecordAttr call.
*
* Get the existing properties, copy the fields from FileProps over, and
* set them.
*
* [currently only supports file type, aux type, and access flags]
*
* Technically we should reload the GenericArchive from the NufxArchive,
* but the set of changes is pretty small, so we just make them here.
*/
bool
NufxArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps) const FileProps* pProps)
{ {
/*
* Sets file properties via the NuSetRecordAttr call.
*
* Gets the existing properties, copies the fields from FileProps over, and
* sets them. [currently only supports file type, aux type, and access flags]
*
* Technically we should reload the GenericArchive from the NufxArchive,
* but the set of changes is pretty small, so we just make them here.
*/
NuError nerr; NuError nerr;
NufxEntry* pNufxEntry = (NufxEntry*) pEntry; NufxEntry* pNufxEntry = (NufxEntry*) pEntry;
const NuRecord* pRecord; const NuRecord* pRecord;

View File

@ -25,14 +25,14 @@ public:
NuRecordIdx GetRecordIdx(void) const { return fRecordIdx; } NuRecordIdx GetRecordIdx(void) const { return fRecordIdx; }
void SetRecordIdx(NuRecordIdx idx) { fRecordIdx = idx; } void SetRecordIdx(NuRecordIdx idx) { fRecordIdx = idx; }
// retrieve thread data
virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength, virtual int ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const; CString* pErrMsg) const override;
virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv, virtual int ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const; ConvertHighASCII convHA, CString* pErrMsg) const override;
virtual long GetSelectionSerial(void) const { return fRecordIdx; }
virtual bool GetFeatureFlag(Feature feature) const { virtual long GetSelectionSerial(void) const override { return fRecordIdx; }
virtual bool GetFeatureFlag(Feature feature) const override {
if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes || if (feature == kFeaturePascalTypes || feature == kFeatureDOSTypes ||
feature == kFeatureHasSimpleAccess) feature == kFeatureHasSimpleAccess)
return false; return false;
@ -40,13 +40,26 @@ public:
return true; return true;
} }
// This fills out several GenericEntry fields based on the contents /*
// of "*pRecord". * Analyzes the contents of a record to determine if it's a disk, file,
* or "other". Computes the total compressed and uncompressed lengths
* of all data threads. Fills out several GenericEntry fields.
*/
void AnalyzeRecord(const NuRecord* pRecord); void AnalyzeRecord(const NuRecord* pRecord);
friend class NufxArchive; friend class NufxArchive;
private: private:
/*
* Find info for the thread we're about to extract.
*
* Given the NuRecordIdx stored in the object, find the thread whose
* ThreadID matches "which". Copies the NuThread structure into
* "*pThread".
*
* On entry *pErrMsg must be an empty string. On failure, it will
* contain an error message describing the problem.
*/
void FindThreadInfo(int which, NuThread* pThread, CString* pErrMsg) const; void FindThreadInfo(int which, NuThread* pThread, CString* pErrMsg) const;
NuRecordIdx fRecordIdx; // unique record index NuRecordIdx fRecordIdx; // unique record index
@ -69,48 +82,68 @@ public:
{} {}
virtual ~NufxArchive(void) { (void) Close(); } virtual ~NufxArchive(void) { (void) Close(); }
// One-time initialization; returns an error string. /*
* Perform one-time initialization of the NufxLib library.
*
* Returns with an error if the NufxLib version is off. Major version must
* match (since it indicates an interface change), minor version must be
* >= what we expect (in case we're relying on recent behavior changes).
*
* Returns 0 on success, nonzero on error.
*/
static CString AppInit(void); static CString AppInit(void);
/*
* Finish instantiating a NufxArchive object by opening an existing file.
*/
virtual OpenResult Open(const WCHAR* filename, bool readOnly, virtual OpenResult Open(const WCHAR* filename, bool readOnly,
CString* pErrMsg); CString* pErrMsg) override;
virtual CString New(const WCHAR* filename, const void* options);
virtual CString Flush(void) { return ""; } /*
virtual CString Reload(void); * Finish instantiating a NufxArchive object by creating a new archive.
virtual bool IsReadOnly(void) const { return fIsReadOnly; }; *
virtual bool IsModified(void) const { return false; } * Returns an error string on failure, or "" on success.
virtual void GetDescription(CString* pStr) const { *pStr = L"NuFX"; } */
virtual CString New(const WCHAR* filename, const void* options) override;
virtual CString Flush(void) override { return ""; }
virtual CString Reload(void) override;
virtual bool IsReadOnly(void) const override { return fIsReadOnly; };
virtual bool IsModified(void) const override { return false; }
virtual void GetDescription(CString* pStr) const override { *pStr = L"NuFX"; }
virtual bool BulkAdd(ActionProgressDialog* pActionProgress, virtual bool BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts); const AddFilesDialog* pAddOpts) override;
virtual bool AddDisk(ActionProgressDialog* pActionProgress, virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts); const AddFilesDialog* pAddOpts) override;
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry, virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName) const WCHAR* newName) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet); virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet); virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet); virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual CString TestPathName(const GenericEntry* pGenericEntry, virtual CString TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const; const CString& basePath, const CString& newName,
char newFssep) const override;
virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS, virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName) const WCHAR* newName) override
{ ASSERT(false); return false; } { ASSERT(false); return false; }
virtual CString TestVolumeName(const DiskFS* pDiskFS, virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const const WCHAR* newName) const override
{ ASSERT(false); return L"!"; } { ASSERT(false); return L"!"; }
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts); const RecompressOptionsDialog* pRecompOpts) override;
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet, virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts); ActionProgressDialog* pActionProgress,
const XferFileOptions* pXferOpts) override;
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry, virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr); CString* pStr) override;
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str); const CString& str) override;
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry); virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override;
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry, virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps); const FileProps* pProps) override;
virtual void PreferencesChanged(void); virtual void PreferencesChanged(void) override;
virtual long GetCapability(Capability cap); virtual long GetCapability(Capability cap) override;
// try not to use this // try not to use this
NuArchive* GetNuArchivePointer(void) const { return fpArchive; } NuArchive* GetNuArchivePointer(void) const { return fpArchive; }
@ -131,40 +164,80 @@ private:
} }
return L""; return L"";
} }
// recompress one thread
bool RecompressThread(NufxEntry* pEntry, int threadKind, bool RecompressThread(NufxEntry* pEntry, int threadKind,
const RecompressOptionsDialog* pRecompOpts, long* pSizeInMemory, const RecompressOptionsDialog* pRecompOpts, long* pSizeInMemory,
CString* pErrMsg); CString* pErrMsg);
virtual void XferPrepare(const XferFileOptions* pXferOpts); virtual void XferPrepare(const XferFileOptions* pXferOpts) override;
virtual CString XferFile(FileDetails* pDetails, unsigned char** pDataBuf, virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen); long dataLen, uint8_t** pRsrcBuf, long rsrcLen) override;
virtual void XferAbort(CWnd* pMsgWnd); virtual void XferAbort(CWnd* pMsgWnd) override;
virtual void XferFinish(CWnd* pMsgWnd); virtual void XferFinish(CWnd* pMsgWnd) override;
virtual ArchiveKind GetArchiveKind(void) { return kArchiveNuFX; } virtual ArchiveKind GetArchiveKind(void) override { return kArchiveNuFX; }
// prepare to add files
void AddPrep(CWnd* pWnd, const AddFilesDialog* pAddOpts); void AddPrep(CWnd* pWnd, const AddFilesDialog* pAddOpts);
void AddFinish(void);
virtual NuError DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails);
/*
* Reset some things after we finish adding files. We don't necessarily
* want these to stay in effect for other operations, e.g. extracting.
*/
void AddFinish(void);
virtual NuError DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails) override;
/*
* Error handler callback for "bulk" adds.
*/
static NuResult BulkAddErrorHandler(NuArchive* pArchive, void* vErrorStatus); static NuResult BulkAddErrorHandler(NuArchive* pArchive, void* vErrorStatus);
/*
* Decide whether or not to replace an existing file (during extract)
* or record (during add).
*/
NuResult HandleReplaceExisting(const NuErrorStatus* pErrorStatus); NuResult HandleReplaceExisting(const NuErrorStatus* pErrorStatus);
/*
* A file that used to be there isn't anymore.
*
* This should be exceedingly rare.
*/
NuResult HandleAddNotFound(const NuErrorStatus* pErrorStatus); NuResult HandleAddNotFound(const NuErrorStatus* pErrorStatus);
/*
* Load the contents of an archive into the GenericEntry/NufxEntry list.
*/
NuError LoadContents(void); NuError LoadContents(void);
/*
* Reload the contents of the archive, showing an error message if the
* reload fails.
*/
NuError InternalReload(CWnd* pMsgWnd); NuError InternalReload(CWnd* pMsgWnd);
/*
* Static callback function. Used for scanning the contents of an archive.
*/
static NuResult ContentFunc(NuArchive* pArchive, void* vpRecord); static NuResult ContentFunc(NuArchive* pArchive, void* vpRecord);
/*
* Set some standard callbacks and feature flags.
*/
NuError SetCallbacks(void); NuError SetCallbacks(void);
// handle progress update messages // handle progress update messages
static NuResult ProgressUpdater(NuArchive* pArchive, void* vpProgress); static NuResult ProgressUpdater(NuArchive* pArchive, void* vpProgress);
// handle errors and debug messages from NufxLib. // handle error and debug messages from NufxLib.
static NuResult NufxErrorMsgHandler(NuArchive* pArchive, static NuResult NufxErrorMsgHandler(NuArchive* pArchive,
void* vErrorMessage); void* vErrorMessage);
// handle a DataSource resource release request // handle a DataSource resource release request; used for memory allocated
// with new[]
static NuResult ArrayDeleteHandler(NuArchive* pArchive, void* ptr); static NuResult ArrayDeleteHandler(NuArchive* pArchive, void* ptr);
NuArchive* fpArchive; NuArchive* fpArchive;

View File

@ -12,7 +12,6 @@
#include "Main.h" #include "Main.h"
#include "../diskimg/Win32Extra.h" // need disk geometry calls #include "../diskimg/Win32Extra.h" // need disk geometry calls
#include "../diskimg/ASPI.h" #include "../diskimg/ASPI.h"
//#include "resource.h"
BEGIN_MESSAGE_MAP(OpenVolumeDialog, CDialog) BEGIN_MESSAGE_MAP(OpenVolumeDialog, CDialog)
@ -24,12 +23,12 @@ BEGIN_MESSAGE_MAP(OpenVolumeDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL OpenVolumeDialog::OnInitDialog(void)
* Set up the list of drives.
*/
BOOL
OpenVolumeDialog::OnInitDialog(void)
{ {
/*
* Sets up the list of drives.
*/
CDialog::OnInitDialog(); // do any DDX init stuff CDialog::OnInitDialog(); // do any DDX init stuff
const Preferences* pPreferences = GET_PREFERENCES(); const Preferences* pPreferences = GET_PREFERENCES();
long defaultFilter; long defaultFilter;
@ -85,21 +84,13 @@ OpenVolumeDialog::OnInitDialog(void)
return TRUE; return TRUE;
} }
/* void OpenVolumeDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
OpenVolumeDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_Check(pDX, IDC_OPENVOL_READONLY, fReadOnly); DDX_Check(pDX, IDC_OPENVOL_READONLY, fReadOnly);
LOGI("DoDataExchange: fReadOnly==%d", fReadOnly); LOGI("DoDataExchange: fReadOnly==%d", fReadOnly);
} }
/* void OpenVolumeDialog::LoadDriveList(void)
* Load the set of logical and physical drives.
*/
void
OpenVolumeDialog::LoadDriveList(void)
{ {
CWaitCursor waitc; CWaitCursor waitc;
CComboBox* pCombo; CComboBox* pCombo;
@ -125,12 +116,7 @@ OpenVolumeDialog::LoadDriveList(void)
LoadLogicalDriveList(pListView, &itemIndex); LoadLogicalDriveList(pListView, &itemIndex);
} }
/* bool OpenVolumeDialog::LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex)
* Determine the logical volumes available in the system and stuff them into
* the list.
*/
bool
OpenVolumeDialog::LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex)
{ {
DWORD drivesAvailable; DWORD drivesAvailable;
bool isWin9x = IsWin9x(); bool isWin9x = IsWin9x();
@ -286,18 +272,18 @@ OpenVolumeDialog::LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex)
return true; return true;
} }
/* bool OpenVolumeDialog::LoadPhysicalDriveList(CListCtrl* pListView, int* pItemIndex)
* Add a list of physical drives to the list control.
*
* I don't see a clever way to do this in Win2K except to open the first 8
* or so devices and see what happens.
*
* Win9x isn't much better, though you can be reasonably confident that there
* are at most 4 floppy drives and 4 hard drives.
*/
bool
OpenVolumeDialog::LoadPhysicalDriveList(CListCtrl* pListView, int* pItemIndex)
{ {
/*
* I don't see a clever way to do this in Win2K except to open the first 8
* or so devices and see what happens.
*
* Win9x isn't much better, though you can be reasonably confident that there
* are at most 4 floppy drives and 4 hard drives.
*
* TODO: check again for a better way
*/
bool isWin9x = IsWin9x(); bool isWin9x = IsWin9x();
int itemIndex = *pItemIndex; int itemIndex = *pItemIndex;
int i; int i;
@ -408,16 +394,7 @@ OpenVolumeDialog::LoadPhysicalDriveList(CListCtrl* pListView, int* pItemIndex)
return true; return true;
} }
/* bool OpenVolumeDialog::HasPhysicalDriveWin9x(int unit, CString* pRemark)
* Determine whether physical device N exists.
*
* Pass in the Int13 unit number, i.e. 0x00 for the first floppy drive. Win9x
* makes direct access to the hard drive very difficult, so we don't even try.
*
* TODO: remove this entirely?
*/
bool
OpenVolumeDialog::HasPhysicalDriveWin9x(int unit, CString* pRemark)
{ {
HANDLE handle = NULL; HANDLE handle = NULL;
const int VWIN32_DIOC_DOS_INT13 = 4; const int VWIN32_DIOC_DOS_INT13 = 4;
@ -484,14 +461,7 @@ OpenVolumeDialog::HasPhysicalDriveWin9x(int unit, CString* pRemark)
return true; return true;
} }
/* bool OpenVolumeDialog::HasPhysicalDriveWin2K(int unit, CString* pRemark)
* Determine whether physical device N exists.
*
* Pass in the Int13 unit number, i.e. 0x80 for the first hard drive. This
* should not be called with units for floppy drives (e.g. 0x00).
*/
bool
OpenVolumeDialog::HasPhysicalDriveWin2K(int unit, CString* pRemark)
{ {
HANDLE hDevice; // handle to the drive to be examined HANDLE hDevice; // handle to the drive to be examined
DISK_GEOMETRY dg; // disk drive geometry structure DISK_GEOMETRY dg; // disk drive geometry structure
@ -584,12 +554,7 @@ OpenVolumeDialog::HasPhysicalDriveWin2K(int unit, CString* pRemark)
return true; return true;
} }
void OpenVolumeDialog::OnListChange(NMHDR*, LRESULT* pResult)
/*
* Something changed in the list. Update the "OK" button.
*/
void
OpenVolumeDialog::OnListChange(NMHDR*, LRESULT* pResult)
{ {
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_VOLUME_LIST); CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_VOLUME_LIST);
CButton* pButton = (CButton*) GetDlgItem(IDOK); CButton* pButton = (CButton*) GetDlgItem(IDOK);
@ -599,11 +564,7 @@ OpenVolumeDialog::OnListChange(NMHDR*, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* void OpenVolumeDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
* Double click.
*/
void
OpenVolumeDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
{ {
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_VOLUME_LIST); CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_VOLUME_LIST);
CButton* pButton = (CButton*) GetDlgItem(IDOK); CButton* pButton = (CButton*) GetDlgItem(IDOK);
@ -616,11 +577,7 @@ OpenVolumeDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* void OpenVolumeDialog::OnVolumeFilterSelChange(void)
* The volume filter drop-down box has changed.
*/
void
OpenVolumeDialog::OnVolumeFilterSelChange(void)
{ {
CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_VOLUME_FILTER); CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_VOLUME_FILTER);
ASSERT(pCombo != NULL); ASSERT(pCombo != NULL);
@ -628,11 +585,7 @@ OpenVolumeDialog::OnVolumeFilterSelChange(void)
LoadDriveList(); LoadDriveList();
} }
/* void OpenVolumeDialog::OnOK(void)
* Verify their selection.
*/
void
OpenVolumeDialog::OnOK(void)
{ {
/* /*
* Figure out the (zero-based) drive letter. * Figure out the (zero-based) drive letter.
@ -714,22 +667,12 @@ OpenVolumeDialog::OnOK(void)
} }
} }
void OpenVolumeDialog::OnHelp(void)
/*
* User pressed the "Help" button.
*/
void
OpenVolumeDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_OPEN_VOLUME, HELP_CONTEXT); WinHelp(HELP_TOPIC_OPEN_VOLUME, HELP_CONTEXT);
} }
void OpenVolumeDialog::ForceReadOnly(bool readOnly) const
/*
* Set the state of the "read only" checkbox in the dialog.
*/
void
OpenVolumeDialog::ForceReadOnly(bool readOnly) const
{ {
CButton* pButton = (CButton*) GetDlgItem(IDC_OPENVOL_READONLY); CButton* pButton = (CButton*) GetDlgItem(IDC_OPENVOL_READONLY);
ASSERT(pButton != NULL); ASSERT(pButton != NULL);
@ -738,5 +681,5 @@ OpenVolumeDialog::ForceReadOnly(bool readOnly) const
pButton->SetCheck(BST_CHECKED); pButton->SetCheck(BST_CHECKED);
else else
pButton->SetCheck(BST_UNCHECKED); pButton->SetCheck(BST_UNCHECKED);
LOGI("FORCED READ ONLY %d", readOnly); LOGW("FORCED READ ONLY %d", readOnly);
} }

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Class definition for Open Volume dialog.
*/
#ifndef APP_OPENVOLUMEDIALOG_H #ifndef APP_OPENVOLUMEDIALOG_H
#define APP_OPENVOLUMEDIALOG_H #define APP_OPENVOLUMEDIALOG_H
@ -36,27 +33,66 @@ public:
bool fAllowROChange; bool fAllowROChange;
protected: protected:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
virtual void OnOK(void); virtual void OnOK(void) override;
afx_msg void OnHelp(void); /*
* Something changed in the list. Update the "OK" button.
*/
afx_msg void OnListChange(NMHDR* pNotifyStruct, LRESULT* pResult); afx_msg void OnListChange(NMHDR* pNotifyStruct, LRESULT* pResult);
afx_msg void OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult);
/*
* The volume filter drop-down box has changed.
*/
afx_msg void OnVolumeFilterSelChange(void); afx_msg void OnVolumeFilterSelChange(void);
afx_msg void OnHelp(void);
afx_msg void OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult);
// 0 is default; numbers must match up with pop-up menu order // 0 is default; numbers must match up with pop-up menu order
// order also matters for range test in OnInitDialog // order also matters for range test in OnInitDialog
enum { kBoth=0, kLogical=1, kPhysical=2 }; enum { kBoth=0, kLogical=1, kPhysical=2 };
// common constants // common constants
enum { kMaxLogicalDrives = 26, kMaxPhysicalDrives = 8 }; enum { kMaxLogicalDrives = 26, kMaxPhysicalDrives = 8 };
/*
* Load the set of logical and physical drives.
*/
void LoadDriveList(void); void LoadDriveList(void);
/*
* Determine the logical volumes available in the system and stuff them into
* the list.
*/
bool LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex); bool LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex);
/*
* Add a list of physical drives to the list control.
*/
bool LoadPhysicalDriveList(CListCtrl* pListView, int* pItemIndex); bool LoadPhysicalDriveList(CListCtrl* pListView, int* pItemIndex);
/*
* Determine whether physical device N exists.
*
* Pass in the Int13 unit number, i.e. 0x00 for the first floppy drive. Win9x
* makes direct access to the hard drive very difficult, so we don't even try.
*
* TODO: remove this entirely?
*/
bool HasPhysicalDriveWin9x(int unit, CString* pRemark); bool HasPhysicalDriveWin9x(int unit, CString* pRemark);
/*
* Determine whether physical device N exists.
*
* Pass in the Int13 unit number, i.e. 0x80 for the first hard drive. This
* should not be called with units for floppy drives (e.g. 0x00).
*/
bool HasPhysicalDriveWin2K(int unit, CString* pRemark); bool HasPhysicalDriveWin2K(int unit, CString* pRemark);
/*
* Set the state of the "read only" checkbox in the dialog.
*/
void ForceReadOnly(bool readOnly) const; void ForceReadOnly(bool readOnly) const;
struct { struct {

View File

@ -27,12 +27,12 @@ PasteSpecialDialog::OnInitDialog(void)
} }
#endif #endif
/* void PasteSpecialDialog::DoDataExchange(CDataExchange* pDX)
* Initialize radio control with value from fPasteHow.
*/
void
PasteSpecialDialog::DoDataExchange(CDataExchange* pDX)
{ {
/*
* Initialize radio control with value from fPasteHow.
*/
if (!pDX->m_bSaveAndValidate) { if (!pDX->m_bSaveAndValidate) {
UINT ctrlId; UINT ctrlId;

View File

@ -33,7 +33,7 @@ public:
protected: protected:
//virtual BOOL OnInitDialog(void); //virtual BOOL OnInitDialog(void);
void DoDataExchange(CDataExchange* pDX); void DoDataExchange(CDataExchange* pDX) override;
//DECLARE_MESSAGE_MAP() //DECLARE_MESSAGE_MAP()
}; };

View File

@ -12,7 +12,7 @@
#include "MyApp.h" #include "MyApp.h"
#include "../util/UtilLib.h" #include "../util/UtilLib.h"
static const char* kDefaultTempPath = "."; static const WCHAR kDefaultTempPath[] = L".";
/* registry section for columns */ /* registry section for columns */
static const WCHAR kColumnSect[] = L"columns"; static const WCHAR kColumnSect[] = L"columns";
@ -44,7 +44,7 @@ static const WCHAR kMiscSect[] = L"misc";
* index into the table. * index into the table.
*/ */
const Preferences::PrefMap Preferences::fPrefMaps[kPrefNumLastEntry] = { const Preferences::PrefMap Preferences::fPrefMaps[kPrefNumLastEntry] = {
/**/ { kPrefNumUnknown, kPTNone, NULL, NULL }, /**/ { kPrefNumUnknown, kPTNone, NULL, NULL },
{ kPrAddIncludeSubFolders, kBool, kAddSect, L"include-sub-folders" }, { kPrAddIncludeSubFolders, kBool, kAddSect, L"include-sub-folders" },
{ kPrAddStripFolderNames, kBool, kAddSect, L"strip-folder-names" }, { kPrAddStripFolderNames, kBool, kAddSect, L"strip-folder-names" },
@ -146,10 +146,6 @@ const Preferences::PrefMap Preferences::fPrefMaps[kPrefNumLastEntry] = {
{ kPrDiskImageCreateFormat, kLong, NULL, NULL }, { kPrDiskImageCreateFormat, kLong, NULL, NULL },
}; };
/*
* Constructor. There should be only one Preferences object in the
* application, so this should only be run once.
*/
Preferences::Preferences(void) Preferences::Preferences(void)
{ {
LOGI("Initializing Preferences"); LOGI("Initializing Preferences");
@ -268,11 +264,7 @@ Preferences::Preferences(void)
* ========================================================================== * ==========================================================================
*/ */
/* void ColumnLayout::LoadFromRegistry(const WCHAR* section)
* Restore column widths.
*/
void
ColumnLayout::LoadFromRegistry(const WCHAR* section)
{ {
WCHAR numBuf[8]; WCHAR numBuf[8];
int i; int i;
@ -289,11 +281,7 @@ ColumnLayout::LoadFromRegistry(const WCHAR* section)
fAscending = (gMyApp.GetProfileInt(section, L"ascending", fAscending) != 0); fAscending = (gMyApp.GetProfileInt(section, L"ascending", fAscending) != 0);
} }
/* void ColumnLayout::SaveToRegistry(const WCHAR* section)
* Store column widths.
*/
void
ColumnLayout::SaveToRegistry(const WCHAR* section)
{ {
WCHAR numBuf[8]; WCHAR numBuf[8];
int i; int i;
@ -314,11 +302,7 @@ ColumnLayout::SaveToRegistry(const WCHAR* section)
* ========================================================================== * ==========================================================================
*/ */
/* void Preferences::InitTempPath(void)
* Get a default value for the temp path.
*/
void
Preferences::InitTempPath(void)
{ {
WCHAR buf[MAX_PATH]; WCHAR buf[MAX_PATH];
DWORD len; DWORD len;
@ -351,11 +335,7 @@ Preferences::InitTempPath(void)
// ::GetCurrentDirectory(sizeof(buf2), buf2); // ::GetCurrentDirectory(sizeof(buf2), buf2);
} }
/* void Preferences::InitFolders(void)
* Set default values for the various folders.
*/
void
Preferences::InitFolders(void)
{ {
CString path; CString path;
@ -375,14 +355,10 @@ Preferences::InitFolders(void)
SetPrefString(kPrOpenWAVFolder, buf); SetPrefString(kPrOpenWAVFolder, buf);
} }
LOGI("Default folder is '%ls'", GetPrefString(kPrExtractFileFolder)); LOGD("Default folder is '%ls'", GetPrefString(kPrExtractFileFolder));
} }
/* bool Preferences::GetMyDocuments(CString* pPath)
* Get the path to the "My Documents" folder.
*/
bool
Preferences::GetMyDocuments(CString* pPath)
{ {
LPITEMIDLIST pidl = NULL; LPITEMIDLIST pidl = NULL;
LPMALLOC lpMalloc = NULL; LPMALLOC lpMalloc = NULL;
@ -395,13 +371,13 @@ Preferences::GetMyDocuments(CString* pPath)
hr = SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl); hr = SHGetSpecialFolderLocation(NULL, CSIDL_PERSONAL, &pidl);
if (FAILED(hr)) { if (FAILED(hr)) {
LOGI("WARNING: unable to get CSIDL_PERSONAL"); LOGW("WARNING: unable to get CSIDL_PERSONAL");
goto bail; goto bail;
} }
result = (Pidl::GetPath(pidl, pPath) != FALSE); result = (Pidl::GetPath(pidl, pPath) != FALSE);
if (!result) { if (!result) {
LOGI("WARNING: unable to convert CSIDL_PERSONAL to path"); LOGW("WARNING: unable to convert CSIDL_PERSONAL to path");
/* fall through with "result" */ /* fall through with "result" */
} }
@ -411,15 +387,7 @@ bail:
return result; return result;
} }
/* int Preferences::DefaultCompressionType(void)
* Determine the type of compression to use as a default, based on what this
* version of NufxLib supports.
*
* Note this happens *before* the AppInit call, so we should restrict this to
* things that are version-safe for all of NufxLib v2.x.
*/
int
Preferences::DefaultCompressionType(void)
{ {
if (NufxArchive::IsCompressionSupported(kNuThreadFormatLZW2)) if (NufxArchive::IsCompressionSupported(kNuThreadFormatLZW2))
return kNuThreadFormatLZW2; return kNuThreadFormatLZW2;
@ -427,47 +395,43 @@ Preferences::DefaultCompressionType(void)
return kNuThreadFormatUncompressed; return kNuThreadFormatUncompressed;
} }
/* bool Preferences::GetPrefBool(PrefNum num) const
* Preference getters and setters.
*/
bool
Preferences::GetPrefBool(PrefNum num) const
{ {
if (!ValidateEntry(num, kBool)) if (!ValidateEntry(num, kBool))
return false; return false;
//return (bool) (fValues[num]); //return (bool) (fValues[num]);
return (bool) ((long) (fValues[num]) != 0); return (bool) ((long) (fValues[num]) != 0);
} }
void
Preferences::SetPrefBool(PrefNum num, bool val) void Preferences::SetPrefBool(PrefNum num, bool val)
{ {
if (!ValidateEntry(num, kBool)) if (!ValidateEntry(num, kBool))
return; return;
fValues[num] = (void*) val; fValues[num] = (void*) val;
} }
long
Preferences::GetPrefLong(PrefNum num) const long Preferences::GetPrefLong(PrefNum num) const
{ {
if (!ValidateEntry(num, kLong)) if (!ValidateEntry(num, kLong))
return -1; return -1;
return (long) fValues[num]; return (long) fValues[num];
} }
void
Preferences::SetPrefLong(PrefNum num, long val) void Preferences::SetPrefLong(PrefNum num, long val)
{ {
if (!ValidateEntry(num, kLong)) if (!ValidateEntry(num, kLong))
return; return;
fValues[num] = (void*) val; fValues[num] = (void*) val;
} }
const WCHAR*
Preferences::GetPrefString(PrefNum num) const const WCHAR* Preferences::GetPrefString(PrefNum num) const
{ {
if (!ValidateEntry(num, kString)) if (!ValidateEntry(num, kString))
return NULL; return NULL;
return (const WCHAR*) fValues[num]; return (const WCHAR*) fValues[num];
} }
void
Preferences::SetPrefString(PrefNum num, const WCHAR* str) void Preferences::SetPrefString(PrefNum num, const WCHAR* str)
{ {
if (!ValidateEntry(num, kString)) if (!ValidateEntry(num, kString))
return; return;
@ -479,35 +443,23 @@ Preferences::SetPrefString(PrefNum num, const WCHAR* str)
} }
} }
/* void Preferences::FreeStringValues(void)
* Free storage for any string entries.
*/
void
Preferences::FreeStringValues(void)
{ {
int i; for (int i = 0; i < kPrefNumLastEntry; i++) {
for (i = 0; i < kPrefNumLastEntry; i++) {
if (fPrefMaps[i].type == kString) { if (fPrefMaps[i].type == kString) {
delete[] fValues[i]; delete[] fValues[i];
} }
} }
} }
void Preferences::ScanPrefMaps(void)
/*
* Do a quick scan of the PrefMaps to identify duplicate, misplaced, and
* missing entries.
*/
void
Preferences::ScanPrefMaps(void)
{ {
int i, j; int i, j;
/* scan PrefNum */ /* scan PrefNum */
for (i = 0; i < kPrefNumLastEntry; i++) { for (i = 0; i < kPrefNumLastEntry; i++) {
if (fPrefMaps[i].num != i) { if (fPrefMaps[i].num != i) {
LOGI("HEY: PrefMaps[%d] has num=%d", i, fPrefMaps[i].num); LOGE("HEY: PrefMaps[%d] has num=%d", i, fPrefMaps[i].num);
ASSERT(false); ASSERT(false);
break; break;
} }
@ -526,7 +478,7 @@ Preferences::ScanPrefMaps(void)
wcsicmp(fPrefMaps[i].registrySection, wcsicmp(fPrefMaps[i].registrySection,
fPrefMaps[j].registrySection) == 0) fPrefMaps[j].registrySection) == 0)
{ {
LOGI("HEY: PrefMaps[%d] and [%d] both have '%ls'/'%ls'", LOGE("HEY: PrefMaps[%d] and [%d] both have '%ls'/'%ls'",
i, j, fPrefMaps[i].registrySection, i, j, fPrefMaps[i].registrySection,
fPrefMaps[i].registryKey); fPrefMaps[i].registryKey);
ASSERT(false); ASSERT(false);
@ -536,11 +488,7 @@ Preferences::ScanPrefMaps(void)
} }
} }
/* int Preferences::LoadFromRegistry(void)
* Load preferences from the registry.
*/
int
Preferences::LoadFromRegistry(void)
{ {
CString sval; CString sval;
bool bval; bool bval;
@ -581,11 +529,7 @@ Preferences::LoadFromRegistry(void)
return 0; return 0;
} }
/* int Preferences::SaveToRegistry(void)
* Save preferences to the registry.
*/
int
Preferences::SaveToRegistry(void)
{ {
LOGI("Saving preferences to registry"); LOGI("Saving preferences to registry");

View File

@ -42,7 +42,14 @@ public:
} }
~ColumnLayout(void) {} ~ColumnLayout(void) {}
/*
* Restore column widths.
*/
void LoadFromRegistry(const WCHAR* section); void LoadFromRegistry(const WCHAR* section);
/*
* Store column widths.
*/
void SaveToRegistry(const WCHAR* section); void SaveToRegistry(const WCHAR* section);
int GetColumnWidth(int col) const { int GetColumnWidth(int col) const {
@ -212,18 +219,26 @@ typedef enum {
*/ */
class Preferences { class Preferences {
public: public:
/*
* There should be only one Preferences object in the
* application, so this should only be run once.
*/
Preferences(void); Preferences(void);
~Preferences(void) { ~Preferences(void) {
FreeStringValues(); FreeStringValues();
} }
// Load/save preferences from/to registry. /*
* Load preferences from the registry.
*/
int LoadFromRegistry(void); int LoadFromRegistry(void);
/*
* Save preferences to the registry.
*/
int SaveToRegistry(void); int SaveToRegistry(void);
ColumnLayout* GetColumnLayout(void) { return &fColumnLayout; } ColumnLayout* GetColumnLayout(void) { return &fColumnLayout; }
//bool GetShowToolbarText(void) const { return fShowToolbarText; }
//void SetShowToolbarText(bool val) { fShowToolbarText = val; }
bool GetPrefBool(PrefNum num) const; bool GetPrefBool(PrefNum num) const;
void SetPrefBool(PrefNum num, bool val); void SetPrefBool(PrefNum num, bool val);
@ -234,10 +249,33 @@ public:
private: private:
/*
* Get a default value for the temp path.
*/
void InitTempPath(void); void InitTempPath(void);
/*
* Set default values for the various folders.
*/
void InitFolders(void); void InitFolders(void);
/*
* Get the path to the "My Documents" folder.
*/
bool GetMyDocuments(CString* pPath); bool GetMyDocuments(CString* pPath);
/*
* Determine the type of compression to use as a default, based on what this
* version of NufxLib supports.
*
* Note this happens *before* the AppInit call, so we should restrict this to
* things that are version-safe for all of NufxLib v2.x.
*/
int DefaultCompressionType(void); int DefaultCompressionType(void);
/*
* Free storage for any string entries.
*/
void FreeStringValues(void); void FreeStringValues(void);
/* /*
@ -251,6 +289,11 @@ private:
const WCHAR* registryKey; const WCHAR* registryKey;
} PrefMap; } PrefMap;
static const PrefMap fPrefMaps[kPrefNumLastEntry]; static const PrefMap fPrefMaps[kPrefNumLastEntry];
/*
* Do a quick scan of the PrefMaps to identify duplicate, misplaced, and
* missing entries.
*/
void ScanPrefMaps(void); void ScanPrefMaps(void);
// this holds the actual values // this holds the actual values

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Implementation classes for the preferences property sheet
*/
#include "stdafx.h" #include "stdafx.h"
#include "PrefsDialog.h" #include "PrefsDialog.h"
#include "ChooseDirDialog.h" #include "ChooseDirDialog.h"
@ -39,33 +36,29 @@ BEGIN_MESSAGE_MAP(PrefsGeneralPage, CPropertyPage)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* void PrefsGeneralPage::OnChange(void)
* If they clicked on a checkbox, just mark the page as dirty so the "apply"
* button will be enabled.
*/
void
PrefsGeneralPage::OnChange(void)
{ {
/*
* They clicked on a checkbox, just mark the page as dirty so the "apply"
* button will be enabled.
*/
SetModified(TRUE); SetModified(TRUE);
} }
void
PrefsGeneralPage::OnChangeRange(UINT nID) void PrefsGeneralPage::OnChangeRange(UINT nID)
{ {
SetModified(TRUE); SetModified(TRUE);
} }
/* void PrefsGeneralPage::OnDefaults(void)
* Handle a click of the "defaults" button.
*
* Since we don't actually set column widths here, we need to tell the main
* window that the defaults button was pushed. It needs to reset all column
* widths to defaults, and then take into account any checking and un-checking
* that was done after "defaults" was pushed.
*/
void
PrefsGeneralPage::OnDefaults(void)
{ {
LOGI("DEFAULTS!"); /*
* Since we don't actually set column widths here, we need to tell the main
* window that the defaults button was pushed. It needs to reset all column
* widths to defaults, and then take into account any checking and un-checking
* that was done after "defaults" was pushed.
*/
LOGD("OnDefaults");
CButton* pButton; CButton* pButton;
@ -83,13 +76,7 @@ PrefsGeneralPage::OnDefaults(void)
SetModified(TRUE); SetModified(TRUE);
} }
/* void PrefsGeneralPage::OnAssociations(void)
* They clicked on "assocations". Bring up the association edit dialog.
* If they click "OK", make a copy of the changes and mark us as modified so
* the Apply/Cancel buttons behave as expected.
*/
void
PrefsGeneralPage::OnAssociations(void)
{ {
EditAssocDialog assocDlg; EditAssocDialog assocDlg;
@ -97,7 +84,11 @@ PrefsGeneralPage::OnAssociations(void)
fOurAssociations = NULL; fOurAssociations = NULL;
if (assocDlg.DoModal() == IDOK) { if (assocDlg.DoModal() == IDOK) {
// steal the modified associations /*
* Make a copy of the changes and mark us as modified so
* the Apply/Cancel buttons behave as expected. (We don't make
* a copy so much as steal the data from the dialog object.)
*/
delete[] fOurAssociations; delete[] fOurAssociations;
fOurAssociations = assocDlg.fOurAssociations; fOurAssociations = assocDlg.fOurAssociations;
assocDlg.fOurAssociations = NULL; assocDlg.fOurAssociations = NULL;
@ -105,15 +96,13 @@ PrefsGeneralPage::OnAssociations(void)
} }
} }
/* void PrefsGeneralPage::DoDataExchange(CDataExchange* pDX)
* Convert values.
*
* The various column checkboxes are independent. We still do the xfer
* for "pathname" even though it's disabled.
*/
void
PrefsGeneralPage::DoDataExchange(CDataExchange* pDX)
{ {
/*
* The various column checkboxes are independent. We still do the xfer
* for "pathname" even though it's disabled.
*/
fReady = true; fReady = true;
ASSERT(NELEM(fColumn) == 9); ASSERT(NELEM(fColumn) == 9);
@ -136,20 +125,13 @@ PrefsGeneralPage::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_PREF_SUCCESS_BEEP, fBeepOnSuccess); DDX_Check(pDX, IDC_PREF_SUCCESS_BEEP, fBeepOnSuccess);
} }
/* LONG PrefsGeneralPage::OnHelp(UINT wParam, LONG lParam)
* Context help request (question mark button).
*/
LONG
PrefsGeneralPage::OnHelp(UINT wParam, LONG lParam)
{ {
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/*
* User pressed the PropertySheet "Help" button. LONG PrefsGeneralPage::OnCommandHelp(UINT, LONG)
*/
LONG
PrefsGeneralPage::OnCommandHelp(UINT, LONG)
{ {
WinHelp(HELP_TOPIC_PREFS_GENERAL, HELP_CONTEXT); WinHelp(HELP_TOPIC_PREFS_GENERAL, HELP_CONTEXT);
return 0; // doesn't matter return 0; // doesn't matter
@ -172,38 +154,26 @@ BEGIN_MESSAGE_MAP(PrefsDiskImagePage, CPropertyPage)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp) ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL PrefsDiskImagePage::OnInitDialog(void)
* Set up our spin button.
*/
BOOL
PrefsDiskImagePage::OnInitDialog(void)
{ {
//LOGI("OnInit!"); //LOGI("OnInit!");
return CPropertyPage::OnInitDialog(); return CPropertyPage::OnInitDialog();
} }
/* void PrefsDiskImagePage::OnChange(void)
* Enable the "apply" button.
*/
void
PrefsDiskImagePage::OnChange(void)
{ {
LOGI("OnChange"); LOGD("OnChange");
SetModified(TRUE); SetModified(TRUE); // enable the "apply" button
} }
//void
//PrefsDiskImagePage::OnChangeRange(UINT nID) //void PrefsDiskImagePage::OnChangeRange(UINT nID)
//{ //{
// LOGI("OnChangeRange id=%d", nID); // LOGD("OnChangeRange id=%d", nID);
// SetModified(TRUE); // SetModified(TRUE);
//} //}
/* void PrefsDiskImagePage::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
PrefsDiskImagePage::DoDataExchange(CDataExchange* pDX)
{ {
fReady = true; fReady = true;
DDX_Check(pDX, IDC_PDISK_CONFIRM_FORMAT, fQueryImageFormat); DDX_Check(pDX, IDC_PDISK_CONFIRM_FORMAT, fQueryImageFormat);
@ -213,20 +183,13 @@ PrefsDiskImagePage::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_PDISK_PRODOS_USESPARSE, fProDOSUseSparse); DDX_Check(pDX, IDC_PDISK_PRODOS_USESPARSE, fProDOSUseSparse);
} }
/* LONG PrefsDiskImagePage::OnHelp(UINT wParam, LONG lParam)
* Context help request (question mark button).
*/
LONG
PrefsDiskImagePage::OnHelp(UINT wParam, LONG lParam)
{ {
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/*
* User pressed the PropertySheet "Help" button. LONG PrefsDiskImagePage::OnCommandHelp(UINT, LONG)
*/
LONG
PrefsDiskImagePage::OnCommandHelp(UINT, LONG)
{ {
WinHelp(HELP_TOPIC_PREFS_DISK_IMAGE, HELP_CONTEXT); WinHelp(HELP_TOPIC_PREFS_DISK_IMAGE, HELP_CONTEXT);
return 0; // doesn't matter return 0; // doesn't matter
@ -246,11 +209,7 @@ BEGIN_MESSAGE_MAP(PrefsCompressionPage, CPropertyPage)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL PrefsCompressionPage::OnInitDialog(void)
* Disable compression types not supported by the NufxLib DLL.
*/
BOOL
PrefsCompressionPage::OnInitDialog(void)
{ {
if (!NufxArchive::IsCompressionSupported(kNuThreadFormatHuffmanSQ)) { if (!NufxArchive::IsCompressionSupported(kNuThreadFormatHuffmanSQ)) {
DisableWnd(IDC_DEFC_SQUEEZE); DisableWnd(IDC_DEFC_SQUEEZE);
@ -293,11 +252,7 @@ PrefsCompressionPage::OnInitDialog(void)
return CPropertyPage::OnInitDialog(); return CPropertyPage::OnInitDialog();
} }
/* void PrefsCompressionPage::DisableWnd(int id)
* Disable a window in our dialog.
*/
void
PrefsCompressionPage::DisableWnd(int id)
{ {
CWnd* pWnd; CWnd* pWnd;
pWnd = GetDlgItem(id); pWnd = GetDlgItem(id);
@ -308,43 +263,30 @@ PrefsCompressionPage::DisableWnd(int id)
pWnd->EnableWindow(FALSE); pWnd->EnableWindow(FALSE);
} }
/* void PrefsCompressionPage::OnChangeRange(UINT nID)
* Enable the "apply" button.
*/
void
PrefsCompressionPage::OnChangeRange(UINT nID)
{ {
SetModified(TRUE); SetModified(TRUE); // enable the "apply" button
} }
/* void PrefsCompressionPage::DoDataExchange(CDataExchange* pDX)
* Convert values.
*
* Compression types match the NuThreadFormat enum in NufxLib.h, starting
* with IDC_DEFC_UNCOMPRESSED.
*/
void
PrefsCompressionPage::DoDataExchange(CDataExchange* pDX)
{ {
//LOGI("OnInit comp!"); /*
* Compression types match the NuThreadFormat enum in NufxLib.h, starting
* with IDC_DEFC_UNCOMPRESSED.
*/
LOGV("OnInit comp!");
fReady = true; fReady = true;
DDX_Radio(pDX, IDC_DEFC_UNCOMPRESSED, fCompressType); DDX_Radio(pDX, IDC_DEFC_UNCOMPRESSED, fCompressType);
} }
/* LONG PrefsCompressionPage::OnHelp(UINT wParam, LONG lParam)
* Context help request (question mark button).
*/
LONG
PrefsCompressionPage::OnHelp(UINT wParam, LONG lParam)
{ {
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/*
* User pressed the PropertySheet "Help" button. LONG PrefsCompressionPage::OnCommandHelp(UINT, LONG)
*/
LONG
PrefsCompressionPage::OnCommandHelp(UINT, LONG)
{ {
WinHelp(HELP_TOPIC_PREFS_COMPRESSION, HELP_CONTEXT); WinHelp(HELP_TOPIC_PREFS_COMPRESSION, HELP_CONTEXT);
return 0; // doesn't matter return 0; // doesn't matter
@ -366,16 +308,11 @@ BEGIN_MESSAGE_MAP(PrefsFviewPage, CPropertyPage)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp) ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL PrefsFviewPage::OnInitDialog(void)
* Set up our spin button.
*/
BOOL
PrefsFviewPage::OnInitDialog(void)
{ {
//LOGI("OnInit!");
CSpinButtonCtrl* pSpin; CSpinButtonCtrl* pSpin;
//LOGI("Configuring spin"); LOGV("Configuring spin");
pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_PVIEW_SIZE_SPIN); pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_PVIEW_SIZE_SPIN);
ASSERT(pSpin != NULL); ASSERT(pSpin != NULL);
@ -385,33 +322,24 @@ PrefsFviewPage::OnInitDialog(void)
uda.nInc = 64; uda.nInc = 64;
pSpin->SetRange(1, 32767); pSpin->SetRange(1, 32767);
pSpin->SetAccel(1, &uda); pSpin->SetAccel(1, &uda);
LOGI("OnInit done!"); LOGD("OnInit done!");
return CPropertyPage::OnInitDialog(); return CPropertyPage::OnInitDialog();
} }
/* void PrefsFviewPage::OnChange(void)
* Enable the "apply" button.
*/
void
PrefsFviewPage::OnChange(void)
{ {
LOGI("OnChange"); LOGD("OnChange");
SetModified(TRUE); SetModified(TRUE); // enable the "apply" button
} }
void
PrefsFviewPage::OnChangeRange(UINT nID) void PrefsFviewPage::OnChangeRange(UINT nID)
{ {
LOGI("OnChangeRange id=%d", nID); LOGD("OnChangeRange id=%d", nID);
SetModified(TRUE); SetModified(TRUE);
} }
void PrefsFviewPage::DoDataExchange(CDataExchange* pDX)
/*
* Convert values.
*/
void
PrefsFviewPage::DoDataExchange(CDataExchange* pDX)
{ {
fReady = true; fReady = true;
//DDX_Check(pDX, IDC_PVIEW_EOL_RAW, fEOLConvRaw); //DDX_Check(pDX, IDC_PVIEW_EOL_RAW, fEOLConvRaw);
@ -449,20 +377,13 @@ PrefsFviewPage::DoDataExchange(CDataExchange* pDX)
DDV_MinMaxUInt(pDX, fMaxViewFileSizeKB, 1, 32767); DDV_MinMaxUInt(pDX, fMaxViewFileSizeKB, 1, 32767);
} }
/* LONG PrefsFviewPage::OnHelp(UINT wParam, LONG lParam)
* Context help request (question mark button).
*/
LONG
PrefsFviewPage::OnHelp(UINT wParam, LONG lParam)
{ {
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/*
* User pressed the PropertySheet "Help" button. LONG PrefsFviewPage::OnCommandHelp(UINT, LONG)
*/
LONG
PrefsFviewPage::OnCommandHelp(UINT, LONG)
{ {
WinHelp(HELP_TOPIC_PREFS_FVIEW, HELP_CONTEXT); WinHelp(HELP_TOPIC_PREFS_FVIEW, HELP_CONTEXT);
return 0; // doesn't matter return 0; // doesn't matter
@ -484,11 +405,7 @@ BEGIN_MESSAGE_MAP(PrefsFilesPage, CPropertyPage)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL PrefsFilesPage::OnInitDialog(void)
* Set up the "choose folder" button.
*/
BOOL
PrefsFilesPage::OnInitDialog(void)
{ {
fChooseFolderButton.ReplaceDlgCtrl(this, IDC_PREF_CHOOSE_TEMP_FOLDER); fChooseFolderButton.ReplaceDlgCtrl(this, IDC_PREF_CHOOSE_TEMP_FOLDER);
fChooseFolderButton.SetBitmapID(IDB_CHOOSE_FOLDER); fChooseFolderButton.SetBitmapID(IDB_CHOOSE_FOLDER);
@ -496,20 +413,12 @@ PrefsFilesPage::OnInitDialog(void)
return CPropertyPage::OnInitDialog(); return CPropertyPage::OnInitDialog();
} }
/* void PrefsFilesPage::OnChange(void)
* Enable the "apply" button.
*/
void
PrefsFilesPage::OnChange(void)
{ {
SetModified(TRUE); SetModified(TRUE); // enable the "apply" button
} }
/* void PrefsFilesPage::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
PrefsFilesPage::DoDataExchange(CDataExchange* pDX)
{ {
fReady = true; fReady = true;
DDX_Text(pDX, IDC_PREF_TEMP_FOLDER, fTempPath); DDX_Text(pDX, IDC_PREF_TEMP_FOLDER, fTempPath);
@ -529,12 +438,12 @@ PrefsFilesPage::DoDataExchange(CDataExchange* pDX)
} }
} }
/* void PrefsFilesPage::OnChooseFolder(void)
* They want to choose the folder from a menu hierarchy. Show them a list.
*/
void
PrefsFilesPage::OnChooseFolder(void)
{ {
/*
* They want to choose the folder from a menu hierarchy. Show them a list.
*/
ChooseDirDialog chooseDir(this); ChooseDirDialog chooseDir(this);
CWnd* pEditWnd; CWnd* pEditWnd;
CString editPath; CString editPath;
@ -547,7 +456,7 @@ PrefsFilesPage::OnChooseFolder(void)
chooseDir.SetPathName(editPath); chooseDir.SetPathName(editPath);
if (chooseDir.DoModal() == IDOK) { if (chooseDir.DoModal() == IDOK) {
const WCHAR* ccp = chooseDir.GetPathName(); const WCHAR* ccp = chooseDir.GetPathName();
LOGI("New temp path chosen = '%ls'", ccp); LOGD("New temp path chosen = '%ls'", ccp);
pEditWnd->SetWindowText(ccp); pEditWnd->SetWindowText(ccp);
@ -556,20 +465,13 @@ PrefsFilesPage::OnChooseFolder(void)
} }
} }
/* LONG PrefsFilesPage::OnHelp(UINT wParam, LONG lParam)
* Context help request (question mark button).
*/
LONG
PrefsFilesPage::OnHelp(UINT wParam, LONG lParam)
{ {
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/*
* User pressed the PropertySheet "Help" button. LONG PrefsFilesPage::OnCommandHelp(UINT, LONG)
*/
LONG
PrefsFilesPage::OnCommandHelp(UINT, LONG)
{ {
WinHelp(HELP_TOPIC_PREFS_FILES, HELP_CONTEXT); WinHelp(HELP_TOPIC_PREFS_FILES, HELP_CONTEXT);
return 0; // doesn't matter return 0; // doesn't matter
@ -589,9 +491,6 @@ BEGIN_MESSAGE_MAP(PrefsSheet, CPropertySheet)
ON_MESSAGE(WM_HELP, OnHelp) ON_MESSAGE(WM_HELP, OnHelp)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/*
* Construct the preferences dialog from the individual pages.
*/
PrefsSheet::PrefsSheet(CWnd* pParentWnd) : PrefsSheet::PrefsSheet(CWnd* pParentWnd) :
CPropertySheet(L"Preferences", pParentWnd) CPropertySheet(L"Preferences", pParentWnd)
{ {
@ -605,31 +504,15 @@ PrefsSheet::PrefsSheet(CWnd* pParentWnd) :
//m_psh.dwFlags |= PSH_HASHELP; //m_psh.dwFlags |= PSH_HASHELP;
} }
/* BOOL PrefsSheet::OnNcCreate(LPCREATESTRUCT cs)
* Enable the context help button.
*
* We don't seem to get a PreCreateWindow or OnInitDialog, but we can
* intercept the WM_NCCREATE message and override the default behavior.
*/
BOOL
PrefsSheet::OnNcCreate(LPCREATESTRUCT cs)
{ {
//LOGI("PrefsSheet OnNcCreate"); LOGV("PrefsSheet OnNcCreate");
BOOL val = CPropertySheet::OnNcCreate(cs); BOOL val = CPropertySheet::OnNcCreate(cs);
ModifyStyleEx(0, WS_EX_CONTEXTHELP); ModifyStyleEx(0, WS_EX_CONTEXTHELP);
return val; return val;
} }
/* void PrefsSheet::OnApplyNow(void)
* Handle the "apply" button. We only want to process updates for property
* pages that have been constructed, and they only get constructed when
* the user clicks on them.
*
* We also have to watch out for DDV tests that should prevent the "apply"
* from succeeding, e.g. the file viewer size limit.
*/
void
PrefsSheet::OnApplyNow(void)
{ {
BOOL result; BOOL result;
@ -666,7 +549,7 @@ PrefsSheet::OnApplyNow(void)
} }
/* reset all to "unmodified" state */ /* reset all to "unmodified" state */
LOGI("All 'applies' were successful"); LOGD("All 'applies' were successful");
((MainWindow*) AfxGetMainWnd())->ApplyNow(this); ((MainWindow*) AfxGetMainWnd())->ApplyNow(this);
fGeneralPage.SetModified(FALSE); fGeneralPage.SetModified(FALSE);
fGeneralPage.fDefaultsPushed = false; fGeneralPage.fDefaultsPushed = false;
@ -676,36 +559,17 @@ PrefsSheet::OnApplyNow(void)
fFilesPage.SetModified(FALSE); fFilesPage.SetModified(FALSE);
} }
/* void PrefsSheet::OnIDHelp(void)
* Handle a press of the "Help" button by redirecting it back to ourselves
* as a WM_COMMANDHELP message. If we don't do this, the main window ends
* up getting our WM_COMMAND(ID_HELP) message.
*
* We still need to define an ID_HELP WM_COMMAND handler in the main window,
* or the CPropertySheet code refuses to believe that help is enabled for
* the application as a whole.
*
* The PropertySheet object handles the WM_COMMANDHELP message and redirects
* it to the active PropertyPage. Each page must handle WM_COMMANDHELP by
* opening an appropriate chapter in the help file.
*/
void
PrefsSheet::OnIDHelp(void)
{ {
LOGI("PrefsSheet OnIDHelp"); LOGD("PrefsSheet OnIDHelp");
SendMessage(WM_COMMANDHELP); SendMessage(WM_COMMANDHELP);
} }
/* LONG PrefsSheet::OnHelp(UINT wParam, LONG lParam)
* Context help request (question mark button) on something outside of the
* property page, most likely the Apply or Cancel button.
*/
LONG
PrefsSheet::OnHelp(UINT wParam, LONG lParam)
{ {
HELPINFO* lpHelpInfo = (HELPINFO*) lParam; HELPINFO* lpHelpInfo = (HELPINFO*) lParam;
LOGI("PrefsSheet OnHelp"); LOGD("PrefsSheet OnHelp");
DWORD context = lpHelpInfo->iCtrlId; DWORD context = lpHelpInfo->iCtrlId;
WinHelp(context, HELP_CONTEXTPOPUP); WinHelp(context, HELP_CONTEXTPOPUP);

View File

@ -51,7 +51,7 @@ public:
bool* fOurAssociations; bool* fOurAssociations;
protected: protected:
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void); afx_msg void OnChange(void);
afx_msg void OnChangeRange(UINT); afx_msg void OnChangeRange(UINT);
@ -87,8 +87,8 @@ public:
BOOL fProDOSUseSparse; BOOL fProDOSUseSparse;
protected: protected:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void); afx_msg void OnChange(void);
//afx_msg void OnChangeRange(UINT); //afx_msg void OnChangeRange(UINT);
@ -114,14 +114,21 @@ public:
int fCompressType; // radio button index int fCompressType; // radio button index
protected: protected:
virtual BOOL OnInitDialog(void); /*
virtual void DoDataExchange(CDataExchange* pDX); * Disable compression types not supported by the NufxLib DLL.
*/
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChangeRange(UINT); afx_msg void OnChangeRange(UINT);
afx_msg LONG OnHelp(UINT wParam, LONG lParam); afx_msg LONG OnHelp(UINT wParam, LONG lParam);
afx_msg LONG OnCommandHelp(UINT wParam, LONG lParam); afx_msg LONG OnCommandHelp(UINT wParam, LONG lParam);
private: private:
/*
* Disable a window in our dialog.
*/
void DisableWnd(int id); void DisableWnd(int id);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
@ -173,8 +180,8 @@ public:
UINT fMaxViewFileSizeKB; UINT fMaxViewFileSizeKB;
protected: protected:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void); afx_msg void OnChange(void);
afx_msg void OnChangeRange(UINT); afx_msg void OnChangeRange(UINT);
@ -201,8 +208,8 @@ public:
CString fExtViewerExts; CString fExtViewerExts;
protected: protected:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void); afx_msg void OnChange(void);
afx_msg void OnChooseFolder(void); afx_msg void OnChooseFolder(void);
@ -221,6 +228,9 @@ protected:
class PrefsSheet : public CPropertySheet class PrefsSheet : public CPropertySheet
{ {
public: public:
/*
* Construct the preferences dialog from the individual pages.
*/
PrefsSheet(CWnd* pParentWnd = NULL); PrefsSheet(CWnd* pParentWnd = NULL);
PrefsGeneralPage fGeneralPage; PrefsGeneralPage fGeneralPage;
@ -230,11 +240,44 @@ public:
PrefsFilesPage fFilesPage; PrefsFilesPage fFilesPage;
protected: protected:
BOOL OnNcCreate(LPCREATESTRUCT cs); /*
* Enables the context help button.
*
* We don't seem to get a PreCreateWindow or OnInitDialog, but we can
* intercept the WM_NCCREATE message and override the default behavior.
*/
afx_msg BOOL OnNcCreate(LPCREATESTRUCT cs);
/*
* Handle the "apply" button. We only want to process updates for property
* pages that have been constructed, and they only get constructed when
* the user clicks on them.
*
* We also have to watch out for DDV tests that should prevent the "apply"
* from succeeding, e.g. the file viewer size limit.
*/
afx_msg void OnApplyNow(); afx_msg void OnApplyNow();
LONG OnHelp(UINT wParam, LONG lParam);
void OnIDHelp(void); /*
* Handle a press of the "Help" button by redirecting it back to ourselves
* as a WM_COMMANDHELP message. If we don't do this, the main window ends
* up getting our WM_COMMAND(ID_HELP) message.
*
* We still need to define an ID_HELP WM_COMMAND handler in the main window,
* or the CPropertySheet code refuses to believe that help is enabled for
* the application as a whole.
*
* The PropertySheet object handles the WM_COMMANDHELP message and redirects
* it to the active PropertyPage. Each page must handle WM_COMMANDHELP by
* opening an appropriate chapter in the help file.
*/
afx_msg LONG OnHelp(UINT wParam, LONG lParam);
/*
* Context help request (question mark button) on something outside of the
* property page, most likely the Apply or Cancel button.
*/
afx_msg void OnIDHelp(void);
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
}; };

View File

@ -21,11 +21,7 @@
/*static*/ const WCHAR PrintStuff::kCourierNew[] = L"Courier New"; /*static*/ const WCHAR PrintStuff::kCourierNew[] = L"Courier New";
/*static*/ const WCHAR PrintStuff::kTimesNewRoman[] = L"Times New Roman"; /*static*/ const WCHAR PrintStuff::kTimesNewRoman[] = L"Times New Roman";
/* void PrintStuff::InitBasics(CDC* pDC)
* Set up various values.
*/
void
PrintStuff::InitBasics(CDC* pDC)
{ {
ASSERT(pDC != NULL); ASSERT(pDC != NULL);
ASSERT(fpDC == NULL); ASSERT(fpDC == NULL);
@ -44,11 +40,7 @@ PrintStuff::InitBasics(CDC* pDC)
fLogPixelsX, fLogPixelsY, fHorzRes, fVertRes); fLogPixelsX, fLogPixelsY, fHorzRes, fVertRes);
} }
/* void PrintStuff::CreateFontByNumLines(CFont* pFont, int numLines)
* Create a new font, based on the number of lines per page we need.
*/
void
PrintStuff::CreateFontByNumLines(CFont* pFont, int numLines)
{ {
ASSERT(pFont != NULL); ASSERT(pFont != NULL);
ASSERT(numLines > 0); ASSERT(numLines > 0);
@ -70,24 +62,14 @@ PrintStuff::CreateFontByNumLines(CFont* pFont, int numLines)
/*fpOldFont =*/ fpDC->SelectObject(pFont); /*fpOldFont =*/ fpDC->SelectObject(pFont);
} }
int PrintStuff::StringWidth(const CString& str)
/*
* Returns the width of the string.
*/
int
PrintStuff::StringWidth(const CString& str)
{ {
CSize size; CSize size;
size = fpDC->GetTextExtent(str); size = fpDC->GetTextExtent(str);
return size.cx; return size.cx;
} }
/* int PrintStuff::TrimString(CString* pStr, int width, bool addOnLeft)
* Trim a string to the specified number of pixels. If it's too large,
* ellipsis will be added on the left or right.
*/
int
PrintStuff::TrimString(CString* pStr, int width, bool addOnLeft)
{ {
static const char* kEllipsis = "..."; static const char* kEllipsis = "...";
CString newStr; CString newStr;
@ -138,11 +120,7 @@ PrintStuff::TrimString(CString* pStr, int width, bool addOnLeft)
* ========================================================================== * ==========================================================================
*/ */
/* void PrintContentList::Setup(CDC* pDC, CWnd* pParent)
* Calculate some constant values.
*/
void
PrintContentList::Setup(CDC* pDC, CWnd* pParent)
{ {
/* init base class */ /* init base class */
InitBasics(pDC); InitBasics(pDC);
@ -158,18 +136,14 @@ PrintContentList::Setup(CDC* pDC, CWnd* pParent)
fCharHeight = metrics.tmHeight + metrics.tmExternalLeading; fCharHeight = metrics.tmHeight + metrics.tmExternalLeading;
fLinesPerPage = fVertRes / fCharHeight; fLinesPerPage = fVertRes / fCharHeight;
LOGI("fVertRes=%d, fCharHeight=%d", fVertRes, fCharHeight); LOGD("fVertRes=%d, fCharHeight=%d", fVertRes, fCharHeight);
/* set up our slightly reduced lines per page */ /* set up our slightly reduced lines per page */
ASSERT(fLinesPerPage > kHeaderLines+1); ASSERT(fLinesPerPage > kHeaderLines+1);
fCLLinesPerPage = fLinesPerPage - kHeaderLines; fCLLinesPerPage = fLinesPerPage - kHeaderLines;
} }
/* void PrintContentList::CalcNumPages(void)
* Compute the number of pages in fpContentList.
*/
void
PrintContentList::CalcNumPages(void)
{ {
/* set up our local goodies */ /* set up our local goodies */
ASSERT(fpContentList != NULL); ASSERT(fpContentList != NULL);
@ -179,15 +153,10 @@ PrintContentList::CalcNumPages(void)
fNumPages = (numLines + fCLLinesPerPage -1) / fCLLinesPerPage; fNumPages = (numLines + fCLLinesPerPage -1) / fCLLinesPerPage;
ASSERT(fNumPages > 0); ASSERT(fNumPages > 0);
LOGI("Using numLines=%d, fNumPages=%d, fCLLinesPerPage=%d", LOGD("Using numLines=%d, fNumPages=%d, fCLLinesPerPage=%d",
numLines, fNumPages, fCLLinesPerPage); numLines, fNumPages, fCLLinesPerPage);
} }
/*
* Initiate printing of the specified list to the specified DC.
*
* Returns 0 if all went well, nonzero on cancellation or failure.
*/
int int
PrintContentList::Print(const ContentList* pContentList) PrintContentList::Print(const ContentList* pContentList)
{ {
@ -198,8 +167,9 @@ PrintContentList::Print(const ContentList* pContentList)
fToPage = fNumPages; fToPage = fNumPages;
return StartPrint(); return StartPrint();
} }
int
PrintContentList::Print(const ContentList* pContentList, int fromPage, int toPage) int PrintContentList::Print(const ContentList* pContentList, int fromPage,
int toPage)
{ {
fpContentList = pContentList; fpContentList = pContentList;
CalcNumPages(); CalcNumPages();
@ -209,11 +179,7 @@ PrintContentList::Print(const ContentList* pContentList, int fromPage, int toPag
return StartPrint(); return StartPrint();
} }
/* int PrintContentList::StartPrint(void)
* Kick off the print job.
*/
int
PrintContentList::StartPrint(void)
{ {
MainWindow* pMain = (MainWindow*)::AfxGetMainWnd(); MainWindow* pMain = (MainWindow*)::AfxGetMainWnd();
BOOL bres; BOOL bres;
@ -276,14 +242,7 @@ bail:
return result; return result;
} }
int PrintContentList::DoPrint(void)
/*
* Print all pages.
*
* Returns 0 on success, nonzero on failure.
*/
int
PrintContentList::DoPrint(void)
{ {
LOGI("Printing from page=%d to page=%d", fFromPage, fToPage); LOGI("Printing from page=%d to page=%d", fFromPage, fToPage);
@ -311,11 +270,7 @@ PrintContentList::DoPrint(void)
return 0; return 0;
} }
/* void PrintContentList::DoPrintPage(int page)
* Print page N of the content list, where N is a 1-based count.
*/
void
PrintContentList::DoPrintPage(int page)
{ {
/* /*
* Column widths, on an arbitrary scale. These will be * Column widths, on an arbitrary scale. These will be
@ -347,7 +302,7 @@ PrintContentList::DoPrintPage(int page)
totalWidth += kColumnWidths[i].width; totalWidth += kColumnWidths[i].width;
widthMult = (float) fHorzRes / totalWidth; widthMult = (float) fHorzRes / totalWidth;
LOGI("totalWidth=%d, fHorzRes=%d, mult=%.3f", LOGD("totalWidth=%d, fHorzRes=%d, mult=%.3f",
totalWidth, fHorzRes, widthMult); totalWidth, fHorzRes, widthMult);
/* /*
@ -430,11 +385,7 @@ PrintContentList::DoPrintPage(int page)
* ========================================================================== * ==========================================================================
*/ */
/* void PrintRichEdit::Setup(CDC* pDC, CWnd* pParent)
* Calculate some constant values.
*/
void
PrintRichEdit::Setup(CDC* pDC, CWnd* pParent)
{ {
/* preflighting can cause this to be initialized twice */ /* preflighting can cause this to be initialized twice */
fpDC = NULL; fpDC = NULL;
@ -462,11 +413,7 @@ PrintRichEdit::Setup(CDC* pDC, CWnd* pParent)
fInitialized = true; fInitialized = true;
} }
/* int PrintRichEdit::PrintPreflight(CRichEditCtrl* pREC, int* pNumPages)
* Pre-flight the print process to get the number of pages.
*/
int
PrintRichEdit::PrintPreflight(CRichEditCtrl* pREC, int* pNumPages)
{ {
fStartChar = 0; fStartChar = 0;
fEndChar = -1; fEndChar = -1;
@ -475,11 +422,7 @@ PrintRichEdit::PrintPreflight(CRichEditCtrl* pREC, int* pNumPages)
return StartPrint(pREC, L"(test)", pNumPages, false); return StartPrint(pREC, L"(test)", pNumPages, false);
} }
/* int PrintRichEdit::PrintAll(CRichEditCtrl* pREC, const WCHAR* title)
* Print all pages.
*/
int
PrintRichEdit::PrintAll(CRichEditCtrl* pREC, const WCHAR* title)
{ {
fStartChar = 0; fStartChar = 0;
fEndChar = -1; fEndChar = -1;
@ -488,11 +431,7 @@ PrintRichEdit::PrintAll(CRichEditCtrl* pREC, const WCHAR* title)
return StartPrint(pREC, title, NULL, true); return StartPrint(pREC, title, NULL, true);
} }
/* int PrintRichEdit::PrintPages(CRichEditCtrl* pREC, const WCHAR* title,
* Print a range of pages.
*/
int
PrintRichEdit::PrintPages(CRichEditCtrl* pREC, const WCHAR* title,
int startPage, int endPage) int startPage, int endPage)
{ {
fStartChar = 0; fStartChar = 0;
@ -502,11 +441,7 @@ PrintRichEdit::PrintPages(CRichEditCtrl* pREC, const WCHAR* title,
return StartPrint(pREC, title, NULL, true); return StartPrint(pREC, title, NULL, true);
} }
/* int PrintRichEdit::PrintSelection(CRichEditCtrl* pREC, const WCHAR* title,
* Print the selected area.
*/
int
PrintRichEdit::PrintSelection(CRichEditCtrl* pREC, const WCHAR* title,
long startChar, long endChar) long startChar, long endChar)
{ {
fStartChar = startChar; fStartChar = startChar;
@ -516,11 +451,7 @@ PrintRichEdit::PrintSelection(CRichEditCtrl* pREC, const WCHAR* title,
return StartPrint(pREC, title, NULL, true); return StartPrint(pREC, title, NULL, true);
} }
/* int PrintRichEdit::StartPrint(CRichEditCtrl* pREC, const WCHAR* title,
* Start the printing process by posting a print-cancel dialog.
*/
int
PrintRichEdit::StartPrint(CRichEditCtrl* pREC, const WCHAR* title,
int* pNumPages, bool doPrint) int* pNumPages, bool doPrint)
{ {
CancelDialog* pPCD = NULL; CancelDialog* pPCD = NULL;
@ -554,11 +485,7 @@ PrintRichEdit::StartPrint(CRichEditCtrl* pREC, const WCHAR* title,
return result; return result;
} }
/* void PrintRichEdit::PrintPrep(FORMATRANGE* pFR)
* Do some prep work before printing.
*/
void
PrintRichEdit::PrintPrep(FORMATRANGE* pFR)
{ {
CFont* pOldFont; CFont* pOldFont;
@ -607,14 +534,7 @@ PrintRichEdit::PrintPrep(FORMATRANGE* pFR)
pFR->chrg.cpMax = fEndChar; pFR->chrg.cpMax = fEndChar;
} }
/* void PrintRichEdit::ComputeMargins(void)
* Compute the size of the left and right margins, based on the width of 80
* characters of 10-point Courier New on the current printer.
*
* Sets fLeftMargin and fRightMargin, in printer DC pixels.
*/
void
PrintRichEdit::ComputeMargins(void)
{ {
CFont tmpFont; CFont tmpFont;
CFont* pOldFont; CFont* pOldFont;
@ -662,13 +582,8 @@ PrintRichEdit::ComputeMargins(void)
} }
} }
/* // This was derived from Microsoft KB article 129860.
* Send the contents of the rich edit control to the printer DC. int PrintRichEdit::DoPrint(CRichEditCtrl* pREC, const WCHAR* title,
*
* This was derived from Microsft KB article 129860.
*/
int
PrintRichEdit::DoPrint(CRichEditCtrl* pREC, const WCHAR* title,
int* pNumPages, bool doPrint) int* pNumPages, bool doPrint)
{ {
FORMATRANGE fr; FORMATRANGE fr;
@ -723,7 +638,7 @@ PrintRichEdit::DoPrint(CRichEditCtrl* pREC, const WCHAR* title,
#endif #endif
extdTextLength = (long)::SendMessage(pREC->m_hWnd, EM_GETTEXTLENGTHEX, extdTextLength = (long)::SendMessage(pREC->m_hWnd, EM_GETTEXTLENGTHEX,
(WPARAM) &exLenReq, (LPARAM) NULL); (WPARAM) &exLenReq, (LPARAM) NULL);
LOGI("RichEdit text length: std=%ld extd=%ld", LOGD("RichEdit text length: std=%ld extd=%ld",
basicTextLength, extdTextLength); basicTextLength, extdTextLength);
if (fEndChar == -1) { if (fEndChar == -1) {
@ -734,13 +649,13 @@ PrintRichEdit::DoPrint(CRichEditCtrl* pREC, const WCHAR* title,
} else } else
textLength = fEndChar - fStartChar; textLength = fEndChar - fStartChar;
LOGI(" +++ starting while loop, textLength=%ld", textLength); LOGD(" +++ starting while loop, textLength=%ld", textLength);
pageNum = 0; pageNum = 0;
lastTextPrinted = -1; lastTextPrinted = -1;
do { do {
bool skipPage = false; bool skipPage = false;
pageNum++; pageNum++;
LOGI(" +++ while loop: pageNum is %d", pageNum); LOGD(" +++ while loop: pageNum is %d", pageNum);
if (fEndPage > 0) { if (fEndPage > 0) {
if (pageNum < fStartPage) if (pageNum < fStartPage)
@ -776,12 +691,12 @@ PrintRichEdit::DoPrint(CRichEditCtrl* pREC, const WCHAR* title,
/* print a page full of RichEdit stuff */ /* print a page full of RichEdit stuff */
textPrinted = pREC->FormatRange(&fr, doPrint && !skipPage); textPrinted = pREC->FormatRange(&fr, doPrint && !skipPage);
LOGI(" +++ returned from FormatRange (textPrinted=%d)", LOGD(" +++ returned from FormatRange (textPrinted=%d)",
textPrinted); textPrinted);
if (textPrinted <= lastTextPrinted) { if (textPrinted <= lastTextPrinted) {
/* the earlier StartPage can't be undone, so we'll get an /* the earlier StartPage can't be undone, so we'll get an
extra blank page at the very end */ extra blank page at the very end */
LOGI("GLITCH: no new text printed (printed=%ld, last=%ld, len=%ld)", LOGW("GLITCH: no new text printed (printed=%ld, last=%ld, len=%ld)",
textPrinted, lastTextPrinted, textLength); textPrinted, lastTextPrinted, textLength);
pageNum--; // fix page count estimator pageNum--; // fix page count estimator
break; break;
@ -806,9 +721,9 @@ PrintRichEdit::DoPrint(CRichEditCtrl* pREC, const WCHAR* title,
} }
} while (textPrinted < textLength); } while (textPrinted < textLength);
//LOGI(" +++ calling FormatRange(NULL, FALSE)"); LOGV(" +++ calling FormatRange(NULL, FALSE)");
pREC->FormatRange(NULL, FALSE); pREC->FormatRange(NULL, FALSE);
//LOGI(" +++ returned from final FormatRange"); LOGV(" +++ returned from final FormatRange");
if (doPrint) if (doPrint)
fpDC->EndDoc(); fpDC->EndDoc();

View File

@ -24,13 +24,21 @@ protected:
/* get basic goodies, based on the DC */ /* get basic goodies, based on the DC */
virtual void InitBasics(CDC* pDC); virtual void InitBasics(CDC* pDC);
// Trim a string until it's <= width; returns final width. /*
* Trim a string to the specified number of pixels. If it's too large,
* ellipsis will be added on the left or right. Returns final width.
*/
int TrimString(CString* pStr, int width, bool addOnLeft = false); int TrimString(CString* pStr, int width, bool addOnLeft = false);
// Fills in blank "pFont" object with font that tries to get us N /*
// lines per page. * Fills in blank "pFont" object with font that tries to get us N
* lines per page.
*/
void CreateFontByNumLines(CFont* pFont, int numLines); void CreateFontByNumLines(CFont* pFont, int numLines);
/*
* Returns the width of the string.
*/
int StringWidth(const CString& str); int StringWidth(const CString& str);
static const WCHAR kCourierNew[]; static const WCHAR kCourierNew[];
@ -64,7 +72,13 @@ public:
/* set the DC and the parent window (for the cancel box) */ /* set the DC and the parent window (for the cancel box) */
virtual void Setup(CDC* pDC, CWnd* pParent); virtual void Setup(CDC* pDC, CWnd* pParent);
/*
* Initiate printing of the specified list to the configured DC.
*
* Returns 0 if all went well, nonzero on cancellation or failure.
*/
int Print(const ContentList* pContentList); int Print(const ContentList* pContentList);
int Print(const ContentList* pContentList, int fromPage, int toPage); int Print(const ContentList* pContentList, int fromPage, int toPage);
/* this is used to set up the page range selection in print dialog */ /* this is used to set up the page range selection in print dialog */
@ -73,9 +87,26 @@ public:
} }
private: private:
/*
* Compute the number of pages in fpContentList.
*/
void CalcNumPages(void); void CalcNumPages(void);
/*
* Kick off the print job.
*/
int StartPrint(void); int StartPrint(void);
/*
* Print all pages.
*
* Returns 0 on success, nonzero on failure.
*/
int DoPrint(void); int DoPrint(void);
/*
* Print page N of the content list, where N is a 1-based count.
*/
void DoPrintPage(int page); void DoPrintPage(int page);
enum { enum {
@ -110,20 +141,50 @@ public:
virtual void Setup(CDC* pDC, CWnd* pParent); virtual void Setup(CDC* pDC, CWnd* pParent);
/* /*
* Commence printing. * Pre-flight the print process to get the number of pages.
*/ */
int PrintPreflight(CRichEditCtrl* pREC, int* pNumPages); int PrintPreflight(CRichEditCtrl* pREC, int* pNumPages);
/*
* Print all pages.
*/
int PrintAll(CRichEditCtrl* pREC, const WCHAR* title); int PrintAll(CRichEditCtrl* pREC, const WCHAR* title);
/*
* Print a range of pages.
*/
int PrintPages(CRichEditCtrl* pREC, const WCHAR* title, int startPage, int PrintPages(CRichEditCtrl* pREC, const WCHAR* title, int startPage,
int endPage); int endPage);
/*
* Print the selected area.
*/
int PrintSelection(CRichEditCtrl* pREC, const WCHAR* title, long startChar, int PrintSelection(CRichEditCtrl* pREC, const WCHAR* title, long startChar,
long endChar); long endChar);
private: private:
/*
* Start the printing process by posting a print-cancel dialog.
*/
int StartPrint(CRichEditCtrl* pREC, const WCHAR* title, int StartPrint(CRichEditCtrl* pREC, const WCHAR* title,
int* pNumPages, bool doPrint); int* pNumPages, bool doPrint);
/*
* Do some prep work before printing.
*/
void PrintPrep(FORMATRANGE* pFR); void PrintPrep(FORMATRANGE* pFR);
/*
* Compute the size of the left and right margins, based on the width of 80
* characters of 10-point Courier New on the current printer.
*
* Sets fLeftMargin and fRightMargin, in printer DC pixels.
*/
void ComputeMargins(void); void ComputeMargins(void);
/*
* Send the contents of the rich edit control to the printer DC.
*/
int DoPrint(CRichEditCtrl* pREC, const WCHAR* title, int* pNumPages, int DoPrint(CRichEditCtrl* pREC, const WCHAR* title, int* pNumPages,
bool doPrint); bool doPrint);

View File

@ -29,6 +29,7 @@ public:
return CancelDialog::Create(&fCancel, IDD_PROGRESS_COUNTER, return CancelDialog::Create(&fCancel, IDD_PROGRESS_COUNTER,
pParentWnd); pParentWnd);
} }
/* enable the parent window before we're destroyed */ /* enable the parent window before we're destroyed */
virtual BOOL DestroyWindow(void) { virtual BOOL DestroyWindow(void) {
if (fpParentWnd != NULL) if (fpParentWnd != NULL)
@ -50,7 +51,7 @@ public:
bool GetCancel(void) const { return fCancel; } bool GetCancel(void) const { return fCancel; }
private: private:
BOOL OnInitDialog(void) { BOOL OnInitDialog(void) override {
CancelDialog::OnInitDialog(); CancelDialog::OnInitDialog();
CWnd* pWnd = GetDlgItem(IDC_PROGRESS_COUNTER_DESC); CWnd* pWnd = GetDlgItem(IDC_PROGRESS_COUNTER_DESC);

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for RecompressOptionsDialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "RecompressOptionsDialog.h" #include "RecompressOptionsDialog.h"
#include "NufxArchive.h" #include "NufxArchive.h"
@ -17,25 +14,14 @@
//END_MESSAGE_MAP() //END_MESSAGE_MAP()
/* BOOL RecompressOptionsDialog::OnInitDialog(void)
* Set up our modified version of the "use selection" dialog.
*/
BOOL
RecompressOptionsDialog::OnInitDialog(void)
{ {
fCompressionIdx = LoadComboBox((NuThreadFormat) fCompressionType); fCompressionIdx = LoadComboBox((NuThreadFormat) fCompressionType);
return UseSelectionDialog::OnInitDialog(); return UseSelectionDialog::OnInitDialog();
} }
/* int RecompressOptionsDialog::LoadComboBox(NuThreadFormat fmt)
* Load strings into the combo box. Only load formats supported by the
* NufxLib DLL.
*
* Returns the combo box index for the format matching "fmt".
*/
int
RecompressOptionsDialog::LoadComboBox(NuThreadFormat fmt)
{ {
static const struct { static const struct {
NuThreadFormat format; NuThreadFormat format;
@ -73,11 +59,7 @@ RecompressOptionsDialog::LoadComboBox(NuThreadFormat fmt)
return retIdx; return retIdx;
} }
/* void RecompressOptionsDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
RecompressOptionsDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_CBIndex(pDX, IDC_RECOMP_COMP, fCompressionIdx); DDX_CBIndex(pDX, IDC_RECOMP_COMP, fCompressionIdx);

View File

@ -30,9 +30,15 @@ public:
int fCompressionType; int fCompressionType;
private: private:
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* Load strings into the combo box. Only load formats supported by the
* NufxLib DLL.
*
* Returns the combo box index for the format matching "fmt".
*/
int LoadComboBox(NuThreadFormat fmt); int LoadComboBox(NuThreadFormat fmt);
int fCompressionIdx; // drop list index int fCompressionIdx; // drop list index

View File

@ -56,9 +56,9 @@ static const WCHAR kUserSettingsBaseKey[] =
/* /*
* Put one of these under the AppID to specify the icon for a file type. * Put one of these under the AppID to specify the icon for a file type.
*/ */
static const WCHAR* kDefaultIcon = L"DefaultIcon"; static const WCHAR kDefaultIcon[] = L"DefaultIcon";
static const WCHAR* kRegKeyCPKStr = L"CPK"; static const WCHAR kRegKeyCPKStr[] = L"CPK";
/* /*
* Table of file type associations. They will appear in the UI in the same * Table of file type associations. They will appear in the UI in the same
@ -110,16 +110,7 @@ static const struct {
* ========================================================================== * ==========================================================================
*/ */
/* void MyRegistry::OneTimeInstall(void) const
* This is called immediately after installation finishes.
*
* We want to snatch up any unused file type associations. We define them
* as "unused" if the entry does not exist in the registry at all. A more
* thorough installer would also verify that the appID actually existed
* and "steal" any apparent orphans, but we can let the user do that manually.
*/
void
MyRegistry::OneTimeInstall(void) const
{ {
/* start by stomping on our appIDs */ /* start by stomping on our appIDs */
LOGI(" Removing appIDs"); LOGI(" Removing appIDs");
@ -149,17 +140,7 @@ MyRegistry::OneTimeInstall(void) const
} }
} }
/* void MyRegistry::OneTimeUninstall(void) const
* Remove things that the standard uninstall script won't.
*
* We want to un-set any of our file associations. We don't really need to
* clean up the ".xxx" entries, because removing their appID entries is enough
* to fry their little brains, but it's probably the right thing to do.
*
* We definitely want to strip out our appIDs.
*/
void
MyRegistry::OneTimeUninstall(void) const
{ {
/* drop any associations we hold */ /* drop any associations we hold */
int i; int i;
@ -195,40 +176,29 @@ MyRegistry::OneTimeUninstall(void) const
* ========================================================================== * ==========================================================================
*/ */
/* const WCHAR* MyRegistry::GetAppRegistryKey(void) const
* Return the application's registry key. This is used as the argument to
* CWinApp::SetRegistryKey(). The GetProfile{Int,String} calls combine this
* (in m_pszRegistryKey) with the app name (in m_pszProfileName) and prepend
* "HKEY_CURRENT_USER\Software\".
*/
const WCHAR*
MyRegistry::GetAppRegistryKey(void) const
{ {
return kCompanyName; return kCompanyName;
} }
/* bool MyRegistry::IsOurAppID(const WCHAR* id) const
* See if an AppID is one we recognize.
*/
bool
MyRegistry::IsOurAppID(const WCHAR* id) const
{ {
return (wcsicmp(id, kAppIDNuFX) == 0 || return (wcsicmp(id, kAppIDNuFX) == 0 ||
wcsicmp(id, kAppIDDiskImage) == 0 || wcsicmp(id, kAppIDDiskImage) == 0 ||
wcsicmp(id, kAppIDBinaryII) == 0); wcsicmp(id, kAppIDBinaryII) == 0);
} }
/* void MyRegistry::FixBasicSettings(void) const
* Fix the basic registry settings, e.g. our AppID classes.
*
* We don't overwrite values that already exist. We want to hold on to the
* installer's settings, which should get whacked if the program is
* uninstalled or reinstalled. This is here for "installer-less" environments
* and to cope with registry damage.
*/
void
MyRegistry::FixBasicSettings(void) const
{ {
/*
* Fix the basic registry settings, e.g. our AppID classes.
*
* We don't overwrite values that already exist. We want to hold on to the
* installer's settings, which should get whacked if the program is
* uninstalled or reinstalled. This is here for "installer-less" environments
* and to cope with registry damage.
*/
const WCHAR* exeName = gMyApp.GetExeFileName(); const WCHAR* exeName = gMyApp.GetExeFileName();
ASSERT(exeName != NULL && wcslen(exeName) > 0); ASSERT(exeName != NULL && wcslen(exeName) > 0);
@ -239,11 +209,7 @@ MyRegistry::FixBasicSettings(void) const
ConfigureAppID(kAppIDDiskImage, L"Disk Image (CiderPress)", exeName, 3); ConfigureAppID(kAppIDDiskImage, L"Disk Image (CiderPress)", exeName, 3);
} }
/* void MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
* Set up the registry goodies for one appID.
*/
void
MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
const WCHAR* exeName, int iconIdx) const const WCHAR* exeName, int iconIdx) const
{ {
LOGI(" Configuring '%ls' for '%ls'", appID, exeName); LOGI(" Configuring '%ls' for '%ls'", appID, exeName);
@ -296,12 +262,7 @@ MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
RegCloseKey(hAppKey); RegCloseKey(hAppKey);
} }
/* void MyRegistry::ConfigureAppIDSubFields(HKEY hAppKey, const WCHAR* descr,
* Set up the current key's default (which is used as the explorer
* description) and put the "Open" command in "...\shell\open\command".
*/
void
MyRegistry::ConfigureAppIDSubFields(HKEY hAppKey, const WCHAR* descr,
const WCHAR* exeName) const const WCHAR* exeName) const
{ {
HKEY hShellKey, hOpenKey, hCommandKey; HKEY hShellKey, hOpenKey, hCommandKey;
@ -362,60 +323,24 @@ MyRegistry::ConfigureAppIDSubFields(HKEY hAppKey, const WCHAR* descr,
} }
/* int MyRegistry::GetNumFileAssocs(void) const
* Return the number of file type associations.
*/
int
MyRegistry::GetNumFileAssocs(void) const
{ {
return NELEM(kFileTypeAssoc); return NELEM(kFileTypeAssoc);
} }
#if 0 void MyRegistry::GetFileAssoc(int idx, CString* pExt, CString* pHandler,
/*
* Return information on a file association.
*
* Check to see if we're the application that will be launched.
*
* Problem: the file must *actually exist* for this to work.
*/
void
MyRegistry::GetFileAssoc(int idx, CString* pExt, CString* pHandler,
bool* pOurs) const bool* pOurs) const
{ {
char buf[MAX_PATH]; /*
* We check to see if the file extension is associated with one of our
* application ID strings. We don't bother to check whether the appID
* strings are still associated with CiderPress, since nobody should be
* messing with those.
*
* BUG: we should be checking to see what the shell actually does to
* take into account the overrides that users can set.
*/
*pExt = kFileTypeAssoc[idx].ext;
*pHandler = "";
*pOurs = false;
HINSTANCE res = FindExecutable(*pExt, "\\", buf);
if ((long) res > 32) {
LOGI("Executable is '%s'", buf);
*pHandler = buf;
} else {
LOGI("FindExecutable failed (err=%d)", res);
*pHandler = kNoAssociation;
}
}
#endif
/*
* Return information on a file association.
*
* We check to see if the file extension is associated with one of our
* application ID strings. We don't bother to check whether the appID
* strings are still associated with CiderPress, since nobody should be
* messing with those.
*
* BUG: we should be checking to see what the shell actually does to
* take into account the overrides that users can set.
*/
void
MyRegistry::GetFileAssoc(int idx, CString* pExt, CString* pHandler,
bool* pOurs) const
{
ASSERT(idx >= 0 && idx < NELEM(kFileTypeAssoc)); ASSERT(idx >= 0 && idx < NELEM(kFileTypeAssoc));
long res; long res;
@ -455,13 +380,7 @@ MyRegistry::GetFileAssoc(int idx, CString* pExt, CString* pHandler,
RegCloseKey(hExtKey); RegCloseKey(hExtKey);
} }
/* int MyRegistry::GetAssocAppName(const CString& appID, CString* pCmd) const
* Given an application ID, determine the application's name.
*
* This requires burrowing down into HKEY_CLASSES_ROOT\<appID>\shell\open\.
*/
int
MyRegistry::GetAssocAppName(const CString& appID, CString* pCmd) const
{ {
CString keyName; CString keyName;
WCHAR buf[260]; WCHAR buf[260];
@ -507,11 +426,7 @@ MyRegistry::GetAssocAppName(const CString& appID, CString* pCmd) const
return result; return result;
} }
/* void MyRegistry::ReduceToToken(CString* pStr) const
* Reduce a compound string to just its first token.
*/
void
MyRegistry::ReduceToToken(CString* pStr) const
{ {
WCHAR* argv[1]; WCHAR* argv[1];
int argc = 1; int argc = 1;
@ -525,19 +440,19 @@ MyRegistry::ReduceToToken(CString* pStr) const
free(mangle); free(mangle);
} }
/* int MyRegistry::SetFileAssoc(int idx, bool wantIt) const
* Set the state of a file association. There are four possibilities:
*
* - We own it, we want to keep owning it: do nothing.
* - We don't own it, we want to keep not owning it: do nothing.
* - We own it, we don't want it anymore: remove ".xxx" entry.
* - We don't own it, we want to own it: remove ".xxx" entry and replace it.
*
* Returns 0 on success, nonzero on failure.
*/
int
MyRegistry::SetFileAssoc(int idx, bool wantIt) const
{ {
/*
* Set the state of a file association. There are four possibilities:
*
* - We own it, we want to keep owning it: do nothing.
* - We don't own it, we want to keep not owning it: do nothing.
* - We own it, we don't want it anymore: remove ".xxx" entry.
* - We don't own it, we want to own it: remove ".xxx" entry and replace it.
*
* Returns 0 on success, nonzero on failure.
*/
const WCHAR* ext; const WCHAR* ext;
bool weOwnIt; bool weOwnIt;
int result = 0; int result = 0;
@ -564,15 +479,7 @@ MyRegistry::SetFileAssoc(int idx, bool wantIt) const
return 0; return 0;
} }
/* bool MyRegistry::GetAssocState(const WCHAR* ext) const
* Determine whether or not the filetype described by "ext" is one that we
* currently manage.
*
* Returns "true" if so, "false" if not. Returns "false" on any errors
* encountered.
*/
bool
MyRegistry::GetAssocState(const WCHAR* ext) const
{ {
WCHAR buf[260]; WCHAR buf[260];
HKEY hExtKey = NULL; HKEY hExtKey = NULL;
@ -596,15 +503,7 @@ MyRegistry::GetAssocState(const WCHAR* ext) const
return result; return result;
} }
/* int MyRegistry::DisownExtension(const WCHAR* ext) const
* Drop ownership of a file extension.
*
* We assume we own it.
*
* Returns 0 on success, -1 on error.
*/
int
MyRegistry::DisownExtension(const WCHAR* ext) const
{ {
ASSERT(ext != NULL); ASSERT(ext != NULL);
ASSERT(ext[0] == '.'); ASSERT(ext[0] == '.');
@ -614,20 +513,14 @@ MyRegistry::DisownExtension(const WCHAR* ext) const
if (RegDeleteKeyNT(HKEY_CLASSES_ROOT, ext) == ERROR_SUCCESS) { if (RegDeleteKeyNT(HKEY_CLASSES_ROOT, ext) == ERROR_SUCCESS) {
LOGI(" HKCR\\%ls subtree deleted", ext); LOGI(" HKCR\\%ls subtree deleted", ext);
} else { } else {
LOGI(" Failed deleting HKCR\\'%ls'", ext); LOGW(" Failed deleting HKCR\\'%ls'", ext);
return -1; return -1;
} }
return 0; return 0;
} }
/* int MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
* Take ownership of a file extension.
*
* Returns 0 on success, -1 on error.
*/
int
MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
{ {
ASSERT(ext != NULL); ASSERT(ext != NULL);
ASSERT(ext[0] == '.'); ASSERT(ext[0] == '.');
@ -645,7 +538,7 @@ MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
} else if (res == ERROR_FILE_NOT_FOUND) { } else if (res == ERROR_FILE_NOT_FOUND) {
LOGI(" No HKCR\\%ls subtree to delete", ext); LOGI(" No HKCR\\%ls subtree to delete", ext);
} else { } else {
LOGI(" Failed deleting HKCR\\'%ls'", ext); LOGW(" Failed deleting HKCR\\'%ls'", ext);
goto bail; goto bail;
} }
@ -660,7 +553,7 @@ MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
LOGI(" Set '%ls' to '%ls'", ext, appID); LOGI(" Set '%ls' to '%ls'", ext, appID);
result = 0; result = 0;
} else { } else {
LOGI("Failed setting '%ls' to '%ls' (res=%d)", ext, appID, res); LOGW("Failed setting '%ls' to '%ls' (res=%d)", ext, appID, res);
goto bail; goto bail;
} }
} }
@ -681,8 +574,7 @@ bail:
// Windows NT. This is by design. // Windows NT. This is by design.
// //
#define MAX_KEY_LENGTH 256 // not in any header I can find ++ATM #define MAX_KEY_LENGTH 256 // not in any header I can find ++ATM
DWORD DWORD MyRegistry::RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const
MyRegistry::RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const
{ {
DWORD dwRtn, dwSubKeyLength; DWORD dwRtn, dwSubKeyLength;
LPTSTR pSubKey = NULL; LPTSTR pSubKey = NULL;

View File

@ -28,7 +28,25 @@ public:
kRegFailed, // error occurred during registration kRegFailed, // error occurred during registration
} RegStatus; } RegStatus;
/*
* This is called immediately after installation finishes.
*
* We want to snatch up any unused file type associations. We define them
* as "unused" if the entry does not exist in the registry at all. A more
* thorough installer would also verify that the appID actually existed
* and "steal" any apparent orphans, but we can let the user do that manually.
*/
void OneTimeInstall(void) const; void OneTimeInstall(void) const;
/*
* Remove things that the standard uninstall script won't.
*
* We want to un-set any of our file associations. We don't really need to
* clean up the ".xxx" entries, because removing their appID entries is enough
* to fry their little brains, but it's probably the right thing to do.
*
* We definitely want to strip out our appIDs.
*/
void OneTimeUninstall(void) const; void OneTimeUninstall(void) const;
/* /*
@ -41,18 +59,34 @@ public:
const CString& company, const CString& reg); const CString& company, const CString& reg);
*/ */
// Get the registry key to be used for our application. /*
* Return the application's registry key. This is used as the argument to
* CWinApp::SetRegistryKey(). The GetProfile{Int,String} calls combine this
* (in m_pszRegistryKey) with the app name (in m_pszProfileName) and prepend
* "HKEY_CURRENT_USER\Software\".
*/
const WCHAR* GetAppRegistryKey(void) const; const WCHAR* GetAppRegistryKey(void) const;
// Fix basic settings, e.g. HKCR AppID classes. // Fix basic settings, e.g. HKCR AppID classes.
void FixBasicSettings(void) const; void FixBasicSettings(void) const;
/*
* Return the number of file type associations.
*/
int GetNumFileAssocs(void) const; int GetNumFileAssocs(void) const;
/*
* Return information on a file association.
*/
void GetFileAssoc(int idx, CString* pExt, CString* pHandler, void GetFileAssoc(int idx, CString* pExt, CString* pHandler,
bool* pOurs) const; bool* pOurs) const;
/*
* Sets the state of a file association.
*/
int SetFileAssoc(int idx, bool wantIt) const; int SetFileAssoc(int idx, bool wantIt) const;
static unsigned short ComputeStringCRC(const char* str); //static uint16_t ComputeStringCRC(const char* str);
private: private:
typedef struct FileTypeAssoc { typedef struct FileTypeAssoc {
@ -62,21 +96,65 @@ private:
static const FileTypeAssoc kFileTypeAssoc[]; static const FileTypeAssoc kFileTypeAssoc[];
/*
* See if an AppID is one we recognize.
*/
bool IsOurAppID(const WCHAR* id) const; bool IsOurAppID(const WCHAR* id) const;
/*
* Set up the registry goodies for one appID.
*/
void ConfigureAppID(const WCHAR* appID, const WCHAR* descr, void ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
const WCHAR* exeName, int iconIdx) const; const WCHAR* exeName, int iconIdx) const;
/*
* Set up the current key's default (which is used as the explorer
* description) and put the "Open" command in "...\shell\open\command".
*/
void ConfigureAppIDSubFields(HKEY hAppKey, const WCHAR* descr, void ConfigureAppIDSubFields(HKEY hAppKey, const WCHAR* descr,
const WCHAR* exeName) const; const WCHAR* exeName) const;
/*
* Given an application ID, determine the application's name.
*
* This requires burrowing down into HKEY_CLASSES_ROOT\<appID>\shell\open\.
*/
int GetAssocAppName(const CString& appID, CString* pCmd) const; int GetAssocAppName(const CString& appID, CString* pCmd) const;
/*
* Reduce a compound string to just its first token.
*/
void ReduceToToken(CString* pStr) const; void ReduceToToken(CString* pStr) const;
/*
* Determine whether or not the filetype described by "ext" is one that we
* currently manage.
*
* Returns "true" if so, "false" if not. Returns "false" on any errors
* encountered.
*/
bool GetAssocState(const WCHAR* ext) const; bool GetAssocState(const WCHAR* ext) const;
/*
* Drop ownership of a file extension. We assume we own it.
*
* Returns 0 on success, -1 on error.
*/
int DisownExtension(const WCHAR* ext) const; int DisownExtension(const WCHAR* ext) const;
/*
* Take ownership of a file extension.
*
* Returns 0 on success, -1 on error.
*/
int OwnExtension(const WCHAR* ext, const WCHAR* appID) const; int OwnExtension(const WCHAR* ext, const WCHAR* appID) const;
DWORD RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const; DWORD RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const;
/* key validation */ /* key validation */
static unsigned short CalcCRC16(unsigned short seed, //static uint16_t CalcCRC16(uint16_t seed,
const unsigned char* ptr, int count); // const uint8_t* ptr, int count);
static char* StripStrings(const char* str1, const char* str2); static char* StripStrings(const char* str1, const char* str2);
void ComputeKey(const char* chBuf, int salt, long* pKeyLo, long* pKeyHi); void ComputeKey(const char* chBuf, int salt, long* pKeyLo, long* pKeyHi);
int VerifyKey(const char* user, const char* company, const char* key); int VerifyKey(const char* user, const char* company, const char* key);

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Support for RenameEntryDialog.
*/
#include "stdafx.h" #include "stdafx.h"
#include "RenameEntryDialog.h" #include "RenameEntryDialog.h"
#include "HelpTopics.h" #include "HelpTopics.h"
@ -17,11 +14,7 @@ BEGIN_MESSAGE_MAP(RenameEntryDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL RenameEntryDialog::OnInitDialog(void)
* Set up the control.
*/
BOOL
RenameEntryDialog::OnInitDialog(void)
{ {
ASSERT(fBasePath.IsEmpty()); ASSERT(fBasePath.IsEmpty());
fOldFile = fOldName; fOldFile = fOldName;
@ -62,15 +55,10 @@ RenameEntryDialog::OnInitDialog(void)
return FALSE; // we set the focus return FALSE; // we set the focus
} }
/* void RenameEntryDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
RenameEntryDialog::DoDataExchange(CDataExchange* pDX)
{ {
CString msg, failed; CString msg, failed;
msg = "";
failed.LoadString(IDS_MB_APP_NAME); failed.LoadString(IDS_MB_APP_NAME);
/* fNewName must come last, or the focus will be set on the wrong field /* fNewName must come last, or the focus will be set on the wrong field
@ -105,31 +93,22 @@ fail:
return; return;
} }
/* void RenameEntryDialog::OnSkip(void)
* User pressed the "skip" button, which causes us to bail with a result that
* skips the rename but continues with the series.
*/
void
RenameEntryDialog::OnSkip(void)
{ {
/*
* User pressed the "skip" button, which causes us to bail with a result that
* skips the rename but continues with the series.
*/
EndDialog(IDIGNORE); EndDialog(IDIGNORE);
} }
/* BOOL RenameEntryDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
RenameEntryDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void RenameEntryDialog::OnHelp(void)
* User pressed the "Help" button.
*/
void
RenameEntryDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_RENAME_ENTRY, HELP_CONTEXT); WinHelp(HELP_TOPIC_RENAME_ENTRY, HELP_CONTEXT);
} }

View File

@ -49,8 +49,8 @@ public:
protected: protected:
// overrides // overrides
virtual BOOL OnInitDialog(void); virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX); virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnSkip(void); afx_msg void OnSkip(void);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);

View File

@ -3,16 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved. * Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms. * See the file LICENSE for distribution terms.
*/ */
/*
* Implementation of RenameVolumeDialog.
*
* Show a tree with possible volumes and sub-volumes, and ask the user to
* enter the desired name (or volume number).
*
* We need to have the tree, rather than just clicking on an entry in the file
* list, because we want to be able to change names and volume numbers on
* disks with no files.
*/
#include "stdafx.h" #include "stdafx.h"
#include "RenameVolumeDialog.h" #include "RenameVolumeDialog.h"
#include "DiskFSTree.h" #include "DiskFSTree.h"
@ -25,11 +15,7 @@ BEGIN_MESSAGE_MAP(RenameVolumeDialog, CDialog)
ON_WM_HELPINFO() ON_WM_HELPINFO()
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL RenameVolumeDialog::OnInitDialog(void)
* Set up the control.
*/
BOOL
RenameVolumeDialog::OnInitDialog(void)
{ {
/* do the DoDataExchange stuff */ /* do the DoDataExchange stuff */
CDialog::OnInitDialog(); CDialog::OnInitDialog();
@ -58,16 +44,11 @@ RenameVolumeDialog::OnInitDialog(void)
return FALSE; // we set the focus return FALSE; // we set the focus
} }
/* void RenameVolumeDialog::DoDataExchange(CDataExchange* pDX)
* Convert values.
*/
void
RenameVolumeDialog::DoDataExchange(CDataExchange* pDX)
{ {
CString msg, failed; CString msg, failed;
//DiskImgLib::DiskFS* pDiskFS = fpArchive->GetDiskFS(); //DiskImgLib::DiskFS* pDiskFS = fpArchive->GetDiskFS();
msg = "";
failed.LoadString(IDS_MB_APP_NAME); failed.LoadString(IDS_MB_APP_NAME);
/* put fNewName last so it gets the focus after failure */ /* put fNewName last so it gets the focus after failure */
@ -130,12 +111,7 @@ fail:
return; return;
} }
/* void RenameVolumeDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
* Get a notification whenever the selection changes. Use it to stuff a
* default value into the edit box.
*/
void
RenameVolumeDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
{ {
CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_RENAMEVOL_TREE); CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_RENAMEVOL_TREE);
HTREEITEM selected; HTREEITEM selected;
@ -160,21 +136,13 @@ RenameVolumeDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
*pResult = 0; *pResult = 0;
} }
/* BOOL RenameVolumeDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
* Context help request (question mark button).
*/
BOOL
RenameVolumeDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{ {
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP); WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it return TRUE; // yes, we handled it
} }
/* void RenameVolumeDialog::OnHelp(void)
* User pressed Ye Olde Helppe Button.
*/
void
RenameVolumeDialog::OnHelp(void)
{ {
WinHelp(HELP_TOPIC_RENAME_VOLUME, HELP_CONTEXT); WinHelp(HELP_TOPIC_RENAME_VOLUME, HELP_CONTEXT);
} }

View File

@ -5,6 +5,13 @@
*/ */
/* /*
* Declarations for "rename volume" dialog. * Declarations for "rename volume" dialog.
*
* Show a tree with possible volumes and sub-volumes, and ask the user to
* enter the desired name (or volume number).
*
* We need to have the tree, rather than just clicking on an entry in the file
* list, because we want to be able to change names and volume numbers on
* disks with no files.
*/ */
#ifndef APP_RENAMEVOLUME_H #ifndef APP_RENAMEVOLUME_H
#define APP_RENAMEVOLUME_H #define APP_RENAMEVOLUME_H
@ -32,11 +39,15 @@ public:
DiskImgLib::DiskFS* fpChosenDiskFS; DiskImgLib::DiskFS* fpChosenDiskFS;
protected: protected:
// overrides virtual BOOL OnInitDialog(void) override;
virtual BOOL OnInitDialog(void); virtual void DoDataExchange(CDataExchange* pDX) override;
virtual void DoDataExchange(CDataExchange* pDX);
/*
* Get a notification whenever the selection changes. Use it to stuff a
* default value into the edit box.
*/
afx_msg void OnSelChanged(NMHDR* pnmh, LRESULT* pResult); afx_msg void OnSelChanged(NMHDR* pnmh, LRESULT* pResult);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo); afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg void OnHelp(void); afx_msg void OnHelp(void);

View File

@ -53,8 +53,7 @@ typedef struct USQState {
/* /*
* Decode the next symbol from the Huffman stream. * Decode the next symbol from the Huffman stream.
*/ */
static NuError static NuError USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
{ {
short val = 0; short val = 0;
int bits, bitPosn; int bits, bitPosn;
@ -90,8 +89,7 @@ USQDecodeHuffSymbol(USQState* pUsqState, int* pVal)
/* /*
* Read two bytes of signed data out of the buffer. * Read two bytes of signed data out of the buffer.
*/ */
static inline NuError static inline NuError USQReadShort(USQState* pUsqState, short* pShort)
USQReadShort(USQState* pUsqState, short* pShort)
{ {
if (pUsqState->dataInBuffer < 2) if (pUsqState->dataInBuffer < 2)
return kNuErrBufferUnderrun; return kNuErrBufferUnderrun;
@ -107,8 +105,7 @@ USQReadShort(USQState* pUsqState, short* pShort)
* Wrapper for fread(). Note the arguments resemble read(2) rather * Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S). * than fread(3S).
*/ */
static NuError static NuError SQRead(FILE* fp, void* buf, size_t nbyte)
SQRead(FILE* fp, void* buf, size_t nbyte)
{ {
size_t result; size_t result;
@ -123,19 +120,14 @@ SQRead(FILE* fp, void* buf, size_t nbyte)
return kNuErrNone; return kNuErrNone;
} }
NuError UnSqueeze(FILE* fp, unsigned long realEOF, ExpandBuffer* outExp,
/*
* Expand "SQ" format. Archive file should already be seeked.
*
* Because we have a stop symbol, knowing the uncompressed length of
* the file is not essential.
*
* If "outExp" is NULL, no output is produced (useful for "test" mode).
*/
NuError
UnSqueeze(FILE* fp, unsigned long realEOF, ExpandBuffer* outExp,
bool fullSqHeader, int blockSize) bool fullSqHeader, int blockSize)
{ {
/*
* Because we have a stop symbol, knowing the uncompressed length of
* the file is not essential.
*/
NuError err = kNuErrNone; NuError err = kNuErrNone;
USQState usqState; USQState usqState;
unsigned long compRemaining, getSize; unsigned long compRemaining, getSize;

View File

@ -9,6 +9,11 @@
#ifndef APP_SQUEEZE_H #ifndef APP_SQUEEZE_H
#define APP_SQUEEZE_H #define APP_SQUEEZE_H
/*
* Expand "SQ" format. Archive file should already be seeked.
*
* If "outExp" is NULL, no output is produced (useful for "test" mode).
*/
NuError UnSqueeze(FILE* fp, unsigned long realEOF, ExpandBuffer* outExp, NuError UnSqueeze(FILE* fp, unsigned long realEOF, ExpandBuffer* outExp,
bool fullSqHeader, int blockSize); bool fullSqHeader, int blockSize);

View File

@ -19,11 +19,7 @@ BEGIN_MESSAGE_MAP(SubVolumeDialog, CDialog)
END_MESSAGE_MAP() END_MESSAGE_MAP()
/* BOOL SubVolumeDialog::OnInitDialog(void)
* Set up the control.
*/
BOOL
SubVolumeDialog::OnInitDialog(void)
{ {
ASSERT(fpDiskFS != NULL); ASSERT(fpDiskFS != NULL);
@ -46,20 +42,13 @@ SubVolumeDialog::OnInitDialog(void)
return CDialog::OnInitDialog(); return CDialog::OnInitDialog();
} }
/* void SubVolumeDialog::DoDataExchange(CDataExchange* pDX)
* Do the DDX thang.
*/
void
SubVolumeDialog::DoDataExchange(CDataExchange* pDX)
{ {
DDX_LBIndex(pDX, IDC_SUBV_LIST, fListBoxIndex); DDX_LBIndex(pDX, IDC_SUBV_LIST, fListBoxIndex);
} }
/* void SubVolumeDialog::OnItemDoubleClicked(void)
* Accept a double-click as an "OK".
*/
void
SubVolumeDialog::OnItemDoubleClicked(void)
{ {
// Accept a double-click as an "OK".
OnOK(); OnOK();
} }

Some files were not shown because too many files have changed in this diff Show More