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 @@
* ===========================================================================
*/
/*
* 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,
int AcuEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const
{
NuError nerr;
@ -199,16 +182,7 @@ bail:
return result;
}
/*
* 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,
int AcuEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const
{
NuError nerr;
@ -297,12 +271,7 @@ bail:
return result;
}
/*
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError
AcuEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
NuError AcuEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const
{
NuError nerr = kNuErrNone;
@ -351,14 +320,7 @@ bail:
}
/*
* 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 AcuEntry::TestEntry(CWnd* pMsgWnd)
{
NuError nerr = kNuErrNone;
CString errMsg;
@ -411,24 +373,13 @@ bail:
* ===========================================================================
*/
/*
* Perform one-time initialization. There really isn't any for us.
*
* Returns 0 on success, nonzero on error.
*/
/*static*/ CString
AcuArchive::AppInit(void)
/*static*/ CString AcuArchive::AppInit(void)
{
return "";
}
/*
* Open an ACU archive.
*
* Returns an error string on failure, or "" on success.
*/
GenericArchive::OpenResult
AcuArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
GenericArchive::OpenResult AcuArchive::Open(const WCHAR* filename,
bool readOnly, CString* pErrMsg)
{
CString errMsg;
@ -465,23 +416,13 @@ bail:
return kResultSuccess;
}
/*
* 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*/)
CString AcuArchive::New(const WCHAR* /*filename*/, const void* /*options*/)
{
return L"Sorry, AppleLink Compression Utility files can't be created.";
}
/*
* Our capabilities.
*/
long
AcuArchive::GetCapability(Capability cap)
long AcuArchive::GetCapability(Capability cap)
{
switch (cap) {
case kCapCanTest:
@ -515,15 +456,7 @@ AcuArchive::GetCapability(Capability cap)
}
}
/*
* 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)
int AcuArchive::LoadContents(void)
{
NuError nerr;
int numEntries;
@ -561,11 +494,7 @@ AcuArchive::LoadContents(void)
return 0;
}
/*
* Reload the contents of the archive.
*/
CString
AcuArchive::Reload(void)
CString AcuArchive::Reload(void)
{
fReloadFlag = true; // tell everybody that cached data is invalid
@ -577,15 +506,7 @@ AcuArchive::Reload(void)
return "";
}
/*
* 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)
int AcuArchive::ReadMasterHeader(int* pNumEntries)
{
AcuMasterHeader header;
unsigned char buf[kAcuMasterHeaderLen];
@ -615,12 +536,7 @@ AcuArchive::ReadMasterHeader(int* pNumEntries)
return 0;
}
/*
* 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 AcuArchive::ReadFileHeader(AcuFileEntry* pEntry)
{
NuError err = kNuErrNone;
unsigned char buf[kAcuEntryHeaderLen];
@ -688,11 +604,7 @@ bail:
return err;
}
/*
* Dump the contents of an AcuFileEntry struct.
*/
void
AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry)
void AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry)
{
time_t createWhen, modWhen;
CString createStr, modStr;
@ -714,12 +626,7 @@ AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry)
pEntry->fileNameLen, pEntry->headerChecksum);
}
/*
* Given an AcuFileEntry structure, add an appropriate entry to the list.
*/
int
AcuArchive::CreateEntry(const AcuFileEntry* pEntry)
int AcuArchive::CreateEntry(const AcuFileEntry* pEntry)
{
const int kAcuFssep = '/';
NuError err = kNuErrNone;
@ -776,21 +683,12 @@ AcuArchive::CreateEntry(const AcuFileEntry* pEntry)
* ===========================================================================
*/
/*
* Test if this entry is a directory.
*/
bool
AcuArchive::IsDir(const AcuFileEntry* pEntry)
bool AcuArchive::IsDir(const AcuFileEntry* pEntry)
{
return (pEntry->storageType == 0x0d);
}
/*
* Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S).
*/
NuError
AcuArchive::AcuRead(void* buf, size_t nbyte)
NuError AcuArchive::AcuRead(void* buf, size_t nbyte)
{
size_t result;
@ -805,13 +703,7 @@ AcuArchive::AcuRead(void* buf, size_t nbyte)
return kNuErrNone;
}
/*
* 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)
NuError AcuArchive::AcuSeek(long offset)
{
ASSERT(fFp != NULL);
ASSERT(offset > 0);
@ -825,12 +717,8 @@ AcuArchive::AcuSeek(long offset)
}
/*
* Convert from ProDOS compact date format to the expanded DateTime format.
*/
void
AcuArchive::AcuConvertDateTime(unsigned short prodosDate,
unsigned short prodosTime, NuDateTime* pWhen)
void AcuArchive::AcuConvertDateTime(uint16_t prodosDate,
uint16_t prodosTime, NuDateTime* pWhen)
{
pWhen->second = 0;
pWhen->minute = prodosTime & 0x3f;
@ -851,11 +739,7 @@ AcuArchive::AcuConvertDateTime(unsigned short prodosDate,
* ===========================================================================
*/
/*
* Test the records represented in the selection set.
*/
bool
AcuArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
bool AcuArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{
NuError nerr;
AcuEntry* pEntry;

View File

@ -24,14 +24,15 @@ public:
{}
virtual ~AcuEntry(void) {}
// retrieve thread data
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,
ConvertHighASCII convHA, CString* pErrMsg) const;
virtual long GetSelectionSerial(void) const { return -1; } // doesn't matter
ConvertHighASCII convHA, CString* pErrMsg) const override;
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 ||
feature == kFeatureHasSimpleAccess)
return false;
@ -39,6 +40,12 @@ public:
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);
bool GetSqueezed(void) const { return fIsSqueezed; }
@ -47,6 +54,10 @@ public:
void SetOffset(long offset) { fOffset = offset; }
private:
/*
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const;
//NuError BNYUnSqueeze(ExpandBuffer* outExp) const;
@ -66,59 +77,78 @@ public:
{}
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);
/*
* Open an ACU archive.
*
* Returns an error string on failure, or "" on success.
*/
virtual OpenResult Open(const WCHAR* filename, bool readOnly,
CString* pErrMsg);
virtual CString New(const WCHAR* filename, const void* options);
virtual CString Flush(void) { return ""; }
virtual CString Reload(void);
virtual bool IsReadOnly(void) const { return fIsReadOnly; };
virtual bool IsModified(void) const { return false; }
virtual void GetDescription(CString* pStr) const { *pStr = "AppleLink ACU"; }
CString* pErrMsg) override;
/*
* Finish instantiating an AcuArchive 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;
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,
const AddFilesDialog* pAddOpts)
const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; }
virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts)
const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; }
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName)
const WCHAR* newName) override
{ ASSERT(false); return false; }
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet);
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; }
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; }
virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName)
const WCHAR* newName) override
{ ASSERT(false); return false; }
virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const
const WCHAR* newName) const override
{ ASSERT(false); return "!"; }
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 "!"; }
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts)
const RecompressOptionsDialog* pRecompOpts) override
{ ASSERT(false); return false; }
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts)
ActionProgressDialog* pActionProgress,
const XferFileOptions* pXferOpts) override
{ ASSERT(false); return kXferFailed; }
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr)
CString* pStr) override
{ ASSERT(false); return false; }
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str)
const CString& str) override
{ ASSERT(false); return false; }
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry)
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override
{ ASSERT(false); return false; }
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps)
const FileProps* pProps) override
{ ASSERT(false); return false; }
virtual void PreferencesChanged(void) {}
virtual long GetCapability(Capability cap);
virtual void PreferencesChanged(void) override {}
virtual long GetCapability(Capability cap) override;
friend class AcuEntry;
@ -130,19 +160,19 @@ private:
}
return "";
}
virtual void XferPrepare(const XferFileOptions* pXferOpts)
virtual void XferPrepare(const XferFileOptions* pXferOpts) override
{ ASSERT(false); }
virtual CString XferFile(FileDetails* pDetails, unsigned char** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen)
virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen) override
{ ASSERT(false); return "!"; }
virtual void XferAbort(CWnd* pMsgWnd)
virtual void XferAbort(CWnd* pMsgWnd) override
{ ASSERT(false); }
virtual void XferFinish(CWnd* pMsgWnd)
virtual void XferFinish(CWnd* pMsgWnd) override
{ ASSERT(false); }
virtual ArchiveKind GetArchiveKind(void) { return kArchiveACU; }
virtual ArchiveKind GetArchiveKind(void) override { return kArchiveACU; }
virtual NuError DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails)
FileDetails* pDetails) override
{ ASSERT(false); return kNuErrGeneric; }
enum {
@ -203,17 +233,62 @@ private:
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);
/*
* 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);
/*
* 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);
/*
* Dump the contents of an AcuFileEntry struct.
*/
void DumpFileHeader(const AcuFileEntry* pEntry);
/*
* Given an AcuFileEntry structure, add an appropriate entry to the list.
*/
int CreateEntry(const AcuFileEntry* pEntry);
/*
* Test if this entry is a directory.
*/
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);
/*
* 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);
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;
bool fIsReadOnly;

View File

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

View File

@ -9,7 +9,6 @@
#ifndef APP_ABOUTDIALOG_H
#define APP_ABOUTDIALOG_H
//#include <afxwin.h>
#include "resource.h"
/*
@ -23,12 +22,17 @@ public:
{}
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 OnEnterReg(void);
//afx_msg void OnEnterReg(void);
//void ShowRegistrationInfo(void);
DECLARE_MESSAGE_MAP()

View File

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

View File

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

View File

@ -10,7 +10,6 @@
#include "stdafx.h"
#include "Main.h"
#include "ViewFilesDialog.h"
//#include "ViewOptionsDialog.h"
#include "ChooseDirDialog.h"
#include "AddFilesDialog.h"
#include "CreateSubdirDialog.h"
@ -31,7 +30,6 @@
#include "ChooseAddTargetDialog.h"
#include "CassetteDialog.h"
#include "BasicImport.h"
//#include "../util/UtilLib.h"
#include "../diskimg/TwoImg.h"
#include <errno.h>
@ -42,36 +40,17 @@
* ==========================================================================
*/
/*
* View a file stored in the archive.
*
* Control bounces back through Get*FileText() to get the actual
* data to view.
*/
void
MainWindow::OnActionsView(void)
void MainWindow::OnActionsView(void)
{
HandleView();
}
void
MainWindow::OnUpdateActionsView(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsView(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL &&
fpContentList->GetSelectedCount() > 0);
}
/*
* 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)
void MainWindow::HandleView(void)
{
ASSERT(fpContentList != NULL);
@ -87,8 +66,6 @@ MainWindow::HandleView(void)
return;
}
//fpSelSet = &selSet;
ViewFilesDialog vfd(this);
vfd.SetSelectionSet(&selSet);
vfd.SetTextTypeFace(fPreferences.GetPrefString(kPrViewTextTypeFace));
@ -96,8 +73,6 @@ MainWindow::HandleView(void)
vfd.SetNoWrapText(fPreferences.GetPrefBool(kPrNoWrapText));
vfd.DoModal();
//fpSelSet = NULL;
// remember which font they used (sticky pref, not in registry)
fPreferences.SetPrefString(kPrViewTextTypeFace, vfd.GetTextTypeFace());
fPreferences.SetPrefLong(kPrViewTextPointSize, vfd.GetTextPointSize());
@ -113,14 +88,7 @@ MainWindow::HandleView(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)
void MainWindow::OnActionsOpenAsDisk(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpContentList->GetSelectedCount() == 1);
@ -131,8 +99,7 @@ MainWindow::OnActionsOpenAsDisk(void)
else
TmpExtractAndOpen(pEntry, GenericEntry::kDataThread, kModeDiskImage);
}
void
MainWindow::OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI)
{
const int kMinLen = 512 * 7;
bool allow = false;
@ -157,11 +124,7 @@ MainWindow::OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Add files to an archive.
*/
void
MainWindow::OnActionsAddFiles(void)
void MainWindow::OnActionsAddFiles(void)
{
LOGI("Add files!");
AddFilesDialog addFiles(this);
@ -266,21 +229,12 @@ MainWindow::OnActionsAddFiles(void)
LOGI("SFD bailed with Cancel");
}
}
void
MainWindow::OnUpdateActionsAddFiles(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsAddFiles(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly());
}
/*
* 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,
bool MainWindow::ChooseAddTarget(DiskImgLib::A2File** ppTargetSubdir,
DiskImgLib::DiskFS** ppTargetDiskFS)
{
ASSERT(ppTargetSubdir != NULL);
@ -341,15 +295,7 @@ MainWindow::ChooseAddTarget(DiskImgLib::A2File** ppTargetSubdir,
* ==========================================================================
*/
/*
* 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)
void MainWindow::OnActionsAddDisks(void)
{
DIError dierr;
DiskImg img;
@ -489,8 +435,7 @@ MainWindow::OnActionsAddDisks(void)
bail:
return;
}
void
MainWindow::OnUpdateActionsAddDisks(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsAddDisks(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpOpenArchive->GetCapability(GenericArchive::kCapCanAddDisk));
@ -503,16 +448,7 @@ MainWindow::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.
*/
void
MainWindow::OnActionsCreateSubdir(void)
void MainWindow::OnActionsCreateSubdir(void)
{
CreateSubdirDialog csDialog;
@ -549,8 +485,7 @@ MainWindow::OnActionsCreateSubdir(void)
fpOpenArchive->CreateSubdir(this, pEntry, csDialog.fNewName);
fpContentList->Reload();
}
void
MainWindow::OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI)
{
bool enable = fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpContentList->GetSelectedCount() == 1 &&
@ -580,11 +515,7 @@ MainWindow::OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Extract files.
*/
void
MainWindow::OnActionsExtract(void)
void MainWindow::OnActionsExtract(void)
{
ASSERT(fpContentList != NULL);
@ -666,25 +597,21 @@ MainWindow::OnActionsExtract(void)
fpActionProgress->Cleanup(this);
fpActionProgress = NULL;
}
void
MainWindow::OnUpdateActionsExtract(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsExtract(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL);
}
/*
* 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,
void MainWindow::DoBulkExtract(SelectionSet* pSelSet,
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;
bool overwriteExisting, ovwrForAll;
@ -790,17 +717,7 @@ MainWindow::DoBulkExtract(SelectionSet* pSelSet,
delete pHolder;
}
/*
* 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,
bool MainWindow::ExtractEntry(GenericEntry* pEntry, int thread,
ReformatHolder* pHolder, const ExtractOptionsDialog* pExtOpts,
bool* pOverwriteExisting, bool* pOvwrForAll)
{
@ -1272,26 +1189,7 @@ open_file_fail:
return true;
}
/*
* 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,
int MainWindow::OpenOutputFile(CString* pOutputPath, const PathProposal& pathProp,
time_t arcFileModWhen, bool* pOverwriteExisting, bool* pOvwrForAll,
FILE** pFp)
{
@ -1402,11 +1300,7 @@ bail:
* ==========================================================================
*/
/*
* Test files.
*/
void
MainWindow::OnActionsTest(void)
void MainWindow::OnActionsTest(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -1480,11 +1374,7 @@ MainWindow::OnUpdateActionsTest(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Delete archive entries.
*/
void
MainWindow::OnActionsDelete(void)
void MainWindow::OnActionsDelete(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -1571,8 +1461,7 @@ MainWindow::OnActionsDelete(void)
if (result)
SuccessBeep();
}
void
MainWindow::OnUpdateActionsDelete(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsDelete(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly()
&& fpContentList->GetSelectedCount() > 0);
@ -1585,13 +1474,7 @@ MainWindow::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.
*/
void
MainWindow::OnActionsRename(void)
void MainWindow::OnActionsRename(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -1626,8 +1509,7 @@ MainWindow::OnActionsRename(void)
// user interaction on each step, so skip the SuccessBeep
}
void
MainWindow::OnUpdateActionsRename(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsRename(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly()
&& fpContentList->GetSelectedCount() > 0);
@ -1640,11 +1522,7 @@ MainWindow::OnUpdateActionsRename(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Edit a comment, creating it if necessary.
*/
void
MainWindow::OnActionsEditComment(void)
void MainWindow::OnActionsEditComment(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -1688,8 +1566,7 @@ MainWindow::OnActionsEditComment(void)
fpContentList->Reload();
}
}
void
MainWindow::OnUpdateActionsEditComment(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsEditComment(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpContentList->GetSelectedCount() == 1 &&
@ -1703,17 +1580,7 @@ MainWindow::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.
*/
void
MainWindow::OnActionsEditProps(void)
void MainWindow::OnActionsEditProps(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -1742,8 +1609,7 @@ MainWindow::OnActionsEditProps(void)
fpContentList->Reload(true);
}
}
void
MainWindow::OnUpdateActionsEditProps(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsEditProps(CCmdUI* pCmdUI)
{
// allow it in read-only mode, so we can view the props
pCmdUI->Enable(fpContentList != NULL &&
@ -1757,11 +1623,7 @@ MainWindow::OnUpdateActionsEditProps(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Change a volume name or volume number.
*/
void
MainWindow::OnActionsRenameVolume(void)
void MainWindow::OnActionsRenameVolume(void)
{
RenameVolumeDialog rvDialog;
@ -1806,8 +1668,7 @@ MainWindow::OnActionsRenameVolume(void)
fpContentList->Reload();
SetCPTitle(fOpenArchivePathName, fpOpenArchive);
}
void
MainWindow::OnUpdateActionsRenameVolume(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsRenameVolume(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpOpenArchive->GetCapability(GenericArchive::kCapCanRenameVolume));
@ -1820,11 +1681,7 @@ MainWindow::OnUpdateActionsRenameVolume(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Recompress files.
*/
void
MainWindow::OnActionsRecompress(void)
void MainWindow::OnActionsRecompress(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -1906,19 +1763,14 @@ MainWindow::OnActionsRecompress(void)
MessageBox(msg, appName, MB_OK|MB_ICONINFORMATION);
}
}
void
MainWindow::OnUpdateActionsRecompress(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsRecompress(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly() &&
fpContentList->GetItemCount() > 0 &&
fpOpenArchive->GetCapability(GenericArchive::kCapCanRecompress));
}
/*
* Compute the total size of all files in the GenericArchive.
*/
void
MainWindow::CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const
void MainWindow::CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const
{
GenericEntry* pEntry = fpOpenArchive->GetEntries();
LONGLONG uncomp = 0, comp = 0;
@ -1940,11 +1792,7 @@ MainWindow::CalcTotalSize(LONGLONG* pUncomp, LONGLONG* pComp) const
* ==========================================================================
*/
/*
* Select files to convert.
*/
void
MainWindow::OnActionsConvDisk(void)
void MainWindow::OnActionsConvDisk(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -2074,8 +1922,7 @@ MainWindow::OnActionsConvDisk(void)
/* clean up */
delete xferOpts.fTarget;
}
void
MainWindow::OnUpdateActionsConvDisk(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsConvDisk(CCmdUI* pCmdUI)
{
/* right now, only NufxArchive has the Xfer stuff implemented */
pCmdUI->Enable(fpContentList != NULL &&
@ -2090,11 +1937,7 @@ MainWindow::OnUpdateActionsConvDisk(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Select files to convert.
*/
void
MainWindow::OnActionsConvFile(void)
void MainWindow::OnActionsConvFile(void)
{
ASSERT(fpContentList != NULL);
ASSERT(fpOpenArchive != NULL);
@ -2219,8 +2062,7 @@ MainWindow::OnActionsConvFile(void)
/* clean up */
delete xferOpts.fTarget;
}
void
MainWindow::OnUpdateActionsConvFile(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsConvFile(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL &&
fpContentList->GetItemCount() > 0 &&
@ -2234,17 +2076,12 @@ MainWindow::OnUpdateActionsConvFile(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* Convert BAS, INT, or BIN to a cassette-audio WAV file.
*/
void
MainWindow::OnActionsConvToWav(void)
void MainWindow::OnActionsConvToWav(void)
{
// do this someday
LOGI("Convert TO wav");
}
void
MainWindow::OnUpdateActionsConvToWav(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsConvToWav(CCmdUI* pCmdUI)
{
BOOL enable = false;
@ -2264,12 +2101,7 @@ MainWindow::OnUpdateActionsConvToWav(CCmdUI* pCmdUI)
pCmdUI->Enable(enable);
}
/*
* 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)
void MainWindow::OnActionsConvFromWav(void)
{
CassetteDialog dlg;
CString fileName, saveFolder;
@ -2301,22 +2133,12 @@ MainWindow::OnActionsConvFromWav(void)
bail:
return;
}
void
MainWindow::OnUpdateActionsConvFromWav(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsConvFromWav(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly());
}
/*
* 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,
/*static*/ bool MainWindow::SaveToArchive(GenericArchive::FileDetails* pDetails,
const unsigned char* dataBufIn, long dataLen,
const unsigned char* rsrcBufIn, long rsrcLen,
CString& errMsg, CWnd* pDialog)
@ -2410,14 +2232,7 @@ bail:
* ==========================================================================
*/
/*
* 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)
void MainWindow::OnActionsImportBAS(void)
{
ImportBASDialog dlg;
CString fileName, saveFolder;
@ -2437,7 +2252,7 @@ MainWindow::OnActionsImportBAS(void)
fileName = fileDlg.GetPathName();
LOGI("Opening TXT file '%ls'", (LPCWSTR) fileName);
dlg.fFileName = fileName;
dlg.SetFileName(fileName);
// pass in fpOpenArchive?
dlg.DoModal();
@ -2449,8 +2264,7 @@ MainWindow::OnActionsImportBAS(void)
bail:
return;
}
void
MainWindow::OnUpdateActionsImportBAS(CCmdUI* pCmdUI)
void MainWindow::OnUpdateActionsImportBAS(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL && !fpOpenArchive->IsReadOnly());
}
@ -2462,15 +2276,7 @@ MainWindow::OnUpdateActionsImportBAS(CCmdUI* pCmdUI)
* ==========================================================================
*/
/*
* 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,
int MainWindow::GetFileParts(const GenericEntry* pEntry,
ReformatHolder** ppHolder) const
{
ReformatHolder* pHolder = new ReformatHolder;
@ -2493,11 +2299,7 @@ MainWindow::GetFileParts(const GenericEntry* pEntry,
return 0;
}
/*
* Load the requested part.
*/
void
MainWindow::GetFilePart(const GenericEntry* pEntry, int whichThread,
void MainWindow::GetFilePart(const GenericEntry* pEntry, int whichThread,
ReformatHolder* pHolder) const
{
CString errMsg;

View File

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

View File

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

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Support for the "add files" dialog.
*/
#include "stdafx.h"
#include "AddFilesDialog.h"
#include "FileNameConv.h"
@ -23,8 +20,7 @@
* "false" indication occurs during saveAndValidate==true, and means that we
* shouldn't allow the dialog to close yet.
*/
bool
AddFilesDialog::MyDataExchange(bool saveAndValidate)
bool AddFilesDialog::MyDataExchange(bool saveAndValidate)
{
CWnd* pWnd;
@ -113,11 +109,7 @@ AddFilesDialog::MyDataExchange(bool saveAndValidate)
}
}
/*
* Make sure the storage prefix they entered is valid.
*/
bool
AddFilesDialog::ValidateStoragePrefix(void)
bool AddFilesDialog::ValidateStoragePrefix(void)
{
if (fStoragePrefix.IsEmpty())
return true;
@ -135,11 +127,7 @@ AddFilesDialog::ValidateStoragePrefix(void)
}
/*
* Override base class version.
*/
UINT
AddFilesDialog::MyOnCommand(WPARAM wParam, LPARAM lParam)
UINT AddFilesDialog::MyOnCommand(WPARAM wParam, LPARAM lParam)
{
switch (wParam) {
case IDHELP:
@ -150,14 +138,7 @@ AddFilesDialog::MyOnCommand(WPARAM wParam, LPARAM lParam)
}
}
/*
* 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)
void AddFilesDialog::ShiftControls(int deltaX, int deltaY)
{
/*
* 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);
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);
}
/*
* User pressed the "Help" button.
*/
void
AddFilesDialog::OnIDHelp(void)
void AddFilesDialog::OnIDHelp(void)
{
CWnd* pWndMain = ::AfxGetMainWnd();
CWinApp* pAppMain = ::AfxGetApp();

View File

@ -67,11 +67,22 @@ public:
DiskImgLib::DiskImg* fpDiskImg;
private:
virtual bool MyDataExchange(bool saveAndValidate);
virtual void ShiftControls(int deltaX, int deltaY);
virtual UINT MyOnCommand(WPARAM wParam, LPARAM lParam);
virtual bool MyDataExchange(bool saveAndValidate) override;
/*
* 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);
/*
* Make sure the storage prefix they entered is valid.
*/
bool ValidateStoragePrefix(void);
//DECLARE_MESSAGE_MAP()

View File

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

View File

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

View File

@ -21,24 +21,7 @@
* ===========================================================================
*/
/*
* 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,
int BnyEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const
{
NuError nerr;
@ -161,16 +144,7 @@ bail:
return result;
}
/*
* 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,
int BnyEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const
{
NuError nerr;
@ -259,12 +233,7 @@ bail:
return result;
}
/*
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError
BnyEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
NuError BnyEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const
{
NuError nerr = kNuErrNone;
@ -312,15 +281,7 @@ bail:
return nerr;
}
/*
* 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 BnyEntry::TestEntry(CWnd* pMsgWnd)
{
NuError nerr = kNuErrNone;
CString errMsg;
@ -373,25 +334,15 @@ bail:
* ===========================================================================
*/
/*
* 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)
/*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"";
}
/*
* Open a BNY archive.
*
* Returns an error string on failure, or "" on success.
*/
GenericArchive::OpenResult
BnyArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
GenericArchive::OpenResult BnyArchive::Open(const WCHAR* filename,
bool readOnly, CString* pErrMsg)
{
CString errMsg;
@ -423,24 +374,14 @@ bail:
return kResultSuccess;
}
/*
* 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 BnyArchive::New(const WCHAR* /*filename*/, const void* /*options*/)
{
CString retmsg(L"Sorry, Binary II files can't be created.");
return retmsg;
}
/*
* Our capabilities.
*/
long
BnyArchive::GetCapability(Capability cap)
long BnyArchive::GetCapability(Capability cap)
{
switch (cap) {
case kCapCanTest:
@ -474,14 +415,7 @@ BnyArchive::GetCapability(Capability cap)
}
}
/*
* Load the contents of the archive.
*
* Returns 0 on success, nonzero on failure.
*/
int
BnyArchive::LoadContents(void)
int BnyArchive::LoadContents(void)
{
NuError nerr;
@ -493,11 +427,7 @@ BnyArchive::LoadContents(void)
return (nerr != kNuErrNone);
}
/*
* Reload the contents of the archive.
*/
CString
BnyArchive::Reload(void)
CString BnyArchive::Reload(void)
{
fReloadFlag = true; // tell everybody that cached data is invalid
@ -509,13 +439,7 @@ BnyArchive::Reload(void)
return "";
}
/*
* Given a BnyFileEntry structure, add an appropriate entry to the list.
*
* Note this can mangle pEntry (notably the filename).
*/
NuError
BnyArchive::LoadContentsCallback(BnyFileEntry* pEntry)
NuError BnyArchive::LoadContentsCallback(BnyFileEntry* pEntry)
{
const int kBNYFssep = '/';
NuError err = kNuErrNone;
@ -599,20 +523,12 @@ BnyArchive::LoadContentsCallback(BnyFileEntry* pEntry)
* included here.
*/
/*
* Test for the magic number on a file in SQueezed format.
*/
bool
BnyArchive::IsSqueezed(uchar one, uchar two)
bool BnyArchive::IsSqueezed(uint8_t one, uint8_t two)
{
return (one == 0x76 && two == 0xff);
}
/*
* Test if this entry is a directory.
*/
bool
BnyArchive::IsDir(BnyFileEntry* pEntry)
bool BnyArchive::IsDir(BnyFileEntry* pEntry)
{
/*
* 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);
}
/*
* Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S).
*/
NuError
BnyArchive::BNYRead(void* buf, size_t nbyte)
NuError BnyArchive::BNYRead(void* buf, size_t nbyte)
{
size_t result;
@ -642,18 +553,12 @@ BnyArchive::BNYRead(void* buf, size_t nbyte)
return kNuErrNone;
}
/*
* 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)
NuError BnyArchive::BNYSeek(long offset)
{
ASSERT(fFp != NULL);
ASSERT(offset > 0);
/*DBUG(("--- seeking forward %ld bytes\n", offset));*/
LOGV("--- seeking forward %ld bytes\n", offset);
if (fseek(fFp, offset, SEEK_CUR) < 0)
return kNuErrFileSeek;
@ -662,11 +567,7 @@ BnyArchive::BNYSeek(long offset)
}
/*
* Convert from ProDOS compact date format to the expanded DateTime format.
*/
void
BnyArchive::BNYConvertDateTime(unsigned short prodosDate,
void BnyArchive::BNYConvertDateTime(unsigned short prodosDate,
unsigned short prodosTime, NuDateTime* pWhen)
{
pWhen->second = 0;
@ -681,17 +582,14 @@ BnyArchive::BNYConvertDateTime(unsigned short prodosDate,
pWhen->weekDay = 0;
}
/*
* 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)
NuError BnyArchive::BNYDecodeHeader(BnyFileEntry* pEntry)
{
/*
* See the File Type Note for $e0/8000 to decipher the buffer offsets
* and meanings.
*/
NuError err = kNuErrNone;
uchar* raw;
uint8_t* raw;
int len;
ASSERT(pEntry != NULL);
@ -852,11 +750,7 @@ bail:
#endif
/*
* Iterate through a Binary II archive, loading the data.
*/
NuError
BnyArchive::BNYIterate(void)
NuError BnyArchive::BNYIterate(void)
{
NuError err = kNuErrNone;
BnyFileEntry entry;
@ -944,11 +838,7 @@ bail:
* ===========================================================================
*/
/*
* Test the records represented in the selection set.
*/
bool
BnyArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
bool BnyArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{
NuError nerr;
BnyEntry* pEntry;

View File

@ -24,14 +24,15 @@ public:
{}
virtual ~BnyEntry(void) {}
// retrieve thread data
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,
ConvertHighASCII convHA, CString* pErrMsg) const;
virtual long GetSelectionSerial(void) const { return -1; } // doesn't matter
ConvertHighASCII convHA, CString* pErrMsg) const override;
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 ||
feature == kFeatureHasSimpleAccess)
return false;
@ -39,6 +40,12 @@ public:
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);
bool GetSqueezed(void) const { return fIsSqueezed; }
@ -51,6 +58,10 @@ public:
};
private:
/*
* Copy data from the seeked archive to outfp, possibly converting EOL along
* the way.
*/
NuError CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
CString* pMsg) const;
//NuError BNYUnSqueeze(ExpandBuffer* outExp) const;
@ -74,55 +85,57 @@ public:
static CString AppInit(void);
virtual OpenResult Open(const WCHAR* filename, bool readOnly,
CString* pErrMsg);
virtual CString New(const WCHAR* filename, const void* options);
virtual CString Flush(void) { return ""; }
virtual CString Reload(void);
virtual bool IsReadOnly(void) const { return fIsReadOnly; };
virtual bool IsModified(void) const { return false; }
virtual void GetDescription(CString* pStr) const { *pStr = "Binary II"; }
CString* pErrMsg) override;
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 = "Binary II"; }
virtual bool BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts)
const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; }
virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts)
const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; }
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName)
const WCHAR* newName) override
{ ASSERT(false); return false; }
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet);
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; }
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; }
virtual bool RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName)
const WCHAR* newName) override
{ ASSERT(false); return false; }
virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const
const WCHAR* newName) const override
{ ASSERT(false); return "!"; }
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 "!"; }
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts)
const RecompressOptionsDialog* pRecompOpts) override
{ ASSERT(false); return false; }
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts)
ActionProgressDialog* pActionProgress,
const XferFileOptions* pXferOpts) override
{ ASSERT(false); return kXferFailed; }
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr)
CString* pStr) override
{ ASSERT(false); return false; }
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str)
const CString& str) override
{ ASSERT(false); return false; }
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry)
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override
{ ASSERT(false); return false; }
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps)
const FileProps* pProps) override
{ ASSERT(false); return false; }
virtual void PreferencesChanged(void) {}
virtual long GetCapability(Capability cap);
virtual void PreferencesChanged(void) override {}
virtual long GetCapability(Capability cap) override;
friend class BnyEntry;
@ -134,19 +147,19 @@ private:
}
return "";
}
virtual void XferPrepare(const XferFileOptions* pXferOpts)
virtual void XferPrepare(const XferFileOptions* pXferOpts) override
{ ASSERT(false); }
virtual CString XferFile(FileDetails* pDetails, unsigned char** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen)
virtual CString XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen) override
{ ASSERT(false); return "!"; }
virtual void XferAbort(CWnd* pMsgWnd)
virtual void XferAbort(CWnd* pMsgWnd) override
{ ASSERT(false); }
virtual void XferFinish(CWnd* pMsgWnd)
virtual void XferFinish(CWnd* pMsgWnd) override
{ ASSERT(false); }
virtual ArchiveKind GetArchiveKind(void) { return kArchiveBNY; }
virtual ArchiveKind GetArchiveKind(void) override { return kArchiveBNY; }
virtual NuError DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails)
FileDetails* pDetails) override
{ ASSERT(false); return kNuErrGeneric; }
enum {
@ -158,10 +171,6 @@ private:
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
* 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
* fields in a BnyEntry.
*/
struct BnyFileEntry; // VC++6 needs these to access private enums
friend struct BnyFileEntry; // in this class
// struct BnyFileEntry; // VC++6 needs these to access private enums
// friend struct BnyFileEntry; // in this class
typedef struct BnyFileEntry {
ushort access;
ushort fileType;
ulong auxType;
uchar storageType;
ulong fileSize; /* in 512-byte blocks */
ushort prodosModDate;
ushort prodosModTime;
uint16_t access;
uint16_t fileType;
uint32_t auxType;
uint8_t storageType;
uint32_t fileSize; /* in 512-byte blocks */
uint16_t prodosModDate;
uint16_t prodosModTime;
NuDateTime modWhen; /* computed from previous two fields */
ushort prodosCreateDate;
ushort prodosCreateTime;
uint16_t prodosCreateDate;
uint16_t prodosCreateTime;
NuDateTime createWhen; /* computed from previous two fields */
ulong eof;
ulong realEOF; /* eof is bogus for directories */
uint32_t eof;
uint32_t realEOF; /* eof is bogus for directories */
char fileName[kBNYMaxFileName+1];
char nativeName[kBNYMaxNativeName+1];
ulong diskSpace; /* in 512-byte blocks */
uchar osType; /* not exactly same as NuFileSysID */
ushort nativeFileType;
uchar phantomFlag;
uchar dataFlags; /* advisory flags */
uchar version;
uchar filesToFollow; /* #of files after this one */
uint32_t diskSpace; /* in 512-byte blocks */
uint8_t osType; /* not exactly same as NuFileSysID */
uint16_t nativeFileType;
uint8_t phantomFlag;
uint8_t dataFlags; /* advisory flags */
uint8_t version;
uint8_t filesToFollow; /* #of files after this one */
uchar blockBuf[kBNYBlockSize];
uint8_t blockBuf[kBNYBlockSize];
} BnyFileEntry;
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);
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);
/*
* Wrapper for fread(). Note the arguments resemble read(2) rather
* than fread(3S).
*/
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);
/*
* Convert from ProDOS compact date format to the expanded DateTime format.
*/
void BNYConvertDateTime(unsigned short prodosDate,
unsigned short prodosTime, NuDateTime* pWhen);
/*
* Decode a Binary II header.
*/
NuError BNYDecodeHeader(BnyFileEntry* pEntry);
/*
* Iterate through a Binary II archive, loading the data.
*/
NuError BNYIterate(void);
FILE* fFp;

View File

@ -21,12 +21,7 @@
* ==========================================================================
*/
/*
* Constructor. Pass in the info for the token blob.
*/
void
BASTokenLookup::Init(const char* tokenList, int numTokens,
int tokenLen)
void BASTokenLookup::Init(const char* tokenList, int numTokens, int tokenLen)
{
int i;
@ -49,13 +44,7 @@ BASTokenLookup::Init(const char* tokenList, int numTokens,
}
}
/*
* 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 BASTokenLookup::Lookup(const char* str, int len, int* pFoundLen)
{
int longestIndex, longestLen;
int i;
@ -86,11 +75,7 @@ BEGIN_MESSAGE_MAP(ImportBASDialog, CDialog)
END_MESSAGE_MAP()
/*
* Set up the dialog.
*/
BOOL
ImportBASDialog::OnInitDialog(void)
BOOL ImportBASDialog::OnInitDialog(void)
{
CDialog::OnInitDialog(); // base class init
@ -119,14 +104,10 @@ ImportBASDialog::OnInitDialog(void)
return FALSE; // keep our focus
}
static const char* kFailed = "failed.\r\n\r\n";
static const char* kSuccess = "success!\r\n\r\n";
static const char kFailed[] = "failed.\r\n\r\n";
static const char kSuccess[] = "success!\r\n\r\n";
/*
* Import an Applesoft BASIC program from the specified file.
*/
bool
ImportBASDialog::ImportBAS(const WCHAR* fileName)
bool ImportBASDialog::ImportBAS(const WCHAR* fileName)
{
FILE* fp = NULL;
ExpandBuffer msgs(1024);
@ -197,11 +178,7 @@ bail:
return result;
}
/*
* Do the actual conversion.
*/
bool
ImportBASDialog::ConvertTextToBAS(const char* buf, long fileLen,
bool ImportBASDialog::ConvertTextToBAS(const char* buf, long fileLen,
char** pOutBuf, long* pOutLen, ExpandBuffer* pMsgs)
{
ExpandBuffer output(32768);
@ -263,13 +240,6 @@ ImportBASDialog::ConvertTextToBAS(const char* buf, long fileLen,
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:
@ -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
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)
{
const int kMaxTokenLen = 7; // longest token; must also hold linenum
@ -537,13 +507,10 @@ output_single:
return true;
}
/*
* Fix up the line pointers. We left dummy nonzero values in them initially.
*/
bool
ImportBASDialog::FixBASLinePointers(char* buf, long len, unsigned short addr)
bool ImportBASDialog::FixBASLinePointers(char* buf, long len,
uint16_t addr)
{
unsigned short val;
uint16_t val;
char* start;
while (len >= 4) {
@ -588,14 +555,7 @@ ImportBASDialog::FixBASLinePointers(char* buf, long len, unsigned short addr)
return true;
}
/*
* 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)
const char* ImportBASDialog::FindEOL(const char* buf, long max)
{
ASSERT(max >= 0);
if (max == 0)
@ -618,15 +578,7 @@ ImportBASDialog::FindEOL(const char* buf, long max)
return buf;
}
/*
* 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)
bool ImportBASDialog::GetNextNWC(const char** pBuf, int* pLen, char* pCh)
{
static const char* kWhitespace = " \t\r\n";
@ -648,10 +600,6 @@ ImportBASDialog::GetNextNWC(const char** pBuf, int* pLen, char* pCh)
return false;
}
/*
* Save the imported data.
*/
void ImportBASDialog::OnOK(void)
{
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_IMPORT_BAS_SAVEAS);
@ -705,11 +653,7 @@ bail:
return;
}
/*
* User pressed the "Help" button.
*/
void
ImportBASDialog::OnHelp(void)
void ImportBASDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_IMPORT_BASIC, HELP_CONTEXT);
}

View File

@ -31,7 +31,7 @@ public:
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);
// Return the index of the matching token, or -1 if none found.
@ -64,26 +64,59 @@ public:
delete[] fOutput;
}
CString fFileName; // file to open
// did we add something to the archive?
bool IsDirty(void) const { return fDirty; }
void SetFileName(const CString& fileName) { fFileName = fileName; }
private:
virtual BOOL OnInitDialog(void);
virtual BOOL OnInitDialog(void) override;
//virtual void DoDataExchange(CDataExchange* pDX);
virtual void OnOK(void);
virtual void OnOK(void) override;
afx_msg void OnHelp(void);
/*
* Import an Applesoft BASIC program from the specified file.
*/
bool ImportBAS(const WCHAR* fileName);
/*
* Do the actual conversion.
*/
bool ConvertTextToBAS(const char* buf, long fileLen,
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,
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);
/*
* 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);
void SetOutput(char* outBuf, long outLen) {
@ -98,6 +131,8 @@ private:
char* fOutput;
long fOutputLen;
CString fFileName; // file to open
DECLARE_MESSAGE_MAP()
};

View File

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

View File

@ -25,7 +25,14 @@ public:
{}
virtual ~CassImpTargetDialog(void) {}
/*
* Get the selected file type. Call this after the modal dialog exits.
*/
long GetFileType(void) const;
/*
* Convert a ProDOS file type into a radio button enum.
*/
void SetFileType(long type);
CString fFileName;
@ -33,13 +40,28 @@ public:
long fFileLength; // used for BIN display
private:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* They selected a different file type. Enable or disable the address
* entry window.
*/
afx_msg void OnTypeChange(void);
/*
* If the user changes the address, update the "end of range" field.
*/
afx_msg void OnAddrChange(void);
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;
/* 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()
/*
* Set up the dialog.
*/
BOOL
CassetteDialog::OnInitDialog(void)
BOOL CassetteDialog::OnInitDialog(void)
{
CRect rect;
const Preferences* pPreferences = GET_PREFERENCES();
@ -360,11 +356,7 @@ CassetteDialog::OnDialogReady(UINT, LONG)
#endif
/*
* Something changed in the list. Update the "OK" button.
*/
void
CassetteDialog::OnListChange(NMHDR*, LRESULT* pResult)
void CassetteDialog::OnListChange(NMHDR*, LRESULT* pResult)
{
LOGI("List change");
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_CASSETTE_LIST);
@ -375,11 +367,7 @@ CassetteDialog::OnListChange(NMHDR*, LRESULT* pResult)
}
/*
* Double click.
*/
void
CassetteDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
void CassetteDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
{
LOGI("Double click!");
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_CASSETTE_LIST);
@ -390,11 +378,7 @@ CassetteDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
*pResult = 0;
}
/*
* The volume filter drop-down box has changed.
*/
void
CassetteDialog::OnAlgorithmChange(void)
void CassetteDialog::OnAlgorithmChange(void)
{
CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_CASSETTE_ALG);
ASSERT(pCombo != NULL);
@ -403,21 +387,12 @@ CassetteDialog::OnAlgorithmChange(void)
AnalyzeWAV();
}
/*
* User pressed the "Help" button.
*/
void
CassetteDialog::OnHelp(void)
void CassetteDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_IMPORT_CASSETTE, HELP_CONTEXT);
}
/*
* User pressed "import" button. Add the selected item to the current
* archive or disk image.
*/
void
CassetteDialog::OnImport(void)
void CassetteDialog::OnImport(void)
{
/*
* Figure out which item they have selected.
@ -486,14 +461,7 @@ bail:
}
}
/*
* Analyze the contents of a WAV file.
*
* Returns "true" if it found anything at all, "false" if not.
*/
bool
CassetteDialog::AnalyzeWAV(void)
bool CassetteDialog::AnalyzeWAV(void)
{
SoundFile soundFile;
CWaitCursor waitc;
@ -546,13 +514,7 @@ CassetteDialog::AnalyzeWAV(void)
return true;
}
/*
* Add an entry to the list.
*
* Layout: index format length checksum start-offset
*/
void
CassetteDialog::AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType)
void CassetteDialog::AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType)
{
CString tmpStr;
const CassetteData* pData = &fDataArray[idx];
@ -605,15 +567,7 @@ CassetteDialog::AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType)
* ==========================================================================
*/
/*
* 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,
bool CassetteDialog::CassetteData::Scan(SoundFile* pSoundFile, Algorithm alg,
long* pStartOffset)
{
const int kSampleChunkSize = 65536; // should be multiple of 4
@ -760,13 +714,7 @@ bail:
return result;
}
/*
* 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,
void CassetteDialog::CassetteData::ConvertSamplesToReal(const WAVEFORMATEX* pFormat,
const unsigned char* buf, long chunkLen, float* sampleBuf)
{
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)
/*
* 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,
bool CassetteDialog::CassetteData::ProcessSample(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal)
{
if (pScanState->algorithm == kAlgorithmZero)
@ -847,18 +789,7 @@ CassetteDialog::CassetteData::ProcessSample(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,
bool CassetteDialog::CassetteData::ProcessSampleZero(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal)
{
long timeDelta;
@ -920,11 +851,7 @@ CassetteDialog::CassetteData::ProcessSampleZero(float sample, long sampleIndex,
return emitBit;
}
/*
* Process the data by finding and measuring the distance between peaks.
*/
bool
CassetteDialog::CassetteData::ProcessSamplePeak(float sample, long sampleIndex,
bool CassetteDialog::CassetteData::ProcessSamplePeak(float sample, long sampleIndex,
ScanState* pScanState, int* pBitVal)
{
/* 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;
}
/*
* 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)
bool CassetteDialog::CassetteData::UpdatePhase(ScanState* pScanState,
long sampleIndex, float halfCycleUsec, int* pBitVal)
{
float fullCycleUsec;
bool emitBit = false;

View File

@ -25,18 +25,31 @@ public:
bool IsDirty(void) const { return fDirty; }
private:
virtual BOOL OnInitDialog(void);
virtual BOOL OnInitDialog(void) override;
//virtual void DoDataExchange(CDataExchange* pDX);
//virtual void OnOK(void);
//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 OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult);
/*
* The volume filter drop-down box has changed.
*/
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 OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult);
afx_msg void OnHelp(void);
/*
* This holds converted data from the WAV file, plus some meta-data
* like what type of file we think this is.
@ -64,6 +77,13 @@ private:
kAlgorithmMAX
} 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);
unsigned char* GetDataBuf(void) const { return fOutputBuf; }
int GetDataLen(void) const { return fOutputLen; }
@ -117,14 +137,52 @@ private:
/* constants */
float usecPerSample;
} 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,
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,
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,
ScanState* pScanState, int* pBitVal);
/*
* Process the data by finding and measuring the distance between peaks.
*/
bool ProcessSamplePeak(float sample, long sampleIndex,
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,
float halfCycleUsec, int* pBitVal);
@ -141,7 +199,18 @@ private:
bool fChecksumGood;
};
/*
* Analyze the contents of a WAV file.
*
* Returns true if it found anything at all, false if not.
*/
bool AnalyzeWAV(void);
/*
* Add an entry to the list.
*
* Layout: index format length checksum start-offset
*/
void AddEntry(int idx, CListCtrl* pListCtrl, long* pFileType);
enum {

View File

@ -17,12 +17,7 @@ BEGIN_MESSAGE_MAP(ChooseAddTargetDialog, CDialog)
ON_COMMAND(IDHELP, OnHelp)
END_MESSAGE_MAP()
/*
* Initialize the dialog box. This requires scanning the provided disk
* archive.
*/
BOOL
ChooseAddTargetDialog::OnInitDialog(void)
BOOL ChooseAddTargetDialog::OnInitDialog(void)
{
CDialog::OnInitDialog();
@ -51,14 +46,13 @@ ChooseAddTargetDialog::OnInitDialog(void)
return TRUE;
}
/*
* 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)
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) {
CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_ADD_TARGET_TREE);
CString errMsg, appName;
@ -91,12 +85,7 @@ ChooseAddTargetDialog::DoDataExchange(CDataExchange* pDX)
}
}
/*
* User pressed the "Help" button.
*/
void
ChooseAddTargetDialog::OnHelp(void)
void ChooseAddTargetDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_CHOOSE_TARGET, HELP_CONTEXT);
}

View File

@ -35,8 +35,13 @@ public:
DiskImgLib::A2File* fpChosenSubdir;
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);
DiskFSTree fDiskFSTree;

View File

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

View File

@ -4,7 +4,8 @@
* 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 "Main.h"
@ -94,11 +95,7 @@ typedef struct FileCollectionEntry {
* ==========================================================================
*/
/*
* Copy data to the clipboard.
*/
void
MainWindow::OnEditCopy(void)
void MainWindow::OnEditCopy(void)
{
CString errStr, fileList;
SelectionSet selSet;
@ -181,22 +178,14 @@ MainWindow::OnEditCopy(void)
bail:
CloseClipboard();
}
void
MainWindow::OnUpdateEditCopy(CCmdUI* pCmdUI)
void MainWindow::OnUpdateEditCopy(CCmdUI* pCmdUI)
{
pCmdUI->Enable(fpContentList != NULL &&
fpContentList->GetSelectedCount() > 0);
}
/*
* 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)
CString MainWindow::CreateFileList(SelectionSet* pSelSet)
{
SelectionEntry* pSelEntry;
GenericEntry* pEntry;
@ -232,11 +221,7 @@ MainWindow::CreateFileList(SelectionSet* pSelSet)
return fullStr;
}
/*
* Double-up all double quotes.
*/
/*static*/ CString
MainWindow::DblDblQuote(const WCHAR* str)
/*static*/ CString MainWindow::DblDblQuote(const WCHAR* str)
{
CString result;
WCHAR* buf;
@ -258,12 +243,7 @@ MainWindow::DblDblQuote(const WCHAR* str)
return result;
}
/*
* Compute the size of everything currently on the clipboard.
*/
long
MainWindow::GetClipboardContentLen(void)
long MainWindow::GetClipboardContentLen(void)
{
long len = 0;
UINT format = 0;
@ -278,11 +258,7 @@ MainWindow::GetClipboardContentLen(void)
return len;
}
/*
* Create the file collection.
*/
HGLOBAL
MainWindow::CreateFileCollection(SelectionSet* pSelSet)
HGLOBAL MainWindow::CreateFileCollection(SelectionSet* pSelSet)
{
SelectionEntry* pSelEntry;
GenericEntry* pEntry;
@ -441,18 +417,8 @@ bail:
return hResult;
}
/*
* 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
MainWindow::CopyToCollection(GenericEntry* pEntry, void** pBuf, long* pBufLen)
CString MainWindow::CopyToCollection(GenericEntry* pEntry, void** pBuf,
long* pBufLen)
{
FileCollectionEntry collEnt;
CString errStr, dummyStr;
@ -615,19 +581,14 @@ MainWindow::CopyToCollection(GenericEntry* pEntry, void** pBuf, long* pBufLen)
* ==========================================================================
*/
/*
* Paste data from the clipboard, using the configured defaults.
*/
void
MainWindow::OnEditPaste(void)
void MainWindow::OnEditPaste(void)
{
bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths);
DoPaste(pasteJunkPaths);
}
void
MainWindow::OnUpdateEditPaste(CCmdUI* pCmdUI)
void MainWindow::OnUpdateEditPaste(CCmdUI* pCmdUI)
{
bool dataAvailable = false;
UINT myFormat;
@ -640,12 +601,7 @@ MainWindow::OnUpdateEditPaste(CCmdUI* pCmdUI)
dataAvailable);
}
/*
* Paste data from the clipboard, giving the user the opportunity to select
* how the files are handled.
*/
void
MainWindow::OnEditPasteSpecial(void)
void MainWindow::OnEditPasteSpecial(void)
{
PasteSpecialDialog dlg;
bool pasteJunkPaths = fPreferences.GetPrefBool(kPrPasteJunkPaths);
@ -673,17 +629,12 @@ MainWindow::OnEditPasteSpecial(void)
DoPaste(pasteJunkPaths);
}
void
MainWindow::OnUpdateEditPasteSpecial(CCmdUI* pCmdUI)
void MainWindow::OnUpdateEditPasteSpecial(CCmdUI* pCmdUI)
{
OnUpdateEditPaste(pCmdUI);
}
/*
* Do some prep work and then call ProcessClipboard to copy files in.
*/
void
MainWindow::DoPaste(bool pasteJunkPaths)
void MainWindow::DoPaste(bool pasteJunkPaths)
{
CString errStr, buildStr;
UINT format = 0;
@ -761,13 +712,8 @@ bail:
CloseClipboard();
}
/*
* Process the data in the clipboard.
*
* Returns an empty string on success, or an error message on failure.
*/
CString
MainWindow::ProcessClipboard(const void* vbuf, long bufLen, bool pasteJunkPaths)
CString MainWindow::ProcessClipboard(const void* vbuf, long bufLen,
bool pasteJunkPaths)
{
FileCollection fileColl;
CString errMsg, storagePrefix;
@ -954,17 +900,8 @@ bail:
return errMsg;
}
/*
* 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
MainWindow::ProcessClipboardEntry(const FileCollectionEntry* pCollEnt,
const WCHAR* pathName, const unsigned char* buf, long remLen)
CString MainWindow::ProcessClipboardEntry(const FileCollectionEntry* pCollEnt,
const WCHAR* pathName, const uint8_t* buf, long remLen)
{
GenericArchive::FileDetails::FileKind entryKind;
GenericArchive::FileDetails details;

View File

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

View File

@ -45,14 +45,16 @@ public:
bool fAllowRename;
private:
virtual BOOL OnInitDialog(void) override;
afx_msg void OnYes(void);
afx_msg void OnYesToAll(void);
afx_msg void OnNo(void);
afx_msg void OnNoToAll(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()
};
@ -82,8 +84,8 @@ public:
CString fNewName;
private:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);

View File

@ -35,12 +35,7 @@ ContentList::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
#endif
/*
* 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)
BOOL ContentList::PreCreateWindow(CREATESTRUCT& cs)
{
if (!CListCtrl::PreCreateWindow(cs))
return FALSE;
@ -53,27 +48,18 @@ ContentList::PreCreateWindow(CREATESTRUCT& cs)
return TRUE;
}
/*
* Auto-cleanup the object.
*/
void
ContentList::PostNcDestroy(void)
void ContentList::PostNcDestroy(void)
{
LOGI("ContentList PostNcDestroy");
delete this;
}
static inline int
MaxVal(int a, int b)
static inline int MaxVal(int a, int b)
{
return a > b ? a : b;
}
/*
* Create and populate list control.
*/
int
ContentList::OnCreate(LPCREATESTRUCT lpcs)
int ContentList::OnCreate(LPCREATESTRUCT lpcs)
{
CString colHdrs[kNumVisibleColumns] = {
"Pathname", "Type", "Aux", "Mod Date",
@ -126,12 +112,7 @@ ContentList::OnCreate(LPCREATESTRUCT lpcs)
return 0;
}
/*
* If we're being shut down, save off the column width info before the window
* gets destroyed.
*/
void
ContentList::OnDestroy(void)
void ContentList::OnDestroy(void)
{
LOGI("ContentList OnDestroy");
@ -139,22 +120,13 @@ ContentList::OnDestroy(void)
CListCtrl::OnDestroy();
}
/*
* The system colors are changing; delete the image list and re-load it.
*/
void
ContentList::OnSysColorChange(void)
void ContentList::OnSysColorChange(void)
{
fHdrImageList.DeleteImageList();
LoadHeaderImages();
}
/*
* They've clicked on a header. Figure out what kind of sort order we want
* to use.
*/
void
ContentList::OnColumnClick(NMHDR* pnmh, LRESULT* pResult)
void ContentList::OnColumnClick(NMHDR* pnmh, LRESULT* pResult)
{
NM_LISTVIEW* pnmlv = (NM_LISTVIEW*) pnmh;
@ -171,28 +143,14 @@ ContentList::OnColumnClick(NMHDR* pnmh, LRESULT* pResult)
*pResult = 0;
}
/*
* Copy the current column widths out to the Preferences object.
*/
void
ContentList::ExportColumnWidths(void)
void ContentList::ExportColumnWidths(void)
{
//LOGI("ExportColumnWidths");
for (int i = 0; i < kNumVisibleColumns; i++)
fpLayout->SetColumnWidth(i, GetColumnWidth(i));
}
/*
* 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)
void ContentList::NewColumnWidths(void)
{
for (int i = 0; i < kNumVisibleColumns; i++) {
int width = fpLayout->GetColumnWidth(i);
@ -205,38 +163,7 @@ ContentList::NewColumnWidths(void)
}
}
#if 0 // replaced by GenericArchive reload flag
/*
* 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)
void ContentList::Reload(bool saveSelection)
{
LOGI("Reloading ContentList");
CWaitCursor waitc;
@ -271,14 +198,7 @@ ContentList::Reload(bool saveSelection)
EnsureVisible(top, false);
}
#if 1
/*
* 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* ContentList::GetSelectionSerials(long* pSelCount)
{
long* savedSel = NULL;
long maxCount;
@ -313,11 +233,7 @@ ContentList::GetSelectionSerials(long* pSelCount)
return savedSel;
}
/*
* Restore the selection from the "savedSel" list.
*/
void
ContentList::RestoreSelection(const long* savedSel, long selCount)
void ContentList::RestoreSelection(const long* savedSel, long selCount)
{
LOGI("RestoreSelection (selCount=%d)", selCount);
if (savedSel == NULL)
@ -341,14 +257,8 @@ ContentList::RestoreSelection(const long* savedSel, long selCount)
}
}
}
#endif
/*
* Call this when the sort order changes.
*/
void
ContentList::NewSortOrder(void)
void ContentList::NewSortOrder(void)
{
CWaitCursor wait; // automatically changes mouse to hourglass
int column;
@ -361,14 +271,8 @@ ContentList::NewSortOrder(void)
SortItems(CompareFunc, column);
}
/*
* 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
ContentList::MakeFileTypeDisplayString(const GenericEntry* pEntry, WCHAR* buf)
/*static*/ void ContentList::MakeFileTypeDisplayString(const GenericEntry* pEntry,
WCHAR* buf)
{
bool isDir =
pEntry->GetRecordKind() == GenericEntry::kRecordKindVolumeDir ||
@ -430,14 +334,7 @@ ContentList::MakeFileTypeDisplayString(const GenericEntry* pEntry, 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)
/*static*/ void ContentList::MakeMacTypeString(unsigned long val, WCHAR* buf)
{
/* expand longword with ASCII type bytes */
buf[0] = (unsigned char) (val >> 24);
@ -453,14 +350,8 @@ ContentList::MakeMacTypeString(unsigned long val, 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
ContentList::MakeAuxTypeDisplayString(const GenericEntry* pEntry, WCHAR* buf)
/*static*/ void ContentList::MakeAuxTypeDisplayString(const GenericEntry* pEntry,
WCHAR* buf)
{
bool isDir =
pEntry->GetRecordKind() == GenericEntry::kRecordKindVolumeDir ||
@ -481,15 +372,7 @@ ContentList::MakeAuxTypeDisplayString(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,
void ContentList::MakeRatioDisplayString(const GenericEntry* pEntry, WCHAR* buf,
int* pPerc)
{
LONGLONG totalLen, totalCompLen;
@ -508,15 +391,7 @@ ContentList::MakeRatioDisplayString(const GenericEntry* pEntry, WCHAR* buf,
}
}
/*
* 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)
void ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult)
{
static const WCHAR kAccessBits[] = L"dnb iwr";
LV_DISPINFO* plvdi = (LV_DISPINFO*) pnmh;
@ -616,12 +491,10 @@ ContentList::OnGetDispInfo(NMHDR* pnmh, LRESULT* pResult)
*pResult = 0;
}
/*
* Helper functions for sort routine.
*/
static inline int
CompareUnsignedLong(unsigned long u1, unsigned long u2)
static inline int CompareUnsignedLong(unsigned long u1, unsigned long u2)
{
if (u1 < u2)
return -1;
@ -630,8 +503,7 @@ CompareUnsignedLong(unsigned long u1, unsigned long u2)
else
return 0;
}
static inline int
CompareLONGLONG(LONGLONG u1, LONGLONG u2)
static inline int CompareLONGLONG(LONGLONG u1, LONGLONG u2)
{
if (u1 < u2)
return -1;
@ -640,8 +512,7 @@ CompareLONGLONG(LONGLONG u1, LONGLONG u2)
else
return 0;
}
static inline int
CompareTime(time_t t1, time_t t2)
static inline int CompareTime(time_t t1, time_t t2)
{
if (t1 < t2)
return -1;
@ -651,11 +522,8 @@ CompareTime(time_t t1, time_t t2)
return 0;
}
/*
* Static comparison function for list sorting.
*/
int CALLBACK
ContentList::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
int CALLBACK ContentList::CompareFunc(LPARAM lParam1, LPARAM lParam2,
LPARAM lParamSort)
{
const GenericEntry* pEntry1 = (const GenericEntry*) lParam1;
const GenericEntry* pEntry2 = (const GenericEntry*) lParam2;
@ -730,16 +598,7 @@ ContentList::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
return result;
}
/*
* 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)
int ContentList::LoadData(void)
{
GenericEntry* pEntry;
LV_ITEM lvi;
@ -781,12 +640,7 @@ ContentList::LoadData(void)
return 0;
}
/*
* Return the default width for the specified column.
*/
int
ContentList::GetDefaultWidth(int col)
int ContentList::GetDefaultWidth(int col)
{
int retval;
@ -826,12 +680,7 @@ ContentList::GetDefaultWidth(int col)
return retval;
}
/*
* Set the up/down sorting arrow as appropriate.
*/
void
ContentList::SetSortIcon(void)
void ContentList::SetSortIcon(void)
{
CHeaderCtrl* pHeader = GetHeaderCtrl();
ASSERT(pHeader != NULL);
@ -857,16 +706,7 @@ ContentList::SetSortIcon(void)
}
}
/*
* 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)
void ContentList::OnDoubleClick(NMHDR*, LRESULT* pResult)
{
/* test */
DWORD dwPos = ::GetMessagePos();
@ -883,20 +723,17 @@ ContentList::OnDoubleClick(NMHDR*, LRESULT* pResult)
*pResult = 0;
}
/*
* 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)
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();
CPoint point ((int) LOWORD(dwPos), (int) HIWORD(dwPos));
ScreenToClient(&point);
@ -922,11 +759,7 @@ ContentList::OnRightClick(NMHDR*, LRESULT* pResult)
*pResult = 0;
}
/*
* Mark everything as selected.
*/
void
ContentList::SelectAll(void)
void ContentList::SelectAll(void)
{
int i;
@ -937,11 +770,7 @@ ContentList::SelectAll(void)
}
}
/*
* Toggle the "selected" state flag.
*/
void
ContentList::InvertSelection(void)
void ContentList::InvertSelection(void)
{
int i, oldState;
@ -953,29 +782,26 @@ ContentList::InvertSelection(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)
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;
posn = GetFirstSelectedItemPosition();
if (posn == NULL) {
@ -1018,11 +844,7 @@ ContentList::SelectSubdirContents(void)
}
}
/*
* Select every entry whose display name has "displayPrefix" as a prefix.
*/
void
ContentList::SelectSubdir(const WCHAR* displayPrefix)
void ContentList::SelectSubdir(const WCHAR* displayPrefix)
{
LOGI(" ContentList selecting all in '%ls'", displayPrefix);
int len = wcslen(displayPrefix);
@ -1035,22 +857,13 @@ ContentList::SelectSubdir(const WCHAR* displayPrefix)
}
}
/*
* Mark all items as unselected.
*/
void
ContentList::ClearSelection(void)
void ContentList::ClearSelection(void)
{
for (int i = GetItemCount()-1; i >= 0; i--)
SetItemState(i, 0, LVIS_SELECTED);
}
/*
* 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,
void ContentList::FindNext(const WCHAR* str, bool down, bool matchCase,
bool wholeWord)
{
POSITION posn;
@ -1110,11 +923,7 @@ ContentList::FindNext(const WCHAR* str, bool down, bool matchCase,
}
}
/*
* Compare "str" against the contents of entry "num".
*/
bool
ContentList::CompareFindString(int num, const WCHAR* str, bool matchCase,
bool ContentList::CompareFindString(int num, const WCHAR* str, bool matchCase,
bool wholeWord)
{
GenericEntry* pEntry = (GenericEntry*) GetItemData(num);

View File

@ -4,7 +4,7 @@
* 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
#define APP_CONTENTLIST_H
@ -45,21 +45,69 @@ public:
fpArchive->ClearReloadFlag();
}
// call this before updating underlying storage; call Reload to un-inval
// void Invalidate(void);
// reload from underlying storage
/*
* 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 Reload(bool saveSelection = false);
/*
* Call this when the sort order changes.
*/
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);
/*
* Copy the current column widths out to the Preferences object.
*/
void ExportColumnWidths(void);
/*
* Mark everything as selected.
*/
void SelectAll(void);
/*
* Toggle the "selected" state flag.
*/
void InvertSelection(void);
/*
* Mark all items as unselected.
*/
void ClearSelection(void);
/*
* Select the contents of any selected subdirs.
*/
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);
/*
* Compare "str" against the contents of entry "num".
*/
bool CompareFindString(int num, const WCHAR* str, bool matchCase,
bool wholeWord);
@ -67,21 +115,63 @@ public:
//void ClearRightClickItem(void) { fRightClickItem = -1; }
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,
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,
WCHAR* buf);
protected:
// overridden functions
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void PostNcDestroy(void);
/*
* Puts the window into "report" mode, and add a client edge since we're not
* 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);
/*
* When being shut down, save off the column width info before the window
* gets destroyed.
*/
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 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*);
/*
* 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);
private:
@ -105,22 +195,79 @@ private:
kListIconDamaged = 3,
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);
/*
* Get the "selection serials" from the list of selected items.
*
* The caller is responsible for delete[]ing the return value.
*/
long* GetSelectionSerials(long* pSelCount);
/*
* Restore the selection from the "savedSel" list.
*/
void RestoreSelection(const long* savedSel, long selCount);
/*
* Return the default width for the specified column.
*/
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);
/*
* 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,
int* pPerc);
/*
* Set the up/down sorting arrow as appropriate.
*/
void SetSortIcon(void);
/*
* Static comparison function for list sorting.
*/
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2,
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);
/*
* Handle a right-click on an item.
*/
void OnRightClick(NMHDR* pnmh, LRESULT* pResult);
/*
* Select every entry whose display name has "displayPrefix" as a prefix.
*/
void SelectSubdir(const WCHAR* displayPrefix);
CImageList fHdrImageList;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Support for ConvDiskOptionsDialog.
*/
#include "stdafx.h"
#include "ConvDiskOptionsDialog.h"
#include "NufxArchive.h"
@ -27,14 +24,10 @@ BEGIN_MESSAGE_MAP(ConvDiskOptionsDialog, CDialog)
END_MESSAGE_MAP()
// TODO: get this from DiskImgLib header?
const int kProDOSVolNameMax = 15; // longest possible ProDOS volume name
/*
* Set up our modified version of the "use selection" dialog.
*/
BOOL
ConvDiskOptionsDialog::OnInitDialog(void)
BOOL ConvDiskOptionsDialog::OnInitDialog(void)
{
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_CONVDISK_VOLNAME);
ASSERT(pEdit != NULL);
@ -50,11 +43,7 @@ ConvDiskOptionsDialog::OnInitDialog(void)
return UseSelectionDialog::OnInitDialog();
}
/*
* Convert values.
*/
void
ConvDiskOptionsDialog::DoDataExchange(CDataExchange* pDX)
void ConvDiskOptionsDialog::DoDataExchange(CDataExchange* pDX)
{
UINT specifyBlocks = 280;
CString errMsg;
@ -99,12 +88,7 @@ ConvDiskOptionsDialog::DoDataExchange(CDataExchange* pDX)
UseSelectionDialog::DoDataExchange(pDX);
}
/*
* 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)
void ConvDiskOptionsDialog::OnRadioChangeRange(UINT nID)
{
LOGI("OnChangeRange id=%d", nID);
@ -115,25 +99,13 @@ ConvDiskOptionsDialog::OnRadioChangeRange(UINT nID)
NewDiskSize::UpdateSpecifyEdit(this);
}
/*
* Test a ProDOS filename for validity.
*/
bool
ConvDiskOptionsDialog::IsValidVolumeName_ProDOS(const WCHAR* name)
bool ConvDiskOptionsDialog::IsValidVolumeName_ProDOS(const WCHAR* name)
{
CStringA nameA(name);
return DiskImgLib::DiskFSProDOS::IsValidVolumeName(nameA);
}
/*
* 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)
void ConvDiskOptionsDialog::ResetSizeControls(void)
{
CWnd* pWnd;
CString spaceReq;
@ -155,14 +127,7 @@ ConvDiskOptionsDialog::ResetSizeControls(void)
NewDiskSize::EnableButtons(this);
}
/*
* 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)
void ConvDiskOptionsDialog::LimitSizeControls(long totalBlocks, long blocksUsed)
{
LOGI("LimitSizeControls %ld %ld", totalBlocks, blocksUsed);
LOGI("Full volume requires %ld bitmap blocks",
@ -209,17 +174,7 @@ ConvDiskOptionsDialog::LimitSizeControls(long totalBlocks, long blocksUsed)
#endif
}
/*
* 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)
void ConvDiskOptionsDialog::OnCompute(void)
{
MainWindow* pMain = (MainWindow*)::AfxGetMainWnd();
const Preferences* pPreferences = GET_PREFERENCES();

View File

@ -35,16 +35,44 @@ public:
long fNumBlocks; // computed when DoModal finishes
private:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
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);
/*
* 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);
/*
* 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);
/*
* 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);
/*
* Test a ProDOS filename for validity.
*/
bool IsValidVolumeName_ProDOS(const WCHAR* name);
DECLARE_MESSAGE_MAP()

View File

@ -3,29 +3,11 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Support for ConvFileOptionsDialog.
*/
#include "stdafx.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
/*
* Convert values.
*/
void
ConvFileOptionsDialog::DoDataExchange(CDataExchange* pDX)
void ConvFileOptionsDialog::DoDataExchange(CDataExchange* pDX)
{
//DDX_Check(pDX, IDC_CONVFILE_CONVDOS, fConvDOSText);
//DDX_Check(pDX, IDC_CONVFILE_CONVPASCAL, fConvPascalText);

View File

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

View File

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

View File

@ -52,14 +52,27 @@ public:
long fNumBlocks; // computed when DoModal finishes
private:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
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);
/*
* 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);
// Context help (question mark).
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
// Dialog help ("help" button).
afx_msg void OnHelp(void);
bool IsValidVolumeName_DOS(const WCHAR* name);

View File

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

View File

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

View File

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

View File

@ -44,11 +44,23 @@ public:
int fOpenRsrcFork;
protected:
// overrides
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
/*
* Turn off the "OK" button, which is only active when some text
* 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 BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
private:

View File

@ -17,7 +17,7 @@
#include "ConfirmOverwriteDialog.h"
#include "../diskimg/DiskImgDetail.h"
static const char* kEmptyFolderMarker = ".$$EmptyFolder";
static const char kEmptyFolderMarker[] = ".$$EmptyFolder";
/*
@ -26,24 +26,7 @@ static const char* kEmptyFolderMarker = ".$$EmptyFolder";
* ===========================================================================
*/
/*
* 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,
int DiskEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const
{
DIError dierr;
@ -150,16 +133,7 @@ bail:
return result;
}
/*
* 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,
int DiskEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const
{
A2FileDescr* pOpenFile = NULL;
@ -219,12 +193,7 @@ bail:
return result;
}
/*
* Copy data from the open A2File to outfp, possibly converting EOL along
* the way.
*/
DIError
DiskEntry::CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv,
DIError DiskEntry::CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pMsg) const
{
DIError dierr = kDIErrNone;
@ -287,13 +256,7 @@ bail:
return dierr;
}
/*
* Figure out whether or not we're allowed to change a file's type and
* aux type.
*/
bool
DiskEntry::GetFeatureFlag(Feature feature) const
bool DiskEntry::GetFeatureFlag(Feature feature) const
{
DiskImg::FSFormat format;
@ -392,11 +355,7 @@ DiskEntry::GetFeatureFlag(Feature feature) const
* ===========================================================================
*/
/*
* Perform one-time initialization of the DiskLib library.
*/
/*static*/ CString
DiskArchive::AppInit(void)
/*static*/ CString DiskArchive::AppInit(void)
{
CString result("");
DIError dierr;
@ -427,21 +386,13 @@ bail:
return result;
}
/*
* Perform one-time cleanup of DiskImgLib at shutdown time.
*/
/*static*/ void
DiskArchive::AppCleanup(void)
/*static*/ void DiskArchive::AppCleanup(void)
{
DiskImgLib::Global::AppCleanup();
}
/*
* Handle a debug message from the DiskImg library.
*/
/*static*/ void
DiskArchive::DebugMsgHandler(const char* file, int line, const char* msg)
/*static*/ void DiskArchive::DebugMsgHandler(const char* file, int line,
const char* msg)
{
ASSERT(file != 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);
}
/*
* Progress update callback, called from DiskImgLib during read/write
* operations.
*
* Returns "true" if we should continue;
*/
/*static*/ bool
DiskArchive::ProgressCallback(DiskImgLib::A2FileDescr* pFile,
/*static*/ bool DiskArchive::ProgressCallback(DiskImgLib::A2FileDescr* pFile,
DiskImgLib::di_off_t max, DiskImgLib::di_off_t current, void* state)
{
int status;
@ -471,16 +415,8 @@ DiskArchive::ProgressCallback(DiskImgLib::A2FileDescr* pFile,
return true; // tell DiskImgLib to continue what it's doing
}
/*
* 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
DiskArchive::ScanProgressCallback(void* cookie, const char* str, int count)
/*static*/ bool DiskArchive::ScanProgressCallback(void* cookie, const char* str,
int count)
{
CString fmt;
bool cont;
@ -498,12 +434,8 @@ DiskArchive::ScanProgressCallback(void* cookie, const char* str, int count)
return cont;
}
/*
* Finish instantiating a DiskArchive object by opening an existing file.
*/
GenericArchive::OpenResult
DiskArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
GenericArchive::OpenResult DiskArchive::Open(const WCHAR* filename,
bool readOnly, CString* pErrMsg)
{
DIError dierr;
CString errMsg;
@ -715,14 +647,7 @@ bail:
return result;
}
/*
* 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)
CString DiskArchive::New(const WCHAR* fileName, const void* vOptions)
{
const Preferences* pPreferences = GET_PREFERENCES();
NewOptions* pOptions = (NewOptions*) vOptions;
@ -901,11 +826,7 @@ bail:
return retmsg;
}
/*
* Close the DiskArchive ojbect.
*/
CString
DiskArchive::Close(void)
CString DiskArchive::Close(void)
{
if (fpPrimaryDiskFS != NULL) {
LOGI("DiskArchive shutdown closing disk image");
@ -930,17 +851,7 @@ DiskArchive::Close(void)
return L"";
}
/*
* 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)
CString DiskArchive::Flush(void)
{
DIError dierr;
CWaitCursor waitc;
@ -959,23 +870,14 @@ DiskArchive::Flush(void)
return L"";
}
/*
* Returns "true" if the archive has un-flushed modifications pending.
*/
bool
DiskArchive::IsModified(void) const
bool DiskArchive::IsModified(void) const
{
assert(fpPrimaryDiskFS != NULL);
return fpPrimaryDiskFS->GetDiskImg()->GetDirtyFlag();
}
/*
* Return an description of the disk archive, suitable for display in the
* main title bar.
*/
void
DiskArchive::GetDescription(CString* pStr) const
void DiskArchive::GetDescription(CString* pStr) const
{
if (fpPrimaryDiskFS == NULL)
return;
@ -985,14 +887,7 @@ DiskArchive::GetDescription(CString* pStr) const
}
}
/*
* Load the contents of a "disk archive".
*
* Returns 0 on success.
*/
int
DiskArchive::LoadContents(void)
int DiskArchive::LoadContents(void)
{
int result;
@ -1018,22 +913,7 @@ DiskArchive::LoadContents(void)
return result;
}
/*
* 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()
CString DiskArchive::Reload()
{
fReloadFlag = true; // tell everybody that cached data is invalid
@ -1047,14 +927,7 @@ DiskArchive::Reload()
return "";
}
/*
* 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)
int DiskArchive::InternalReload(CWnd* pMsgWnd)
{
CString errMsg;
@ -1068,14 +941,7 @@ DiskArchive::InternalReload(CWnd* pMsgWnd)
return 0;
}
/*
* 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)
int DiskArchive::LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName)
{
static const WCHAR* kBlankFileName = L"<blank filename>";
A2File* pFile;
@ -1231,15 +1097,7 @@ DiskArchive::LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName)
return 0;
}
/*
* 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)
void DiskArchive::PreferencesChanged(void)
{
const Preferences* pPreferences = GET_PREFERENCES();
@ -1251,12 +1109,7 @@ DiskArchive::PreferencesChanged(void)
}
}
/*
* Report on what this disk image is capable of.
*/
long
DiskArchive::GetCapability(Capability cap)
long DiskArchive::GetCapability(Capability cap)
{
switch (cap) {
case kCapCanTest:
@ -1297,13 +1150,7 @@ DiskArchive::GetCapability(Capability cap)
* ===========================================================================
*/
/*
* Process a bulk "add" request.
*
* Returns "true" on success, "false" on failure.
*/
bool
DiskArchive::BulkAdd(ActionProgressDialog* pActionProgress,
bool DiskArchive::BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts)
{
NuError nerr;
@ -1396,43 +1243,40 @@ bail:
return retVal;
}
/*
* 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,
NuError DiskArchive::DoAddFile(const AddFilesDialog* pAddOpts,
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;
DiskFS* pDiskFS = pAddOpts->fpTargetDiskFS;
@ -1527,22 +1371,7 @@ bail:
return nuerr;
}
/*
* 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,
NuResult DiskArchive::HandleReplaceExisting(const A2File* pExisting,
FileDetails* pDetails)
{
NuResult result;
@ -1602,14 +1431,7 @@ DiskArchive::HandleReplaceExisting(const A2File* pExisting,
return result;
}
/*
* Process the list of pending file adds.
*
* This is where the rubber (finally!) meets the road.
*/
CString
DiskArchive::ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL)
CString DiskArchive::ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL)
{
CString errMsg;
FileAddData* pData;
@ -1775,25 +1597,14 @@ bail:
return errMsg;
}
#define kCharLF '\n'
#define kCharCR '\r'
/*
* 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.
*
* 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,
// TODO: 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
{
const char kCharLF = '\n';
const char kCharCR = '\r';
CString errMsg;
FILE* fp;
long fileLen;
@ -1950,16 +1761,8 @@ bail:
return errMsg;
}
/*
* 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
DiskArchive::AddForksToDisk(DiskFS* pDiskFS, const DiskFS::CreateParms* pParms,
DIError DiskArchive::AddForksToDisk(DiskFS* pDiskFS,
const DiskFS::CreateParms* pParms,
const unsigned char* dataBuf, long dataLen,
const unsigned char* rsrcBuf, long rsrcLen) const
{
@ -2149,14 +1952,7 @@ bail:
return dierr;
}
/*
* 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,
void DiskArchive::ConvertFDToCP(const FileDetails* pDetails,
DiskFS::CreateParms* pCreateParms)
{
// TODO(xyzzy): need to store 8-bit form
@ -2170,19 +1966,7 @@ DiskArchive::ConvertFDToCP(const FileDetails* pDetails,
pCreateParms->modWhen = NufxArchive::DateTimeToSeconds(&pDetails->modWhen);
}
/*
* 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)
void DiskArchive::AddToAddDataList(FileAddData* pData)
{
ASSERT(pData != NULL);
ASSERT(pData->GetNext() == NULL);
@ -2234,11 +2018,7 @@ DiskArchive::AddToAddDataList(FileAddData* pData)
}
}
/*
* Free all entries in the FileAddData list.
*/
void
DiskArchive::FreeAddDataList(void)
void DiskArchive::FreeAddDataList(void)
{
FileAddData* pData;
FileAddData* pNext;
@ -2261,11 +2041,7 @@ DiskArchive::FreeAddDataList(void)
* ===========================================================================
*/
/*
* Create a subdirectory named "newName" in "pParentEntry".
*/
bool
DiskArchive::CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
bool DiskArchive::CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName)
{
ASSERT(newName != NULL && wcslen(newName) > 0);
@ -2332,11 +2108,8 @@ DiskArchive::CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
* ===========================================================================
*/
/*
* Compare DiskEntry display names in descending order (Z-A).
*/
/*static*/ int
DiskArchive::CompareDisplayNamesDesc(const void* ventry1, const void* ventry2)
/*static*/ int DiskArchive::CompareDisplayNamesDesc(const void* ventry1,
const void* ventry2)
{
const DiskEntry* pEntry1 = *((const DiskEntry**) ventry1);
const DiskEntry* pEntry2 = *((const DiskEntry**) ventry2);
@ -2344,21 +2117,18 @@ DiskArchive::CompareDisplayNamesDesc(const void* ventry1, const void* ventry2)
return wcsicmp(pEntry2->GetDisplayName(), pEntry1->GetDisplayName());
}
/*
* 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)
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;
SelectionEntry* pSelEntry;
DiskEntry* pEntry;
@ -2467,20 +2237,17 @@ bail:
* ===========================================================================
*/
/*
* 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)
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;
bool retVal = false;
@ -2546,13 +2313,7 @@ bail:
return retVal;
}
/*
* Set up a RenameEntryDialog for the entry in "*pEntry".
*
* Returns "true" on success, "false" on failure.
*/
bool
DiskArchive::SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
bool DiskArchive::SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
RenameEntryDialog* pDialog)
{
DiskFS* pDiskFS;
@ -2598,16 +2359,7 @@ DiskArchive::SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
return true;
}
/*
* 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,
CString DiskArchive::TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const
{
const DiskEntry* pEntry = (DiskEntry*) pGenericEntry;
@ -2670,13 +2422,7 @@ bail:
* ===========================================================================
*/
/*
* Ask a DiskFS to change its volume name.
*
* Returns "true" on success, "false" on failure.
*/
bool
DiskArchive::RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
bool DiskArchive::RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
const WCHAR* newName)
{
DIError dierr;
@ -2700,11 +2446,7 @@ DiskArchive::RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
return retVal;
}
/*
* Test a volume name for validity.
*/
CString
DiskArchive::TestVolumeName(const DiskFS* pDiskFS,
CString DiskArchive::TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const
{
DiskImg::FSFormat format;
@ -2748,18 +2490,13 @@ DiskArchive::TestVolumeName(const DiskFS* pDiskFS,
* ===========================================================================
*/
/*
* 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,
bool DiskArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
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;
DiskEntry* pEntry = (DiskEntry*) pGenericEntry;
A2File* pFile = pEntry->GetA2File();
@ -2802,20 +2539,17 @@ DiskArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
* ===========================================================================
*/
/*
* Transfer the selected files out of this archive and into another.
*
* 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)
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!");
unsigned char* dataBuf = NULL;
unsigned char* rsrcBuf = NULL;
@ -3024,11 +2758,7 @@ bail:
return retval;
}
/*
* Prepare for file transfers.
*/
void
DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
void DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
{
LOGI("DiskArchive::XferPrepare");
@ -3042,21 +2772,7 @@ DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
fpXferTargetFS = pXferOpts->fpTargetFS;
}
/*
* 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,
CString DiskArchive::XferFile(FileDetails* pDetails, uint8_t** pDataBuf,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen)
{
//const int kFileTypeTXT = 0x04;
@ -3144,23 +2860,14 @@ bail:
return errMsg;
}
/*
* Abort our progress. Not really possible, except by throwing the disk
* image away.
*/
void
DiskArchive::XferAbort(CWnd* pMsgWnd)
void DiskArchive::XferAbort(CWnd* pMsgWnd)
{
// Can't undo previous actions.
LOGI("DiskArchive::XferAbort");
InternalReload(pMsgWnd);
}
/*
* Transfer is finished.
*/
void
DiskArchive::XferFinish(CWnd* pMsgWnd)
void DiskArchive::XferFinish(CWnd* pMsgWnd)
{
LOGI("DiskArchive::XferFinish");
InternalReload(pMsgWnd);

View File

@ -24,14 +24,19 @@ public:
{}
virtual ~DiskEntry(void) {}
// retrieve thread data
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,
ConvertHighASCII convHA, CString* pErrMsg) const;
virtual long GetSelectionSerial(void) const { return -1; } // idea: T/S block number
ConvertHighASCII convHA, CString* pErrMsg) const override;
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
virtual DiskImg::FSFormat GetFSFormat(void) const {
@ -43,6 +48,10 @@ public:
void SetA2File(A2File* pFile) { fpFile = pFile; }
private:
/*
* Copy data from the open A2File to outfp, possibly converting EOL along
* the way.
*/
DIError CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pMsg) const;
@ -96,69 +105,145 @@ public:
} dos;
} NewOptions;
// One-time initialization; returns an error string.
/*
* Perform one-time initialization of the DiskLib library.
*/
static CString AppInit(void);
// one-time cleanup at app shutdown time
/*
* Perform one-time cleanup of DiskImgLib at shutdown time.
*/
static void AppCleanup(void);
virtual OpenResult Open(const WCHAR* filename, bool readOnly, CString* pErrMsg);
virtual CString New(const WCHAR* filename, const void* options);
virtual CString Flush(void);
virtual CString Reload(void);
virtual bool IsReadOnly(void) const { return fIsReadOnly; };
virtual bool IsModified(void) const;
virtual void GetDescription(CString* pStr) const;
/*
* Finish instantiating a DiskArchive object by opening an existing file.
*/
virtual OpenResult Open(const WCHAR* filename, bool readOnly,
CString* pErrMsg) override;
/*
* 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,
const AddFilesDialog* pAddOpts);
const AddFilesDialog* pAddOpts) override;
virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts)
const AddFilesDialog* pAddOpts) override
{ ASSERT(false); return false; }
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName);
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
const WCHAR* newName) override;
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override
{ ASSERT(false); return false; }
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet);
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet);
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
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,
const WCHAR* newName);
const WCHAR* newName) override;
virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const;
const WCHAR* newName) const override;
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts)
const RecompressOptionsDialog* pRecompOpts) override
{ ASSERT(false); return false; }
virtual bool GetComment(CWnd* pMsgWnd, const GenericEntry* pEntry,
CString* pStr)
CString* pStr) override
{ ASSERT(false); return false; }
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str)
const CString& str) override
{ ASSERT(false); return false; }
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry)
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override
{ ASSERT(false); return false; }
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps);
virtual void PreferencesChanged(void);
virtual long GetCapability(Capability cap);
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress, const XferFileOptions* pXferOpts);
const FileProps* pProps) override;
/*
* 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; }
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,
DiskImgLib::di_off_t max, DiskImgLib::di_off_t current, void* state);
private:
/*
* Close the DiskArchive ojbect.
*/
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,
int count);
@ -206,32 +291,123 @@ private:
FileAddData* fpNext;
};
virtual ArchiveKind GetArchiveKind(void) { return kArchiveDiskImage; }
virtual ArchiveKind GetArchiveKind(void) override { return kArchiveDiskImage; }
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);
/*
* Compare DiskEntry display names in descending order (Z-A).
*/
static int CompareDisplayNamesDesc(const void* ventry1, const void* ventry2);
/*
* Load the contents of a "disk archive". Returns 0 on success.
*/
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);
void DowncaseSubstring(CString* pStr, int startPos, int endPos,
bool prevWasSpace);
/*
* Handle a debug message from the DiskImg library.
*/
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,
FileDetails* pDetails);
/*
* Process the list of pending file adds.
*
* This is where the rubber (finally!) meets the road.
*/
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,
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,
const uint8_t* dataBuf, long dataLen,
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);
/*
* Free all entries in the FileAddData list.
*/
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,
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,
RenameEntryDialog* pDialog);

View File

@ -19,11 +19,7 @@ BEGIN_MESSAGE_MAP(DiskConvertDialog, CDialog)
END_MESSAGE_MAP()
/*
* Initialize the set of available options based on the source image.
*/
void
DiskConvertDialog::Init(const DiskImg* pDiskImg)
void DiskConvertDialog::Init(const DiskImg* pDiskImg)
{
ASSERT(pDiskImg != NULL);
const int kMagicNibbles = -1234;
@ -129,11 +125,7 @@ DiskConvertDialog::Init(const DiskImg* pDiskImg)
}
}
/*
* Initialize options for a bulk transfer.
*/
void
DiskConvertDialog::Init(int fileCount)
void DiskConvertDialog::Init(int fileCount)
{
/* allow everything */
fAllowUnadornedDOS = fAllowUnadornedProDOS = fAllowProDOS2MG =
@ -144,12 +136,7 @@ DiskConvertDialog::Init(int fileCount)
fDiskDescription.Format(L"%d images selected", fBulkFileCount);
}
/*
* Disable unavailable options.
*/
BOOL
DiskConvertDialog::OnInitDialog(void)
BOOL DiskConvertDialog::OnInitDialog(void)
{
CWnd* pWnd;
@ -227,11 +214,7 @@ DiskConvertDialog::OnInitDialog(void)
return TRUE;
}
/*
* Convert options in and out.
*/
void
DiskConvertDialog::DoDataExchange(CDataExchange* pDX)
void DiskConvertDialog::DoDataExchange(CDataExchange* pDX)
{
DDX_Check(pDX, IDC_DISKCONV_GZIP, fAddGzip);
DDX_Radio(pDX, IDC_DISKCONV_DOS, fConvertIdx);
@ -264,15 +247,7 @@ DiskConvertDialog::DoDataExchange(CDataExchange* pDX)
}
}
/*
* 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)
void DiskConvertDialog::OnChangeRadio(UINT nID)
{
CWnd* pGzip = GetDlgItem(IDC_DISKCONV_GZIP);
ASSERT(pGzip != NULL);
@ -285,21 +260,13 @@ DiskConvertDialog::OnChangeRadio(UINT nID)
pGzip->EnableWindow(pNuFX->GetCheck() == BST_UNCHECKED);
}
/*
* Context help request (question mark button).
*/
BOOL
DiskConvertDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
BOOL DiskConvertDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it
}
/*
* User pressed the "Help" button.
*/
void
DiskConvertDialog::OnHelp(void)
void DiskConvertDialog::OnHelp(void)
{
if (fBulkFileCount < 0)
WinHelp(HELP_TOPIC_DISK_CONV, HELP_CONTEXT);

View File

@ -29,8 +29,15 @@ public:
}
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 */
enum {
@ -55,13 +62,23 @@ public:
CString fExtension;
private:
BOOL OnInitDialog(void);
void DoDataExchange(CDataExchange* pDX);
BOOL OnInitDialog(void) override;
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);
// User pressed the "Help" button.
afx_msg void OnHelp(void);
BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
// Context help request (question mark button).
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
CString fDiskDescription;
bool fAllowUnadornedDOS;

View File

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

View File

@ -49,7 +49,15 @@ public:
virtual int LoadData(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);
/*
* Display a track full of nibble data.
*/
virtual void DisplayNibbleData(const uint8_t* srcBuf, int size);
bool GetReadOnly(void) const { return fReadOnly; }
@ -72,28 +80,72 @@ protected:
return ch & 0x7f;
}
// overrides
virtual BOOL OnInitDialog(void);
virtual BOOL OnInitDialog(void) override;
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);
/*
* Toggle the spin button / edit controls.
*/
afx_msg virtual void OnHexMode(void);
afx_msg virtual void OnDoRead(void) = 0;
afx_msg virtual void OnDoWrite(void) = 0;
afx_msg virtual void OnReadPrev(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 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 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);
/*
* 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);
/*
* Set the value of a spin control.
*/
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,
A2FileDescr** ppOpenFile);
@ -104,8 +156,16 @@ protected:
int fPositionShift;
private:
/*
* Initialize the nibble parm drop-list.
*/
void InitNibbleParmList(void);
/*
* Replace a spin button with our improved version.
*/
int ReplaceSpinCtrl(MySpinCtrl* pNewSpin, int idSpin, int idEdit);
MySpinCtrl fTrackSpinner;
MySpinCtrl fSectorSpinner;
bool fFirstResize;
@ -129,22 +189,34 @@ public:
}
virtual ~SectorEditDialog() {}
virtual int LoadData(void); // load the current track/sector
virtual void DisplayData(void) {
virtual int LoadData(void) override; // load the current track/sector
virtual void DisplayData(void) override {
DiskEditDialog::DisplayData(fSectorData, kSectorSize);
}
//void SetTrack(int val) { fTrack = val; }
//void SetSector(int val) { fSector = val; }
// overrides
virtual BOOL OnInitDialog(void);
protected:
virtual BOOL OnInitDialog(void) override;
afx_msg virtual void OnDoRead(void);
afx_msg virtual void OnDoWrite(void);
/*
* Back up to the previous track/sector.
*/
afx_msg virtual void OnReadPrev(void);
/*
* Advance to the next track/sector.
*/
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);
long fTrack;
@ -211,21 +283,32 @@ public:
}
virtual ~BlockEditDialog() {}
virtual int LoadData(void); // load the current block
virtual void DisplayData(void) {
virtual int LoadData(void) override; // load the current block
virtual void DisplayData(void) override {
DiskEditDialog::DisplayData(fBlockData, kBlockSize);
}
// overrides
virtual BOOL OnInitDialog(void);
protected:
//void MoveControl(int id, int deltaX, int deltaY);
virtual BOOL OnInitDialog(void) override;
afx_msg virtual void OnDoRead(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);
/*
* Same as OnReadPrev, but moving forward.
*/
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);
long fBlock;
@ -266,7 +349,14 @@ private:
// overrides
virtual BOOL OnInitDialog(void);
/*
* Move to the previous Block in the file.
*/
afx_msg virtual void OnReadPrev(void);
/*
* Move to the next Block in the file.
*/
afx_msg virtual void OnReadNext(void);
CString fOpenFileName;
@ -291,15 +381,18 @@ public:
}
virtual ~NibbleEditDialog() {}
virtual int LoadData(void); // load the current track/sector
virtual void DisplayData(void) {
virtual int LoadData(void) override; // load the current track/sector
virtual void DisplayData(void) override {
DiskEditDialog::DisplayNibbleData(fNibbleData, fNibbleDataLen);
}
// overrides
virtual BOOL OnInitDialog(void);
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 OnDoWrite(void);
afx_msg virtual void OnReadPrev(void);

View File

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

View File

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

View File

@ -12,11 +12,7 @@
using namespace DiskImgLib;
/*
* Build the tree.
*/
bool
DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree)
bool DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree)
{
ASSERT(pDiskFS != NULL);
ASSERT(pTree != NULL);
@ -25,16 +21,7 @@ DiskFSTree::BuildTree(DiskFS* pDiskFS, CTreeCtrl* pTree)
return AddDiskFS(pTree, TVI_ROOT, pDiskFS, 1);
}
/*
* 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,
bool DiskFSTree::AddDiskFS(CTreeCtrl* pTree, HTREEITEM parent,
DiskImgLib::DiskFS* pDiskFS, int depth)
{
const DiskFS::SubVolume* pSubVol;
@ -116,21 +103,7 @@ DiskFSTree::AddDiskFS(CTreeCtrl* pTree, HTREEITEM parent,
return true;
}
/*
* 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::A2File* DiskFSTree::AddSubdir(CTreeCtrl* pTree, HTREEITEM parent,
DiskImgLib::DiskFS* pDiskFS, DiskImgLib::A2File* pParentFile,
int depth)
{
@ -212,12 +185,7 @@ DiskFSTree::AddSubdir(CTreeCtrl* pTree, HTREEITEM parent,
return pFile;
}
/*
* Allocate a new TargetData struct, and add it to our list.
*/
DiskFSTree::TargetData*
DiskFSTree::AllocTargetData(void)
DiskFSTree::TargetData* DiskFSTree::AllocTargetData(void)
{
TargetData* pNew = new TargetData;
@ -232,13 +200,7 @@ DiskFSTree::AllocTargetData(void)
return pNew;
}
/*
* Free up the TargetData structures we created.
*
* Rather than
*/
void
DiskFSTree::FreeAllTargetData(void)
void DiskFSTree::FreeAllTargetData(void)
{
TargetData* pTarget;
TargetData* pNext;

View File

@ -52,13 +52,40 @@ public:
struct TargetData* pNext;
} 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,
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::DiskFS* pDiskFS, DiskImgLib::A2File* pFile,
int depth);
/*
* Allocate a new TargetData struct, and add it to our list.
*/
TargetData* AllocTargetData(void);
/*
* Free up the TargetData structures we created.
*/
void FreeAllTargetData(void);
void LoadTreeImages(void) {

View File

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

View File

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

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Support for EditAssocDialog.
*/
#include "stdafx.h"
#include "EditAssocDialog.h"
#include "MyApp.h"
@ -24,11 +21,7 @@ END_MESSAGE_MAP()
INDEXTOSTATEIMAGEMASK((fCheck)+1), LVIS_STATEIMAGEMASK)
#endif
/*
* Tweak the controls.
*/
BOOL
EditAssocDialog::OnInitDialog(void)
BOOL EditAssocDialog::OnInitDialog(void)
{
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST);
@ -59,18 +52,9 @@ EditAssocDialog::OnInitDialog(void)
return CDialog::OnInitDialog();
}
/*
* 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)
void EditAssocDialog::Setup(bool loadAssoc)
{
LOGI("Setup!");
LOGD("Setup!");
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST);
ASSERT(pListView != NULL);
@ -107,11 +91,7 @@ EditAssocDialog::Setup(bool loadAssoc)
//DeleteAllItems(); // for Reload case
}
/*
* Copy state in and out of dialog.
*/
void
EditAssocDialog::DoDataExchange(CDataExchange* pDX)
void EditAssocDialog::DoDataExchange(CDataExchange* pDX)
{
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_ASSOCIATION_LIST);
@ -140,20 +120,12 @@ EditAssocDialog::DoDataExchange(CDataExchange* pDX)
}
}
/*
* Context help request (question mark button).
*/
BOOL
EditAssocDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
BOOL EditAssocDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{
return ShowContextHelp(this, lpHelpInfo);
}
/*
* User pressed the "Help" button.
*/
void
EditAssocDialog::OnHelp(void)
void EditAssocDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_EDIT_ASSOC, HELP_CONTEXT);
}

View File

@ -30,13 +30,20 @@ public:
bool* fOurAssociations;
protected:
// overrides
virtual BOOL OnInitDialog(void);
BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
void DoDataExchange(CDataExchange* pDX) override;
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
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);
DECLARE_MESSAGE_MAP()

View File

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

View File

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

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Support for file properties edit dialog.
*/
#include "StdAfx.h"
#include "EditPropsDialog.h"
#include "FileNameConv.h"
@ -25,11 +22,7 @@ BEGIN_MESSAGE_MAP(EditPropsDialog, CDialog)
END_MESSAGE_MAP()
/*
* Initialize fProps from the stuff in pEntry.
*/
void
EditPropsDialog::InitProps(GenericEntry* pEntry)
void EditPropsDialog::InitProps(GenericEntry* pEntry)
{
fPathName = pEntry->GetPathName();
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,
* though this would provide a way for users to fix badly-formed archives.
*/
BOOL
EditPropsDialog::OnInitDialog(void)
BOOL EditPropsDialog::OnInitDialog(void)
{
static const int kPascalTypes[] = {
0x00 /*NON*/, 0x01 /*BAD*/, 0x02 /*PCD*/, 0x03 /*PTX*/,
@ -197,11 +189,7 @@ EditPropsDialog::OnInitDialog(void)
return CDialog::OnInitDialog();
}
/*
* Convert values.
*/
void
EditPropsDialog::DoDataExchange(CDataExchange* pDX)
void EditPropsDialog::DoDataExchange(CDataExchange* pDX)
{
int fileTypeIdx;
BOOL accessR, accessW, accessI, accessB, accessN, accessD;
@ -342,17 +330,7 @@ EditPropsDialog::DoDataExchange(CDataExchange* pDX)
DDX_Text(pDX, IDC_PROPS_PATHNAME, fPathName);
}
/*
* 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)
void EditPropsDialog::OnTypeChange(void)
{
static const WCHAR kUnknownFileType[] = L"Unknown file type";
CComboBox* pCombo;
@ -388,20 +366,12 @@ EditPropsDialog::OnTypeChange(void)
}
}
/*
* Called when something is typed in one of the HFS type boxes.
*/
void
EditPropsDialog::OnHFSTypeChange(void)
void EditPropsDialog::OnHFSTypeChange(void)
{
assert(fAllowedTypes == kAllowedHFS);
}
/*
* Called initially and when switching modes.
*/
void
EditPropsDialog::UpdateHFSMode(void)
void EditPropsDialog::UpdateHFSMode(void)
{
CButton* pButton = (CButton*) GetDlgItem(IDC_PROPS_HFS_MODE);
CComboBox* pCombo;
@ -449,13 +419,7 @@ EditPropsDialog::UpdateHFSMode(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)
void EditPropsDialog::UpdateSimpleAccess(void)
{
if (!fSimpleAccess)
return;
@ -472,15 +436,7 @@ EditPropsDialog::UpdateSimpleAccess(void)
pButton->SetCheck(checked);
}
/*
* Get the aux type.
*
* Returns -1 if something was wrong with the string (e.g. empty or has
* invalid chars).
*/
long
EditPropsDialog::GetAuxType(void)
long EditPropsDialog::GetAuxType(void)
{
CWnd* pWnd = GetDlgItem(IDC_PROPS_AUXTYPE);
ASSERT(pWnd != NULL);
@ -505,21 +461,13 @@ EditPropsDialog::GetAuxType(void)
return val;
}
/*
* Context help request (question mark button).
*/
BOOL
EditPropsDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
BOOL EditPropsDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it
}
/*
* User pressed the "Help" button.
*/
void
EditPropsDialog::OnHelp(void)
void EditPropsDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_EDIT_PROPS, HELP_CONTEXT);
}

View File

@ -50,19 +50,46 @@ public:
bool fReadOnly;
private:
// overrides
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* 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);
/*
* Called when something is typed in one of the HFS type boxes.
*/
afx_msg void OnHFSTypeChange(void);
afx_msg void OnHelp(void);
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);
/*
* Called initially and when switching modes.
*/
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);
//void ShowHFSType(void);
/* what sort of type changes do we allow? */
AllowedTypes fAllowedTypes;

View File

@ -23,8 +23,7 @@ END_MESSAGE_MAP()
/*
* Disable the "OK" button initially.
*/
BOOL
EnterRegDialog::OnInitDialog(void)
BOOL EnterRegDialog::OnInitDialog(void)
{
//CWnd* pWnd = GetDlgItem(IDOK);
//ASSERT(pWnd != NULL);
@ -53,8 +52,7 @@ EnterRegDialog::OnInitDialog(void)
* Shuffle data in and out of the edit fields. We do an extra validation
* step on the registration key before accepting it.
*/
void
EnterRegDialog::DoDataExchange(CDataExchange* pDX)
void EnterRegDialog::DoDataExchange(CDataExchange* pDX)
{
DDX_Text(pDX, IDC_REGENTER_USER, fUserName);
DDX_Text(pDX, IDC_REGENTER_COMPANY, fCompanyName);
@ -85,14 +83,7 @@ EnterRegDialog::DoDataExchange(CDataExchange* pDX)
}
}
/*
* 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)
void EnterRegDialog::HandleEditChange(int editID, int crcID)
{
CString userStr, regStr;
CEdit* pEdit;
@ -127,45 +118,29 @@ EnterRegDialog::HandleEditChange(int editID, int crcID)
pWnd->EnableWindow(!userStr.IsEmpty() && !regStr.IsEmpty());
}
/*
* Handle changes in the three edit fields.
*/
void
EnterRegDialog::OnUserChange(void)
void EnterRegDialog::OnUserChange(void)
{
HandleEditChange(IDC_REGENTER_USER, IDC_REGENTER_USERCRC);
}
void
EnterRegDialog::OnCompanyChange(void)
void EnterRegDialog::OnCompanyChange(void)
{
HandleEditChange(IDC_REGENTER_COMPANY, IDC_REGENTER_COMPCRC);
}
void
EnterRegDialog::OnRegChange(void)
void EnterRegDialog::OnRegChange(void)
{
HandleEditChange(IDC_REGENTER_REG, IDC_REGENTER_REGCRC);
}
/*
* User pressed the "Help" button.
*/
void
EnterRegDialog::OnHelp(void)
void EnterRegDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_ENTER_REG_DATA, HELP_CONTEXT);
}
/*
* 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)
/*static*/ int EnterRegDialog::GetRegInfo(CWnd* pWnd)
{
CString user, company, reg, versions, expire;
@ -208,4 +183,4 @@ EnterRegDialog::GetRegInfo(CWnd* pWnd)
return result;
}
#endif /*0*/
#endif /*0*/

View File

@ -16,29 +16,43 @@
* Straightforward dialog. We validate the registration key in the DDX
* 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.
*
* [ This was only used in the shareware product. ]
*/
class EnterRegDialog : public CDialog {
public:
EnterRegDialog(CWnd* pParent = NULL) : CDialog(IDD_REGISTRATION, pParent)
{ fDepth = 0; }
{ fDepth = 0; }
virtual ~EnterRegDialog(void) {}
CString fUserName;
CString fCompanyName;
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);
private:
// overrides
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnUserChange(void);
afx_msg void OnCompanyChange(void);
afx_msg void OnRegChange(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);
MyEdit fMyEdit;

View File

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

View File

@ -68,14 +68,34 @@ public:
}
private:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* Reconfigure controls for best preservation of Apple II formats.
*/
afx_msg void OnConfigPreserve(void);
/*
* Reconfigure controls for easiest viewing under Windows.
*/
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);
/*
* They want to choose the folder from a tree.
*/
afx_msg void OnChooseFolder(void);
// Context help request (question mark button).
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
// User pressed the "Help" button.
afx_msg void OnHelp(void);
MyBitmapButton fChooseFolderButton;

View File

@ -15,6 +15,7 @@
#define WINDOWS_LIKE
/* replace unsupported chars with '%xx' */
#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"
};
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"
* 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 */
};
/*
* 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.
*
@ -589,16 +587,10 @@ static const struct {
/*OS */ { 0xff, 0x0000, 0xffff, L"ProDOS 8 application" },
};
/*
* 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*
PathProposal::FileTypeDescription(long fileType, long auxType)
/*static*/ const WCHAR* PathProposal::FileTypeDescription(long fileType,
long auxType)
{
int i;
for (i = NELEM(gTypeDescriptions)-1; i >= 0; i--) {
for (int i = NELEM(gTypeDescriptions)-1; i >= 0; i--) {
if (fileType == gTypeDescriptions[i].fileType &&
auxType >= gTypeDescriptions[i].minAuxType &&
auxType <= gTypeDescriptions[i].maxAuxType)
@ -617,15 +609,7 @@ PathProposal::FileTypeDescription(long fileType, long auxType)
* ===========================================================================
*/
/*
* 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)
void PathProposal::ArchiveToLocal(void)
{
WCHAR* pathBuf;
const WCHAR* startp;
@ -736,17 +720,14 @@ static const WCHAR* gFatReservedNames4[] = {
NULL
};
/*
* 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,
void PathProposal::Win32NormalizeFileName(const WCHAR* srcp, long srcLen,
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;
const WCHAR* startp = srcp;
static const WCHAR* kInvalid = L"\\/:*?\"<>|";
@ -823,18 +804,7 @@ PathProposal::Win32NormalizeFileName(const WCHAR* srcp, long srcLen,
}
#endif
/*
* 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,
void PathProposal::NormalizeFileName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen)
{
ASSERT(srcp != NULL);
@ -852,12 +822,7 @@ PathProposal::NormalizeFileName(const WCHAR* srcp, long srcLen,
#endif
}
/*
* Normalize a directory name to local filesystem conventions.
*/
void
PathProposal::NormalizeDirectoryName(const WCHAR* srcp, long srcLen,
void PathProposal::NormalizeDirectoryName(const WCHAR* srcp, long srcLen,
char fssep, WCHAR** pDstp, long dstLen)
{
/* 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);
}
/*
* 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)
void PathProposal::AddPreservationString(const WCHAR* pathBuf, WCHAR* extBuf)
{
WCHAR* cp;
@ -905,14 +862,7 @@ PathProposal::AddPreservationString(const WCHAR* pathBuf, WCHAR* extBuf)
*cp = '\0';
}
/*
* 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)
void PathProposal::AddTypeExtension(const WCHAR* pathBuf, WCHAR* extBuf)
{
const WCHAR* pPathExt = NULL;
const WCHAR* pWantedExt = NULL;
@ -1024,18 +974,7 @@ know_ext:
typedef bool Boolean;
/*
* 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)
void PathProposal::LocalToArchive(const AddFilesDialog* pAddOpts)
{
Boolean wasPreserved;
Boolean doJunk = false;
@ -1173,12 +1112,7 @@ PathProposal::LocalToArchive(const AddFilesDialog* pAddOpts)
fStoredPathName.ReleaseBuffer();
}
/*
* 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)
void PathProposal::ReplaceFssep(WCHAR* str, char oldc, char newc, char newSubst)
{
while (*str != '\0') {
if (*str == oldc)
@ -1189,15 +1123,7 @@ PathProposal::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
PathProposal::LookupExtension(const WCHAR* ext)
void PathProposal::LookupExtension(const WCHAR* ext)
{
WCHAR uext3[4];
int i, extLen;
@ -1242,11 +1168,7 @@ bail:
return;
}
/*
* Try to associate some meaning with the file extension.
*/
void
PathProposal::InterpretExtension(const WCHAR* pathName)
void PathProposal::InterpretExtension(const WCHAR* pathName)
{
const WCHAR* pExt;
@ -1257,18 +1179,12 @@ PathProposal::InterpretExtension(const WCHAR* pathName)
LookupExtension(pExt+1);
}
/*
* 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)
Boolean PathProposal::ExtractPreservationString(WCHAR* pathname)
{
/*
* We have to be careful not to trip on false-positive occurrences of '#'
* in the filename.
*/
WCHAR numBuf[9];
unsigned long fileType, auxType;
int threadMask;
@ -1352,15 +1268,7 @@ PathProposal::ExtractPreservationString(WCHAR* pathname)
return true;
}
/*
* 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)
void PathProposal::DenormalizePath(WCHAR* pathBuf)
{
const WCHAR* srcp;
WCHAR* dstp;
@ -1402,14 +1310,7 @@ PathProposal::DenormalizePath(WCHAR* pathBuf)
ASSERT(dstp <= srcp);
}
/*
* 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)
void PathProposal::StripDiskImageSuffix(WCHAR* pathName)
{
static const WCHAR diskExt[][4] = {
L"SHK", L"SDK", L"IMG", L"PO", L"DO", L"2MG", L"DSK"

View File

@ -11,7 +11,6 @@
#include "GenericArchive.h"
#define kUnknownTypeStr L"???"
/*
* Proposal for an output pathname, based on the contents of a GenericEntry.
@ -78,9 +77,25 @@ public:
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);
// 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);
/*
@ -113,26 +128,98 @@ public:
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);
/*
* 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);
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,
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,
char fssep, WCHAR** pDstp, long dstLen);
/*
* Normalize a directory name to local filesystem conventions.
*/
void NormalizeDirectoryName(const WCHAR* srcp, long srcLen,
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);
/*
* 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);
/*
* 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);
/*
* 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);
bool ExtractPreservationString(WCHAR* pathName);
/*
* Try to associate some meaning with the file extension.
*/
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);
/*
* 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);
};

View File

@ -45,9 +45,6 @@
* ===========================================================================
*/
/*
* Initialize all data members.
*/
GenericEntry::GenericEntry(void)
{
fPathName = NULL;
@ -81,9 +78,6 @@ GenericEntry::GenericEntry(void)
fDamaged = fSuspicious = false;
}
/*
* Throw out anything we allocated.
*/
GenericEntry::~GenericEntry(void)
{
delete[] fPathName;
@ -91,11 +85,7 @@ GenericEntry::~GenericEntry(void)
delete[] fDisplayName;
}
/*
* Pathname getters and setters.
*/
void
GenericEntry::SetPathName(const WCHAR* path)
void GenericEntry::SetPathName(const WCHAR* path)
{
ASSERT(path != NULL && wcslen(path) > 0);
if (fPathName != NULL)
@ -117,29 +107,29 @@ GenericEntry::SetPathName(const WCHAR* path)
if (pPreferences->GetPrefBool(kPrSpacesToUnder))
SpacesToUnderscores(fPathName);
}
const WCHAR*
GenericEntry::GetFileName(void)
const WCHAR* GenericEntry::GetFileName(void)
{
ASSERT(fPathName != NULL);
if (fFileName == NULL)
fFileName = PathName::FilenameOnly(fPathName, fFssep);
return fFileName;
}
const WCHAR*
GenericEntry::GetFileNameExtension(void)
const WCHAR* GenericEntry::GetFileNameExtension(void)
{
ASSERT(fPathName != NULL);
if (fFileNameExtension == NULL)
fFileNameExtension = PathName::FindExtension(fPathName, fFssep);
return fFileNameExtension;
}
CStringA
GenericEntry::GetFileNameExtensionA(void)
CStringA GenericEntry::GetFileNameExtensionA(void)
{
return GetFileNameExtension();
}
void
GenericEntry::SetSubVolName(const WCHAR* name)
void GenericEntry::SetSubVolName(const WCHAR* name)
{
delete[] fSubVolName;
fSubVolName = NULL;
@ -147,8 +137,8 @@ GenericEntry::SetSubVolName(const WCHAR* name)
fSubVolName = wcsdup(name);
}
}
const WCHAR*
GenericEntry::GetDisplayName(void) const
const WCHAR* GenericEntry::GetDisplayName(void) const
{
ASSERT(fPathName != NULL);
if (fDisplayName != NULL)
@ -172,20 +162,12 @@ GenericEntry::GetDisplayName(void) const
return pThis->fDisplayName;
}
/*
* Get a string for this entry's filetype.
*/
const WCHAR*
GenericEntry::GetFileTypeString(void) const
const WCHAR* GenericEntry::GetFileTypeString(void) const
{
return PathProposal::FileTypeString(fFileType);
}
/*
* Convert spaces to underscores.
*/
/*static*/ void
GenericEntry::SpacesToUnderscores(WCHAR* buf)
/*static*/ void GenericEntry::SpacesToUnderscores(WCHAR* buf)
{
while (*buf != '\0') {
if (*buf == ' ')
@ -194,24 +176,22 @@ GenericEntry::SpacesToUnderscores(WCHAR* buf)
}
}
/*
* (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,
/*static*/ bool GenericEntry::CheckHighASCII(const uint8_t* buffer,
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;
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 */
};
#define kNuMaxUpperASCII 1 /* max #of binary chars per 100 bytes */
#define kMinConvThreshold 40 /* min of 40 chars for auto-detect */
#define kCharLF '\n'
#define kCharCR '\r'
/*
* Decide, based on the contents of the buffer, whether we should do an
* EOL conversion on the data.
*
* 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,
static const int kNuMaxUpperASCII = 1; /* max #of binary chars per 100 bytes */
static const int kMinConvThreshold = 40; /* min of 40 chars for auto-detect */
static const char kCharLF = '\n';
static const char kCharCR = '\r';
/*static*/ GenericEntry::ConvertEOL GenericEntry::DetermineConversion(
const uint8_t* buffer, long count,
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;
long bufCount, numBinary, numLF, numCR;
bool isHighASCII;
unsigned char val;
uint8_t val;
*pSourceType = kEOLUnknown;
*pConvHA = kConvertHAOff;
@ -380,29 +356,13 @@ GenericEntry::DetermineConversion(const unsigned char* buffer, long count,
/*
* Output CRLF.
*/
static inline void
PutEOL(FILE* fp)
static inline void PutEOL(FILE* fp)
{
putc(kCharCR, fp);
putc(kCharLF, fp);
}
/*
* 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,
/*static*/ int GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
ConvertEOL* pConv, ConvertHighASCII* pConvHA, bool* pLastCR)
{
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 (*pConv == kConvertEOLAuto) {
EOLType sourceType;
*pConv = DetermineConversion((unsigned char*)buf, len, &sourceType,
*pConv = DetermineConversion((uint8_t*)buf, len, &sourceType,
pConvHA);
if (*pConv == kConvertEOLOn && sourceType == kEOLCRLF) {
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) {
if (*pConv == kConvertEOLOn) {
/* definitely converting EOL, test for high ASCII */
if (CheckHighASCII((unsigned char*)buf, len))
if (CheckHighASCII((uint8_t*)buf, len))
*pConvHA = kConvertHAOn;
else
*pConvHA = kConvertHAOff;
@ -449,7 +409,7 @@ GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
} else {
ASSERT(*pConv == kConvertEOLOn);
bool lastCR = *pLastCR;
unsigned char uch;
uint8_t uch;
int mask;
if (*pConvHA == kConvertHAOn)
@ -486,11 +446,7 @@ GenericEntry::WriteConvert(FILE* fp, const char* buf, size_t len,
* ===========================================================================
*/
/*
* Add a new entry to the end of the list.
*/
void
GenericArchive::AddEntry(GenericEntry* pEntry)
void GenericArchive::AddEntry(GenericEntry* pEntry)
{
if (fEntryHead == NULL) {
ASSERT(fEntryTail == NULL);
@ -516,11 +472,7 @@ GenericArchive::AddEntry(GenericEntry* pEntry)
//}
}
/*
* Delete the "entries" list.
*/
void
GenericArchive::DeleteEntries(void)
void GenericArchive::DeleteEntries(void)
{
GenericEntry* pEntry;
GenericEntry* pNext;
@ -567,20 +519,17 @@ GenericArchive::CreateIndex(void)
}
#endif
/*
* 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)
/*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";
CString mangle(filename);
int idx, len;
@ -602,23 +551,7 @@ GenericArchive::GenDerivedTempName(const WCHAR* filename)
return mangle;
}
/*
* 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,
/*static*/ int GenericArchive::ComparePaths(const CString& name1, char fssep1,
const CString& name2, char fssep2)
{
const WCHAR* cp1 = name1;
@ -668,11 +601,8 @@ GenericArchive::ComparePaths(const CString& name1, char fssep1,
typedef bool Boolean;
/*
* Convert from time in seconds to Apple IIgs DateTime format.
*/
/*static*/ void
GenericArchive::UNIXTimeToDateTime(const time_t* pWhen, NuDateTime* pDateTime)
/*static*/ void GenericArchive::UNIXTimeToDateTime(const time_t* pWhen,
NuDateTime* pDateTime)
{
struct tm* ptm;
@ -695,16 +625,7 @@ GenericArchive::UNIXTimeToDateTime(const time_t* pWhen, NuDateTime* pDateTime)
pDateTime->weekDay = ptm->tm_wday +1;
}
/*
* 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,
NuError GenericArchive::GetFileDetails(const AddFilesDialog* pAddOpts,
const WCHAR* pathname, struct _stat* psb, FileDetails* pDetails)
{
//char* livePathStr;
@ -809,13 +730,7 @@ typedef struct Win32dirent {
static const WCHAR kWildMatchAll[] = L"*.*";
/*
* Prepare a directory for reading.
*
* Allocates a Win32dirent struct that must be freed by the caller.
*/
Win32dirent*
GenericArchive::OpenDir(const WCHAR* name)
Win32dirent* GenericArchive::OpenDir(const WCHAR* name)
{
Win32dirent* dir = NULL;
WCHAR* tmpStr = NULL;
@ -858,13 +773,7 @@ failed:
goto bail;
}
/*
* Get an entry from an open directory.
*
* Returns a NULL pointer after the last entry has been read.
*/
Win32dirent*
GenericArchive::ReadDir(Win32dirent* dir)
Win32dirent* GenericArchive::ReadDir(Win32dirent* dir)
{
if (dir->d_first)
dir->d_first = 0;
@ -880,11 +789,7 @@ GenericArchive::ReadDir(Win32dirent* dir)
return dir;
}
/*
* Close a directory.
*/
void
GenericArchive::CloseDir(Win32dirent* dir)
void GenericArchive::CloseDir(Win32dirent* dir)
{
if (dir == NULL)
return;
@ -893,13 +798,7 @@ GenericArchive::CloseDir(Win32dirent* dir)
free(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
GenericArchive::Win32AddDirectory(const AddFilesDialog* pAddOpts,
NuError GenericArchive::Win32AddDirectory(const AddFilesDialog* pAddOpts,
const WCHAR* dirName, CString* pErrMsg)
{
NuError err = kNuErrNone;
@ -961,15 +860,7 @@ bail:
return err;
}
/*
* 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,
NuError GenericArchive::Win32AddFile(const AddFilesDialog* pAddOpts,
const WCHAR* pathname, CString* pErrMsg)
{
NuError err = kNuErrNone;
@ -1036,21 +927,10 @@ bail:
return err;
}
/*
* External entry point; just calls the system-specific version.
*
* [ 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)
NuError GenericArchive::AddFile(const AddFilesDialog* pAddOpts,
const WCHAR* pathname, CString* pErrMsg)
{
*pErrMsg = "";
*pErrMsg = L"";
return Win32AddFile(pAddOpts, pathname, pErrMsg);
}
@ -1060,9 +940,6 @@ GenericArchive::AddFile(const AddFilesDialog* pAddOpts, const WCHAR* pathname,
* ===========================================================================
*/
/*
* Constructor.
*/
GenericArchive::FileDetails::FileDetails(void)
{
//threadID = 0;
@ -1075,12 +952,6 @@ GenericArchive::FileDetails::FileDetails(void)
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
{
NuFileDetails details;
@ -1155,13 +1026,7 @@ GenericArchive::FileDetails::operator const NuFileDetails() const
return details;
}
/*
* Copy the contents of our object to a new object.
*
* Useful for operator= and copy construction.
*/
/*static*/ void
GenericArchive::FileDetails::CopyFields(FileDetails* pDst,
/*static*/ void GenericArchive::FileDetails::CopyFields(FileDetails* pDst,
const FileDetails* pSrc)
{
//pDst->threadID = pSrc->threadID;
@ -1186,16 +1051,13 @@ GenericArchive::FileDetails::CopyFields(FileDetails* pDst,
* ===========================================================================
*/
/*
* 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)
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);
POSITION posn;
@ -1211,11 +1073,7 @@ SelectionSet::CreateFromSelection(ContentList* pContentList, int threadMask)
}
}
/*
* Like CreateFromSelection, but includes the entire list.
*/
void
SelectionSet::CreateFromAll(ContentList* pContentList, int threadMask)
void SelectionSet::CreateFromAll(ContentList* pContentList, int threadMask)
{
LOGI("CreateFromAll (threadMask=0x%02x)", threadMask);
@ -1227,12 +1085,7 @@ SelectionSet::CreateFromAll(ContentList* pContentList, 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)
void SelectionSet::AddToSet(GenericEntry* pEntry, int threadMask)
{
SelectionEntry* pSelEntry;
@ -1280,11 +1133,7 @@ SelectionSet::AddToSet(GenericEntry* pEntry, int threadMask)
}
}
/*
* Add a new entry to the end of the list.
*/
void
SelectionSet::AddEntry(SelectionEntry* pEntry)
void SelectionSet::AddEntry(SelectionEntry* pEntry)
{
if (fEntryHead == NULL) {
ASSERT(fEntryTail == NULL);
@ -1304,11 +1153,7 @@ SelectionSet::AddEntry(SelectionEntry* pEntry)
fNumEntries++;
}
/*
* Delete the "entries" list.
*/
void
SelectionSet::DeleteEntries(void)
void SelectionSet::DeleteEntries(void)
{
SelectionEntry* pEntry;
SelectionEntry* pNext;
@ -1323,11 +1168,7 @@ SelectionSet::DeleteEntries(void)
}
}
/*
* Count the #of entries whose display name matches the prefix string.
*/
int
SelectionSet::CountMatchingPrefix(const WCHAR* prefix)
int SelectionSet::CountMatchingPrefix(const WCHAR* prefix)
{
SelectionEntry* pEntry;
int count = 0;
@ -1346,11 +1187,7 @@ SelectionSet::CountMatchingPrefix(const WCHAR* prefix)
return count;
}
/*
* Dump the contents of a selection set.
*/
void
SelectionSet::Dump(void)
void SelectionSet::Dump(void)
{
const SelectionEntry* pEntry;

View File

@ -4,7 +4,8 @@
* 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.
*/
@ -39,11 +40,11 @@ const int kFileTypeBAS = 0xfc;
* Set of data allowed in file property "set file info" calls.
*/
typedef struct FileProps {
unsigned long fileType;
unsigned long auxType;
unsigned long access;
time_t createWhen;
time_t modWhen;
uint32_t fileType;
uint32_t auxType;
uint32_t access;
time_t createWhen;
time_t modWhen;
} FileProps;
/*
@ -148,9 +149,34 @@ public:
kFeatureHasInvisibleFlag,
} 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,
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,
ConvertHighASCII convHA, CString* pErrMsg) const = 0;
@ -226,18 +252,48 @@ public:
GenericEntry* GetNext(void) const { return fpNext; }
void SetNext(GenericEntry* pEntry) { fpNext = pEntry; }
// Utility functions.
/*
* Get a string for this entry's filetype.
*/
const WCHAR* GetFileTypeString(void) const;
/*
* Check to see if this is a high-ASCII file.
*/
static bool CheckHighASCII(const uint8_t* buffer,
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,
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,
size_t len, ConvertEOL* pConv, ConvertHighASCII* pConvHA,
bool* pLastCR);
protected:
/*
* Convert spaces to underscores, modifying the string.
*/
static void SpacesToUnderscores(WCHAR* buf);
private:
@ -303,12 +359,6 @@ public:
virtual long GetNumEntries(void) const {
return fNumEntries;
}
//virtual GenericEntry* GetEntry(long num) {
// ASSERT(num >= 0 && num < fNumEntries);
// if (fEntryIndex == NULL)
// CreateIndex();
// return fEntryIndex[num];
//}
typedef enum {
kResultUnknown = 0,
@ -353,10 +403,12 @@ public:
// Do a bulk add.
virtual bool BulkAdd(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) = 0;
// Do a disk add.
// Add a single disk to the archive.
virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts) = 0;
// Create a subdirectory.
// Create a subdirectory with name newName in pParentEntry.
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName) = 0;
@ -368,6 +420,13 @@ public:
// Rename a set of files.
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,
const CString& basePath, const CString& newName, char newFssep) const = 0;
@ -381,26 +440,33 @@ public:
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts) = 0;
// Transfer files out of this archive and into another.
// return result from XferSelection()
typedef enum {
kXferOK = 0, kXferFailed = 1, kXferCancelled = 2, kXferOutOfSpace = 3
} XferStatus;
// Transfer selected files out of this archive and into another.
virtual XferStatus XferSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
ActionProgressDialog* pActionProgress,
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,
CString* pStr) = 0;
// Set a comment on an entry.
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str) = 0;
// Delete the comment from the entry.
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,
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;
// Determine an archive's capabilities. This is specific to the object
@ -422,11 +488,31 @@ public:
// Get the pathname of the file we opened.
const WCHAR* GetPathName(void) const { return fPathName; }
// Generic utility function.
/*
* Generate a temp name from a file name.
*/
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,
const CString& name2, char fssep2);
/*
* Add a new entry to the end of the list.
*/
void AddEntry(GenericEntry* pEntry);
/*
@ -505,41 +591,108 @@ public:
//NuFileSysID fileSysID;
DiskImg::FSFormat fileSysFmt;
unsigned short fileSysInfo; /* fssep lurks here */
unsigned long access;
unsigned long fileType;
unsigned long extraType;
unsigned short storageType; /* "Unknown" or disk block size */
uint16_t fileSysInfo; /* fssep lurks here */
uint32_t access;
uint32_t fileType;
uint32_t extraType;
uint16_t storageType; /* "Unknown" or disk block size */
NuDateTime createWhen;
NuDateTime modWhen;
NuDateTime archiveWhen;
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);
};
// Transfer files, one at a time, into this archive from another.
// Prepare for file transfers.
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,
long dataLen, uint8_t** pRsrcBuf, long rsrcLen) = 0;
// Abort progress. Not all subclasses are capable of "undo".
virtual void XferAbort(CWnd* pMsgWnd) = 0;
// Transfer is finished.
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);
protected:
/*
* Delete the "entries" list.
*/
virtual void DeleteEntries(void);
/* NuLib2-derived recursive directory add functions */
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,
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);
/*
* Get an entry from an open directory.
*
* Returns a NULL pointer after the last entry has been read.
*/
Win32dirent* ReadDir(Win32dirent* dir);
/*
* Close a directory.
*/
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,
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,
const WCHAR* pathname, CString* pErrMsg);
/*
* External entry point; just calls the system-specific version.
*/
NuError AddFile(const AddFilesDialog* pAddOpts, const WCHAR* pathname,
CString* pErrMsg);
@ -687,13 +840,24 @@ public:
// count the #of entries whose display name matches "prefix"
int CountMatchingPrefix(const WCHAR* prefix);
// debug dump
// debug dump the contents of the selection set
void Dump(void);
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);
/*
* Add a new entry to the end of the list.
*/
void AddEntry(SelectionEntry* pEntry);
/*
* Delete the "entries" list.
*/
void DeleteEntries(void);
int fNumEntries;

View File

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

View File

@ -3,18 +3,16 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Dialog asking the user to confirm certain details of a disk image.
*/
#ifndef APP_IMAGEFORMATDIALOG_H
#define APP_IMAGEFORMATDIALOG_H
//#include <afxwin.h>
#include "resource.h"
#include "../diskimg/DiskImg.h"
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
* DiskImg structure.
*/
@ -38,7 +36,9 @@ public:
fHasSectors = fHasBlocks = fHasNibbles = false;
}
// initialize values from a DiskImg
/*
* Initialize our members by querying the associated DiskImg.
*/
void InitializeValues(const DiskImg* pImg);
bool fInitialized;
@ -58,15 +58,37 @@ public:
void SetAllowGenericFormats(bool val) { fAllowGenericFormats = val; }
protected:
//virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void);
void OnOK(void);
virtual BOOL OnInitDialog(void) override;
/*
* 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 BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
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);
/*
* 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);
/*
* Find the enum value for the specified index.
*/
int ConvComboSel(int boxID, const ConvTable* pTable);
bool fQueryDisplayFormat;

File diff suppressed because it is too large Load Diff

View File

@ -44,9 +44,17 @@ public:
MainWindow(void);
~MainWindow(void);
// Overridden functions
BOOL PreCreateWindow(CREATESTRUCT& cs);
//BOOL OnCreateClient( LPCREATESTRUCT lpcs, CCreateContext* pContext );
/*
* Override the pre-create function to tweak the window style.
*/
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;
// get a pointer to the preferences
@ -65,22 +73,50 @@ public:
const WCHAR* newName);
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);
// 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);
// do some idle processing
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);
// raise flag to abort the current print job
void SetAbortPrinting(bool val) { fAbortPrinting = val; }
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);
bool fAbortPrinting;
// track printer choice
HANDLE fhDevMode;
@ -90,7 +126,10 @@ public:
//void SetAbortOperation(bool val) { fAbortOperation = val; }
//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);
ContentList* GetContentList(void) const { return fpContentList; }
@ -103,41 +142,103 @@ public:
}
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,
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();
// 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);
// make a not-so-happy noise
/*
* If something fails, make noise if we're configured for loudness.
*/
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);
// 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,
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,
DiskImg::FSFormat defaultFormat, int* pDisplayFormat,
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,
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);
// raise a flag to cause a full reload of the open file
void SetReopenFlag(void) { fNeedReopen = true; }
/*
* Configure a ReformatHolder based on the current preferences.
*/
static void ConfigureReformatFromPreferences(ReformatHolder* pReformat);
/*
* Convert a DiskImg format spec into a ReformatHolder SourceFormat.
*/
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,
const uint8_t* dataBuf, long dataLen,
const uint8_t* rsrcBuf, long rsrcLen,
@ -159,17 +260,14 @@ private:
// Command handlers
afx_msg int OnCreate(LPCREATESTRUCT lpcs);
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 OnGetMinMaxInfo(MINMAXINFO* pMMI);
afx_msg void OnPaint(void);
//afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg BOOL OnQueryEndSession(void);
afx_msg void OnEndSession(BOOL bEnding);
afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
//afx_msg LONG OnHelp(UINT wParam, LONG lParam);
afx_msg void OnFileNewArchive(void);
afx_msg void OnFileOpen(void);
afx_msg void OnFileOpenVolume(void);
@ -185,12 +283,26 @@ private:
afx_msg void OnFilePrint(void);
afx_msg void OnUpdateFilePrint(CCmdUI* pCmdUI);
afx_msg void OnFileExit(void);
/*
* Copy data to the clipboard.
*/
afx_msg void OnEditCopy(void);
afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
/*
* Paste data from the clipboard, using the configured defaults.
*/
afx_msg void OnEditPaste(void);
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 OnUpdateEditPasteSpecial(CCmdUI* pCmdUI);
afx_msg void OnEditFind(void);
afx_msg void OnUpdateEditFind(CCmdUI* pCmdUI);
afx_msg void OnEditSelectAll(void);
@ -200,50 +312,157 @@ private:
afx_msg void OnEditPreferences(void);
afx_msg void OnEditSort(UINT id);
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 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 OnUpdateActionsOpenAsDisk(CCmdUI* pCmdUI);
/*
* Add files to an archive.
*/
afx_msg void OnActionsAddFiles(void);
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 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 OnUpdateActionsCreateSubdir(CCmdUI* pCmdUI);
/*
* Extract files.
*/
afx_msg void OnActionsExtract(void);
afx_msg void OnUpdateActionsExtract(CCmdUI* pCmdUI);
/*
* Test files.
*/
afx_msg void OnActionsTest(void);
afx_msg void OnUpdateActionsTest(CCmdUI* pCmdUI);
/*
* Delete archive entries.
*/
afx_msg void OnActionsDelete(void);
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 OnUpdateActionsRename(CCmdUI* pCmdUI);
/*
* Edit a comment, creating it if necessary.
*/
afx_msg void OnActionsEditComment(void);
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 OnUpdateActionsEditProps(CCmdUI* pCmdUI);
/*
* Change a volume name or volume number.
*/
afx_msg void OnActionsRenameVolume(void);
afx_msg void OnUpdateActionsRenameVolume(CCmdUI* pCmdUI);
/*
* Recompress files.
*/
afx_msg void OnActionsRecompress(void);
afx_msg void OnUpdateActionsRecompress(CCmdUI* pCmdUI);
/*
* Select files to convert.
*/
afx_msg void OnActionsConvDisk(void);
afx_msg void OnUpdateActionsConvDisk(CCmdUI* pCmdUI);
/*
* Select files to convert.
*/
afx_msg void OnActionsConvFile(void);
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 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 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 OnUpdateActionsImportBAS(CCmdUI* pCmdUI);
// edit a disk
afx_msg void OnToolsDiskEdit(void);
// convert a disk image from one format to another
afx_msg void OnToolsDiskConv(void);
// bulk disk conversion
afx_msg void OnToolsBulkDiskConv(void);
// merge two SST images into a single NIB image
afx_msg void OnToolsSSTMerge(void);
afx_msg void OnToolsVolumeCopierVolume(void);
afx_msg void OnToolsVolumeCopierFile(void);
// scan and report on the end-of-line markers found in a file
afx_msg void OnToolsEOLScanner(void);
// edit the properties (but not the disk image inside) a .2MG disk image
afx_msg void OnToolsTwoImgProps(void);
// create a new disk image
afx_msg void OnToolsDiskImageCreator(void);
afx_msg void OnHelpContents(void);
afx_msg void OnHelpWebSite(void);
@ -251,83 +470,352 @@ private:
afx_msg void OnHelpAbout(void);
afx_msg void OnRtClkDefault(void);
// Handle command-line arguments.
void ProcessCommandLine(void);
void ResizeClientArea(void);
/*
* Draw what looks like an empty client area.
*/
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,
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);
void DoOpenArchive(const WCHAR* pathName, const WCHAR* ext,
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 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);
/*
* Switch the content list to a new archive, closing the previous if one
* was already open.
*/
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);
/*
* Close the existing archive file, and throw out the control we're
* using to display it.
*/
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);
/*
* Set the title bar to something boring when nothing is open.
*/
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);
/*
* 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 DeleteFileOnExit(const WCHAR* name);
/*
* Close and re-open the current archive.
*/
void ReopenArchive(void);
/* some stuff from Actions.cpp */
//int GetFileText(SelectionEntry* pSelEntry, ReformatHolder* pHolder,
// CString* pTitle);
/*
* ===== Actions.cpp =====
*/
/*
* Load the requested part.
*/
void GetFilePart(const GenericEntry* pEntry, int whichThread,
ReformatHolder* pHolder) const;
/**
* this is a test
* of whatever the hell this does
* whee.
*/
/*
* Handle a bulk extraction.
*/
void DoBulkExtract(SelectionSet* pSelSet,
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,
ReformatHolder* pHolder, const ExtractOptionsDialog* pExtOpts,
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,
time_t arcFileModWhen, bool* pOverwriteExisting, bool* pOvwrForAll,
FILE** pFp);
bool DoBulkRecompress(ActionProgressDialog* pActionProgress,
SelectionSet* pSelSet, const RecompressOptionsDialog* pRecompOpts);
/*
* Compute the total size of all files in the GenericArchive.
*/
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);
/*
* Double-up all double quotes.
*/
static CString DblDblQuote(const WCHAR* str);
/*
* Compute the size of everything currently on the clipboard.
*/
long GetClipboardContentLen(void);
/*
* Create the file collection.
*/
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);
/*
* Do some prep work and then call ProcessClipboard to copy files in.
*/
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,
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,
DiskImg::OuterFormat* pOuterFormat, DiskImg::FileFormat* pFileFormat,
DiskImg::PhysicalFormat* pPhysicalFormat,
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,
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);
/*
* 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,
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);
/*
* 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);
/*
* 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);
/*
* Select a volume and then invoke the volcopy dialog.
*/
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);
void PrintListing(const ContentList* pContentList);
// set when one of the tools modifies the file we have open
bool fNeedReopen;

View File

@ -17,15 +17,17 @@
/* magic global that MFC finds (or that finds MFC) */
MyApp gMyApp;
/* used for debug logging */
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.
*/
MyApp::MyApp(LPCTSTR lpszAppName) : CWinApp(lpszAppName)
{
gDebugLog = new DebugLog(L"C:\\src\\cplog.txt");
time_t now = time(NULL);
@ -54,19 +56,9 @@ MyApp::~MyApp(void)
delete gDebugLog;
}
/*
* It all begins here.
*
* Create a main window.
*/
BOOL
MyApp::InitInstance(void)
BOOL MyApp::InitInstance(void)
{
//fclose(fopen("c:\\cp-initinstance.txt", "w"));
//_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG);
// Create the main window.
m_pMainWnd = new MainWindow;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
@ -146,13 +138,7 @@ MyApp::InitInstance(void)
return TRUE;
}
/*
* 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)
void MyApp::LogModuleLocation(const WCHAR* name)
{
HMODULE hModule;
WCHAR fileNameBuf[256];
@ -167,11 +153,7 @@ MyApp::LogModuleLocation(const WCHAR* name)
}
}
/*
* Do some idle processing.
*/
BOOL
MyApp::OnIdle(LONG lCount)
BOOL MyApp::OnIdle(LONG lCount)
{
BOOL bMore = CWinApp::OnIdle(lCount);

View File

@ -32,10 +32,14 @@ public:
const WCHAR* GetExeBaseName(void) const { return fExeBaseName; }
private:
// Overridden functions
virtual BOOL InitInstance(void);
virtual BOOL OnIdle(LONG lCount);
virtual BOOL InitInstance(void) override;
virtual BOOL OnIdle(LONG lCount) override;
/*
* 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);
CString fExeFileName;

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Functions and data to support the "new disk size" radio buttons.
*/
#include "stdafx.h"
#include "NewDiskSize.h"
#include "resource.h"
@ -27,27 +24,18 @@
};
static const int kEditBoxID = IDC_CONVDISK_SPECIFY_EDIT;
/*
* Return the #of entries in the table.
*/
/*static*/ unsigned int
NewDiskSize::GetNumSizeEntries(void)
/*static*/ unsigned int NewDiskSize::GetNumSizeEntries(void)
{
return NELEM(kCtrlMap);
}
/*
* Return the "size" field from an array entry.
*/
/*static*/ long
NewDiskSize::GetDiskSizeByIndex(int idx)
/*static*/ long NewDiskSize::GetDiskSizeByIndex(int idx)
{
ASSERT(idx >= 0 && idx < NELEM(kCtrlMap));
return kCtrlMap[idx].blocks;
}
/*static*/ void
NewDiskSize::EnableButtons(CDialog* pDialog, BOOL state /*=true*/)
/*static*/ void NewDiskSize::EnableButtons(CDialog* pDialog, BOOL state)
{
CWnd* pWnd;
@ -58,22 +46,8 @@ NewDiskSize::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
NewDiskSize::EnableButtons_ProDOS(CDialog* pDialog, long totalBlocks,
long blocksUsed)
/*static*/ void NewDiskSize::EnableButtons_ProDOS(CDialog* pDialog,
long totalBlocks, long blocksUsed)
{
CButton* pButton;
long usedWithoutBitmap = blocksUsed - GetNumBitmapBlocks_ProDOS(totalBlocks);
@ -116,23 +90,14 @@ NewDiskSize::EnableButtons_ProDOS(CDialog* pDialog, long totalBlocks,
UpdateSpecifyEdit(pDialog);
}
/*
* Compute the #of blocks needed to hold the ProDOS block bitmap.
*/
/*static*/long
NewDiskSize::GetNumBitmapBlocks_ProDOS(long totalBlocks) {
/*static*/ long NewDiskSize::GetNumBitmapBlocks_ProDOS(long totalBlocks) {
ASSERT(totalBlocks > 0);
const int kBitsPerBlock = 512 * 8;
int numBlocks = (totalBlocks + kBitsPerBlock-1) / kBitsPerBlock;
return numBlocks;
}
/*
* Update the "specify size" edit box.
*/
/*static*/ void
NewDiskSize::UpdateSpecifyEdit(CDialog* pDialog)
/*static*/ void NewDiskSize::UpdateSpecifyEdit(CDialog* pDialog)
{
CEdit* pEdit = (CEdit*) pDialog->GetDlgItem(kEditBoxID);
int i;

View File

@ -16,14 +16,44 @@ class NewDiskSize {
public:
NewDiskSize(void) { ASSERT(false); }
/*
* Return the #of entries in the table.
*/
static unsigned int GetNumSizeEntries(void);
/*
* Return the "size" field from an array entry.
*/
static long GetDiskSizeByIndex(int idx);
enum { kSpecified = -1 };
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,
long blocksUsed);
/*
* Compute the #of blocks needed to hold the ProDOS block bitmap.
*/
static long GetNumBitmapBlocks_ProDOS(long totalBlocks);
/*
* Update the "specify size" edit box.
*/
static void UpdateSpecifyEdit(CDialog* pDialog);
private:

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Allow the user to create a new folder.
*/
#include "stdafx.h"
#include "NewFolderDialog.h"
@ -13,24 +10,22 @@ BEGIN_MESSAGE_MAP(NewFolderDialog, CDialog)
ON_WM_HELPINFO()
END_MESSAGE_MAP()
/*
* 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)
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)
DDX_Text(pDX, IDC_NEWFOLDER_CURDIR, fCurrentFolder);
@ -72,12 +67,7 @@ NewFolderDialog::DoDataExchange(CDataExchange* pDX)
}
}
/*
* Context help request (question mark button).
*/
BOOL
NewFolderDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
BOOL NewFolderDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it

View File

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

View File

@ -29,24 +29,7 @@ const unsigned char kNufxNoFssep = 0xff;
* ===========================================================================
*/
/*
* 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,
int NufxEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
CString* pErrMsg) const
{
NuError nerr;
@ -148,16 +131,7 @@ bail:
return result;
}
/*
* 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,
int NufxEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
ConvertHighASCII convHA, CString* pErrMsg) const
{
NuDataSink* pDataSink = NULL;
@ -259,18 +233,7 @@ bail:
return result;
}
/*
* 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,
void NufxEntry::FindThreadInfo(int which, NuThread* pRetThread,
CString* pErrMsg) const
{
NuError nerr;
@ -334,29 +297,24 @@ static const WCHAR* gFormatNames[] = {
L"LZC-16", L"Deflate", L"Bzip2"
};
/*
* 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)
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;
NuThreadID threadID;
unsigned long idx;
@ -442,17 +400,7 @@ NufxEntry::AnalyzeRecord(const NuRecord* pRecord)
* ===========================================================================
*/
/*
* 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)
/*static*/ CString NufxArchive::AppInit(void)
{
NuError nerr;
CString result("");
@ -483,15 +431,7 @@ bail:
return result;
}
/*
* Determine whether a particular kind of compression is supported by
* NufxLib.
*
* Returns "true" if supported, "false" if not.
*/
/*static*/ bool
NufxArchive::IsCompressionSupported(NuThreadFormat format)
/*static*/ bool NufxArchive::IsCompressionSupported(NuThreadFormat format)
{
NuFeature feature;
@ -529,11 +469,7 @@ NufxArchive::IsCompressionSupported(NuThreadFormat format)
return false;
}
/*
* Display error messages... or not.
*/
NuResult
NufxArchive::NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage)
NuResult NufxArchive::NufxErrorMsgHandler(NuArchive*, void* vErrorMessage)
{
const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage;
@ -544,14 +480,10 @@ NufxArchive::NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage)
return kNuOK;
}
/*
* Display our progress.
*
* "oldName" ends up on top, "newName" on bottom.
*/
/*static*/NuResult
NufxArchive::ProgressUpdater(NuArchive* pArchive, void* vpProgress)
/*static*/NuResult NufxArchive::ProgressUpdater(NuArchive* pArchive,
void* vpProgress)
{
// "oldName" ends up on top, "newName" on bottom.
const NuProgressData* pProgress = (const NuProgressData*) vpProgress;
NufxArchive* pThis;
MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd();
@ -608,14 +540,8 @@ NufxArchive::ProgressUpdater(NuArchive* pArchive, void* vpProgress)
return kNuOK;
}
/*
* 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)
GenericArchive::OpenResult NufxArchive::Open(const WCHAR* filename,
bool readOnly, CString* pErrMsg)
{
NuError nerr;
CString errMsg;
@ -669,14 +595,7 @@ bail:
return kResultSuccess;
}
/*
* 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)
CString NufxArchive::New(const WCHAR* filename, const void* options)
{
NuError nerr;
CString retmsg;
@ -710,11 +629,7 @@ bail:
return retmsg;
}
/*
* Set some standard callbacks and feature flags.
*/
NuError
NufxArchive::SetCallbacks(void)
NuError NufxArchive::SetCallbacks(void)
{
NuError nerr;
@ -745,13 +660,7 @@ bail:
return nerr;
}
/*
* User has updated their preferences. Take note.
*
* (This is also called the first time through.)
*/
void
NufxArchive::PreferencesChanged(void)
void NufxArchive::PreferencesChanged(void)
{
NuError nerr;
const Preferences* pPreferences = GET_PREFERENCES();
@ -774,11 +683,7 @@ NufxArchive::PreferencesChanged(void)
NuSetValue(fpArchive, kNuValueHandleBadMac, val);
}
/*
* Report on what NuFX is capable of.
*/
long
NufxArchive::GetCapability(Capability cap)
long NufxArchive::GetCapability(Capability cap)
{
switch (cap) {
case kCapCanTest:
@ -812,15 +717,12 @@ NufxArchive::GetCapability(Capability cap)
}
}
/*
* 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)
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;
NuError result;
@ -846,11 +748,7 @@ NufxArchive::LoadContents(void)
return result;
}
/*
* Reload the contents.
*/
CString
NufxArchive::Reload(void)
CString NufxArchive::Reload(void)
{
NuError nerr;
CString errMsg;
@ -871,12 +769,7 @@ NufxArchive::Reload(void)
return errMsg;
}
/*
* Reload the contents of the archive, showing an error message if the
* reload fails.
*/
NuError
NufxArchive::InternalReload(CWnd* pMsgWnd)
NuError NufxArchive::InternalReload(CWnd* pMsgWnd)
{
CString errMsg;
@ -890,11 +783,7 @@ NufxArchive::InternalReload(CWnd* pMsgWnd)
return kNuErrNone;
}
/*
* Static callback function. Used for scanning the contents of an archive.
*/
NuResult
NufxArchive::ContentFunc(NuArchive* pArchive, void* vpRecord)
NuResult NufxArchive::ContentFunc(NuArchive* pArchive, void* vpRecord)
{
const NuRecord* pRecord = (const NuRecord*) vpRecord;
NufxArchive* pThis;
@ -933,11 +822,7 @@ NufxArchive::ContentFunc(NuArchive* pArchive, void* vpRecord)
return kNuOK;
}
/*
* Convert a NuDateTime structure to a time_t.
*/
/*static*/ time_t
NufxArchive::DateTimeToSeconds(const NuDateTime* pDateTime)
/*static*/ time_t NufxArchive::DateTimeToSeconds(const NuDateTime* pDateTime)
{
if (pDateTime->second == 0 &&
pDateTime->minute == 0 &&
@ -983,12 +868,7 @@ NufxArchive::DateTimeToSeconds(const NuDateTime* pDateTime)
return (time_t) modTime.GetTime();
}
/*
* Callback from a DataSource that is done with a buffer. Use for memory
* allocated with new[].
*/
/*static*/ NuResult
NufxArchive::ArrayDeleteHandler(NuArchive* pArchive, void* ptr)
/*static*/ NuResult NufxArchive::ArrayDeleteHandler(NuArchive* pArchive, void* ptr)
{
delete[] ptr;
return kNuOK;
@ -1001,19 +881,14 @@ NufxArchive::ArrayDeleteHandler(NuArchive* pArchive, void* ptr)
* ===========================================================================
*/
/*
* 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,
bool NufxArchive::BulkAdd(ActionProgressDialog* pActionProgress,
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;
CString errMsg;
WCHAR curDir[MAX_PATH] = L"";
@ -1103,11 +978,7 @@ bail:
return retVal;
}
/*
* Add a single disk to the archive.
*/
bool
NufxArchive::AddDisk(ActionProgressDialog* pActionProgress,
bool NufxArchive::AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts)
{
NuError nerr;
@ -1279,13 +1150,7 @@ bail:
return retVal;
}
/*
* 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,
NuError NufxArchive::DoAddFile(const AddFilesDialog* pAddOpts,
FileDetails* pDetails)
{
NuError err;
@ -1337,11 +1202,7 @@ bail_quiet:
return err;
}
/*
* Prepare to add files.
*/
void
NufxArchive::AddPrep(CWnd* pMsgWnd, const AddFilesDialog* pAddOpts)
void NufxArchive::AddPrep(CWnd* pMsgWnd, const AddFilesDialog* pAddOpts)
{
NuError nerr;
const Preferences* pPreferences = GET_PREFERENCES();
@ -1375,13 +1236,7 @@ NufxArchive::AddPrep(CWnd* pMsgWnd, const AddFilesDialog* pAddOpts)
NuSetExtraData(fpArchive, this);
}
/*
* 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)
void NufxArchive::AddFinish(void)
{
NuSetErrorHandler(fpArchive, NULL);
NuSetValue(fpArchive, kNuValueHandleExisting, kNuMaybeOverwrite);
@ -1390,12 +1245,8 @@ NufxArchive::AddFinish(void)
//fBulkProgress = false;
}
/*
* Error handler callback for "bulk" adds.
*/
/*static*/ NuResult
NufxArchive::BulkAddErrorHandler(NuArchive* pArchive, void* vErrorStatus)
/*static*/ NuResult NufxArchive::BulkAddErrorHandler(NuArchive* pArchive,
void* vErrorStatus)
{
const NuErrorStatus* pErrorStatus = (const NuErrorStatus*)vErrorStatus;
NufxArchive* pThis;
@ -1437,12 +1288,7 @@ NufxArchive::BulkAddErrorHandler(NuArchive* pArchive, void* vErrorStatus)
return result;
}
/*
* Decide whether or not to replace an existing file (during extract)
* or record (during add).
*/
NuResult
NufxArchive::HandleReplaceExisting(const NuErrorStatus* pErrorStatus)
NuResult NufxArchive::HandleReplaceExisting(const NuErrorStatus* pErrorStatus)
{
NuResult result = kNuOK;
@ -1498,13 +1344,7 @@ bail:
return result;
}
/*
* A file that used to be there isn't anymore.
*
* This should be exceedingly rare.
*/
NuResult
NufxArchive::HandleAddNotFound(const NuErrorStatus* pErrorStatus)
NuResult NufxArchive::HandleAddNotFound(const NuErrorStatus* pErrorStatus)
{
CString errMsg;
@ -1522,11 +1362,7 @@ NufxArchive::HandleAddNotFound(const NuErrorStatus* pErrorStatus)
* ===========================================================================
*/
/*
* Test the records represented in the selection set.
*/
bool
NufxArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
bool NufxArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{
NuError nerr;
NufxEntry* pEntry;
@ -1579,11 +1415,7 @@ bail:
* ===========================================================================
*/
/*
* Delete the records represented in the selection set.
*/
bool
NufxArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
bool NufxArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{
NuError nerr;
NufxEntry* pEntry;
@ -1638,11 +1470,7 @@ bail:
* ===========================================================================
*/
/*
* Rename the records represented in the selection set.
*/
bool
NufxArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
bool NufxArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
{
CString errMsg;
NuError nerr;
@ -1733,16 +1561,7 @@ NufxArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
return retVal;
}
/*
* 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,
CString NufxArchive::TestPathName(const GenericEntry* pGenericEntry,
const CString& basePath, const CString& newName, char newFssep) const
{
CString errMsg;
@ -1796,24 +1615,21 @@ bail:
* ===========================================================================
*/
/*
* 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,
bool NufxArchive::RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
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
CString errMsg;
NuError nerr;
@ -1934,13 +1750,7 @@ bail:
return retVal;
}
/*
* Recompress one thread.
*
* Returns "true" if things went okay, "false" on a fatal failure.
*/
bool
NufxArchive::RecompressThread(NufxEntry* pEntry, int threadKind,
bool NufxArchive::RecompressThread(NufxEntry* pEntry, int threadKind,
const RecompressOptionsDialog* pRecompOpts, long* pSizeInMemory,
CString* pErrMsg)
{
@ -2032,18 +1842,16 @@ bail:
* ===========================================================================
*/
/*
* Transfer the selected files out of this archive and into another.
*
* 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)
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!");
XferStatus retval = kXferFailed;
unsigned char* dataBuf = NULL;
@ -2202,31 +2010,17 @@ bail:
return retval;
}
/*
* 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)
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");
(void) NuSetValue(fpArchive, kNuValueAllowDuplicates, true);
}
/*
* 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,
CString NufxArchive::XferFile(FileDetails* pDetails, unsigned char** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen)
{
NuError nerr;
@ -2360,15 +2154,12 @@ bail:
return errMsg;
}
/*
* 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)
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;
CString errMsg;
@ -2381,11 +2172,7 @@ NufxArchive::XferAbort(CWnd* pMsgWnd)
}
}
/*
* Flush all changes to the archive.
*/
void
NufxArchive::XferFinish(CWnd* pMsgWnd)
void NufxArchive::XferFinish(CWnd* pMsgWnd)
{
NuError nerr;
CString errMsg;
@ -2425,8 +2212,7 @@ bail:
*
* Returns "true" on success, "false" on failure.
*/
bool
NufxArchive::GetComment(CWnd* pMsgWnd, const GenericEntry* pGenericEntry,
bool NufxArchive::GetComment(CWnd* pMsgWnd, const GenericEntry* pGenericEntry,
CString* pStr)
{
NufxEntry* pEntry = (NufxEntry*) pGenericEntry;
@ -2472,24 +2258,21 @@ NufxArchive::GetComment(CWnd* pMsgWnd, const GenericEntry* pGenericEntry,
return true;
}
/*
* 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,
bool NufxArchive::SetComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
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;
NufxEntry* pEntry = (NufxEntry*) pGenericEntry;
NuError nerr;
@ -2578,13 +2361,7 @@ bail:
return retVal;
}
/*
* Remove a comment.
*
* Returns "true" on success, "false" on failure.
*/
bool
NufxArchive::DeleteComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry)
bool NufxArchive::DeleteComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry)
{
CString errMsg;
NuError nerr;
@ -2626,21 +2403,18 @@ bail:
}
/*
* 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,
bool NufxArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
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;
NufxEntry* pNufxEntry = (NufxEntry*) pEntry;
const NuRecord* pRecord;

View File

@ -25,14 +25,14 @@ public:
NuRecordIdx GetRecordIdx(void) const { return fRecordIdx; }
void SetRecordIdx(NuRecordIdx idx) { fRecordIdx = idx; }
// retrieve thread data
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,
ConvertHighASCII convHA, CString* pErrMsg) const;
virtual long GetSelectionSerial(void) const { return fRecordIdx; }
ConvertHighASCII convHA, CString* pErrMsg) const override;
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 ||
feature == kFeatureHasSimpleAccess)
return false;
@ -40,13 +40,26 @@ public:
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);
friend class NufxArchive;
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;
NuRecordIdx fRecordIdx; // unique record index
@ -69,48 +82,68 @@ public:
{}
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);
/*
* Finish instantiating a NufxArchive object by opening an existing file.
*/
virtual OpenResult Open(const WCHAR* filename, bool readOnly,
CString* pErrMsg);
virtual CString New(const WCHAR* filename, const void* options);
virtual CString Flush(void) { return ""; }
virtual CString Reload(void);
virtual bool IsReadOnly(void) const { return fIsReadOnly; };
virtual bool IsModified(void) const { return false; }
virtual void GetDescription(CString* pStr) const { *pStr = L"NuFX"; }
CString* pErrMsg) override;
/*
* Finish instantiating a NufxArchive 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;
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,
const AddFilesDialog* pAddOpts);
const AddFilesDialog* pAddOpts) override;
virtual bool AddDisk(ActionProgressDialog* pActionProgress,
const AddFilesDialog* pAddOpts);
const AddFilesDialog* pAddOpts) override;
virtual bool CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
const WCHAR* newName)
const WCHAR* newName) override
{ ASSERT(false); return false; }
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet);
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet);
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet);
virtual bool TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
virtual bool RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet) override;
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,
const WCHAR* newName)
const WCHAR* newName) override
{ ASSERT(false); return false; }
virtual CString TestVolumeName(const DiskFS* pDiskFS,
const WCHAR* newName) const
const WCHAR* newName) const override
{ ASSERT(false); return L"!"; }
virtual bool RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
const RecompressOptionsDialog* pRecompOpts);
const RecompressOptionsDialog* pRecompOpts) override;
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,
CString* pStr);
CString* pStr) override;
virtual bool SetComment(CWnd* pMsgWnd, GenericEntry* pEntry,
const CString& str);
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry);
const CString& str) override;
virtual bool DeleteComment(CWnd* pMsgWnd, GenericEntry* pEntry) override;
virtual bool SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
const FileProps* pProps);
virtual void PreferencesChanged(void);
virtual long GetCapability(Capability cap);
const FileProps* pProps) override;
virtual void PreferencesChanged(void) override;
virtual long GetCapability(Capability cap) override;
// try not to use this
NuArchive* GetNuArchivePointer(void) const { return fpArchive; }
@ -131,40 +164,80 @@ private:
}
return L"";
}
// recompress one thread
bool RecompressThread(NufxEntry* pEntry, int threadKind,
const RecompressOptionsDialog* pRecompOpts, long* pSizeInMemory,
CString* pErrMsg);
virtual void XferPrepare(const XferFileOptions* pXferOpts);
virtual CString XferFile(FileDetails* pDetails, unsigned char** pDataBuf,
long dataLen, unsigned char** pRsrcBuf, long rsrcLen);
virtual void XferAbort(CWnd* pMsgWnd);
virtual void XferFinish(CWnd* pMsgWnd);
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;
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 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);
/*
* Decide whether or not to replace an existing file (during extract)
* or record (during add).
*/
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);
/*
* Load the contents of an archive into the GenericEntry/NufxEntry list.
*/
NuError LoadContents(void);
/*
* Reload the contents of the archive, showing an error message if the
* reload fails.
*/
NuError InternalReload(CWnd* pMsgWnd);
/*
* Static callback function. Used for scanning the contents of an archive.
*/
static NuResult ContentFunc(NuArchive* pArchive, void* vpRecord);
/*
* Set some standard callbacks and feature flags.
*/
NuError SetCallbacks(void);
// handle progress update messages
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,
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);
NuArchive* fpArchive;

View File

@ -12,7 +12,6 @@
#include "Main.h"
#include "../diskimg/Win32Extra.h" // need disk geometry calls
#include "../diskimg/ASPI.h"
//#include "resource.h"
BEGIN_MESSAGE_MAP(OpenVolumeDialog, CDialog)
@ -24,12 +23,12 @@ BEGIN_MESSAGE_MAP(OpenVolumeDialog, CDialog)
END_MESSAGE_MAP()
/*
* Set up the list of drives.
*/
BOOL
OpenVolumeDialog::OnInitDialog(void)
BOOL OpenVolumeDialog::OnInitDialog(void)
{
/*
* Sets up the list of drives.
*/
CDialog::OnInitDialog(); // do any DDX init stuff
const Preferences* pPreferences = GET_PREFERENCES();
long defaultFilter;
@ -85,21 +84,13 @@ OpenVolumeDialog::OnInitDialog(void)
return TRUE;
}
/*
* Convert values.
*/
void
OpenVolumeDialog::DoDataExchange(CDataExchange* pDX)
void OpenVolumeDialog::DoDataExchange(CDataExchange* pDX)
{
DDX_Check(pDX, IDC_OPENVOL_READONLY, fReadOnly);
LOGI("DoDataExchange: fReadOnly==%d", fReadOnly);
}
/*
* Load the set of logical and physical drives.
*/
void
OpenVolumeDialog::LoadDriveList(void)
void OpenVolumeDialog::LoadDriveList(void)
{
CWaitCursor waitc;
CComboBox* pCombo;
@ -125,12 +116,7 @@ OpenVolumeDialog::LoadDriveList(void)
LoadLogicalDriveList(pListView, &itemIndex);
}
/*
* Determine the logical volumes available in the system and stuff them into
* the list.
*/
bool
OpenVolumeDialog::LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex)
bool OpenVolumeDialog::LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex)
{
DWORD drivesAvailable;
bool isWin9x = IsWin9x();
@ -286,18 +272,18 @@ OpenVolumeDialog::LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex)
return true;
}
/*
* 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)
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();
int itemIndex = *pItemIndex;
int i;
@ -408,16 +394,7 @@ OpenVolumeDialog::LoadPhysicalDriveList(CListCtrl* pListView, int* pItemIndex)
return true;
}
/*
* 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)
bool OpenVolumeDialog::HasPhysicalDriveWin9x(int unit, CString* pRemark)
{
HANDLE handle = NULL;
const int VWIN32_DIOC_DOS_INT13 = 4;
@ -484,14 +461,7 @@ OpenVolumeDialog::HasPhysicalDriveWin9x(int unit, CString* pRemark)
return true;
}
/*
* 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)
bool OpenVolumeDialog::HasPhysicalDriveWin2K(int unit, CString* pRemark)
{
HANDLE hDevice; // handle to the drive to be examined
DISK_GEOMETRY dg; // disk drive geometry structure
@ -584,12 +554,7 @@ OpenVolumeDialog::HasPhysicalDriveWin2K(int unit, CString* pRemark)
return true;
}
/*
* Something changed in the list. Update the "OK" button.
*/
void
OpenVolumeDialog::OnListChange(NMHDR*, LRESULT* pResult)
void OpenVolumeDialog::OnListChange(NMHDR*, LRESULT* pResult)
{
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_VOLUME_LIST);
CButton* pButton = (CButton*) GetDlgItem(IDOK);
@ -599,11 +564,7 @@ OpenVolumeDialog::OnListChange(NMHDR*, LRESULT* pResult)
*pResult = 0;
}
/*
* Double click.
*/
void
OpenVolumeDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
void OpenVolumeDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
{
CListCtrl* pListView = (CListCtrl*) GetDlgItem(IDC_VOLUME_LIST);
CButton* pButton = (CButton*) GetDlgItem(IDOK);
@ -616,11 +577,7 @@ OpenVolumeDialog::OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult)
*pResult = 0;
}
/*
* The volume filter drop-down box has changed.
*/
void
OpenVolumeDialog::OnVolumeFilterSelChange(void)
void OpenVolumeDialog::OnVolumeFilterSelChange(void)
{
CComboBox* pCombo = (CComboBox*) GetDlgItem(IDC_VOLUME_FILTER);
ASSERT(pCombo != NULL);
@ -628,11 +585,7 @@ OpenVolumeDialog::OnVolumeFilterSelChange(void)
LoadDriveList();
}
/*
* Verify their selection.
*/
void
OpenVolumeDialog::OnOK(void)
void OpenVolumeDialog::OnOK(void)
{
/*
* Figure out the (zero-based) drive letter.
@ -714,22 +667,12 @@ OpenVolumeDialog::OnOK(void)
}
}
/*
* User pressed the "Help" button.
*/
void
OpenVolumeDialog::OnHelp(void)
void OpenVolumeDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_OPEN_VOLUME, HELP_CONTEXT);
}
/*
* Set the state of the "read only" checkbox in the dialog.
*/
void
OpenVolumeDialog::ForceReadOnly(bool readOnly) const
void OpenVolumeDialog::ForceReadOnly(bool readOnly) const
{
CButton* pButton = (CButton*) GetDlgItem(IDC_OPENVOL_READONLY);
ASSERT(pButton != NULL);
@ -738,5 +681,5 @@ OpenVolumeDialog::ForceReadOnly(bool readOnly) const
pButton->SetCheck(BST_CHECKED);
else
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.
* See the file LICENSE for distribution terms.
*/
/*
* Class definition for Open Volume dialog.
*/
#ifndef APP_OPENVOLUMEDIALOG_H
#define APP_OPENVOLUMEDIALOG_H
@ -36,27 +33,66 @@ public:
bool fAllowROChange;
protected:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual void OnOK(void);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
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 OnListDblClick(NMHDR* pNotifyStruct, LRESULT* pResult);
/*
* The volume filter drop-down box has changed.
*/
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
// order also matters for range test in OnInitDialog
enum { kBoth=0, kLogical=1, kPhysical=2 };
// common constants
enum { kMaxLogicalDrives = 26, kMaxPhysicalDrives = 8 };
/*
* Load the set of logical and physical drives.
*/
void LoadDriveList(void);
/*
* Determine the logical volumes available in the system and stuff them into
* the list.
*/
bool LoadLogicalDriveList(CListCtrl* pListView, int* pItemIndex);
/*
* Add a list of physical drives to the list control.
*/
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);
/*
* 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);
/*
* Set the state of the "read only" checkbox in the dialog.
*/
void ForceReadOnly(bool readOnly) const;
struct {

View File

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

View File

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

View File

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

View File

@ -42,7 +42,14 @@ public:
}
~ColumnLayout(void) {}
/*
* Restore column widths.
*/
void LoadFromRegistry(const WCHAR* section);
/*
* Store column widths.
*/
void SaveToRegistry(const WCHAR* section);
int GetColumnWidth(int col) const {
@ -212,18 +219,26 @@ typedef enum {
*/
class Preferences {
public:
/*
* There should be only one Preferences object in the
* application, so this should only be run once.
*/
Preferences(void);
~Preferences(void) {
FreeStringValues();
}
// Load/save preferences from/to registry.
/*
* Load preferences from the registry.
*/
int LoadFromRegistry(void);
/*
* Save preferences to the registry.
*/
int SaveToRegistry(void);
ColumnLayout* GetColumnLayout(void) { return &fColumnLayout; }
//bool GetShowToolbarText(void) const { return fShowToolbarText; }
//void SetShowToolbarText(bool val) { fShowToolbarText = val; }
bool GetPrefBool(PrefNum num) const;
void SetPrefBool(PrefNum num, bool val);
@ -234,10 +249,33 @@ public:
private:
/*
* Get a default value for the temp path.
*/
void InitTempPath(void);
/*
* Set default values for the various folders.
*/
void InitFolders(void);
/*
* Get the path to the "My Documents" folder.
*/
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);
/*
* Free storage for any string entries.
*/
void FreeStringValues(void);
/*
@ -251,6 +289,11 @@ private:
const WCHAR* registryKey;
} PrefMap;
static const PrefMap fPrefMaps[kPrefNumLastEntry];
/*
* Do a quick scan of the PrefMaps to identify duplicate, misplaced, and
* missing entries.
*/
void ScanPrefMaps(void);
// this holds the actual values

View File

@ -3,9 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* See the file LICENSE for distribution terms.
*/
/*
* Implementation classes for the preferences property sheet
*/
#include "stdafx.h"
#include "PrefsDialog.h"
#include "ChooseDirDialog.h"
@ -39,33 +36,29 @@ BEGIN_MESSAGE_MAP(PrefsGeneralPage, CPropertyPage)
END_MESSAGE_MAP()
/*
* If they clicked on a checkbox, just mark the page as dirty so the "apply"
* button will be enabled.
*/
void
PrefsGeneralPage::OnChange(void)
void PrefsGeneralPage::OnChange(void)
{
/*
* They clicked on a checkbox, just mark the page as dirty so the "apply"
* button will be enabled.
*/
SetModified(TRUE);
}
void
PrefsGeneralPage::OnChangeRange(UINT nID)
void PrefsGeneralPage::OnChangeRange(UINT nID)
{
SetModified(TRUE);
}
/*
* 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)
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;
@ -83,13 +76,7 @@ PrefsGeneralPage::OnDefaults(void)
SetModified(TRUE);
}
/*
* 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)
void PrefsGeneralPage::OnAssociations(void)
{
EditAssocDialog assocDlg;
@ -97,7 +84,11 @@ PrefsGeneralPage::OnAssociations(void)
fOurAssociations = NULL;
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;
fOurAssociations = assocDlg.fOurAssociations;
assocDlg.fOurAssociations = NULL;
@ -105,15 +96,13 @@ PrefsGeneralPage::OnAssociations(void)
}
}
/*
* 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)
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;
ASSERT(NELEM(fColumn) == 9);
@ -136,20 +125,13 @@ PrefsGeneralPage::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_PREF_SUCCESS_BEEP, fBeepOnSuccess);
}
/*
* Context help request (question mark button).
*/
LONG
PrefsGeneralPage::OnHelp(UINT wParam, LONG lParam)
LONG PrefsGeneralPage::OnHelp(UINT wParam, LONG lParam)
{
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
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);
return 0; // doesn't matter
@ -172,38 +154,26 @@ BEGIN_MESSAGE_MAP(PrefsDiskImagePage, CPropertyPage)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
END_MESSAGE_MAP()
/*
* Set up our spin button.
*/
BOOL
PrefsDiskImagePage::OnInitDialog(void)
BOOL PrefsDiskImagePage::OnInitDialog(void)
{
//LOGI("OnInit!");
return CPropertyPage::OnInitDialog();
}
/*
* Enable the "apply" button.
*/
void
PrefsDiskImagePage::OnChange(void)
void PrefsDiskImagePage::OnChange(void)
{
LOGI("OnChange");
SetModified(TRUE);
LOGD("OnChange");
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);
//}
/*
* Convert values.
*/
void
PrefsDiskImagePage::DoDataExchange(CDataExchange* pDX)
void PrefsDiskImagePage::DoDataExchange(CDataExchange* pDX)
{
fReady = true;
DDX_Check(pDX, IDC_PDISK_CONFIRM_FORMAT, fQueryImageFormat);
@ -213,20 +183,13 @@ PrefsDiskImagePage::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_PDISK_PRODOS_USESPARSE, fProDOSUseSparse);
}
/*
* Context help request (question mark button).
*/
LONG
PrefsDiskImagePage::OnHelp(UINT wParam, LONG lParam)
LONG PrefsDiskImagePage::OnHelp(UINT wParam, LONG lParam)
{
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
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);
return 0; // doesn't matter
@ -246,11 +209,7 @@ BEGIN_MESSAGE_MAP(PrefsCompressionPage, CPropertyPage)
END_MESSAGE_MAP()
/*
* Disable compression types not supported by the NufxLib DLL.
*/
BOOL
PrefsCompressionPage::OnInitDialog(void)
BOOL PrefsCompressionPage::OnInitDialog(void)
{
if (!NufxArchive::IsCompressionSupported(kNuThreadFormatHuffmanSQ)) {
DisableWnd(IDC_DEFC_SQUEEZE);
@ -293,11 +252,7 @@ PrefsCompressionPage::OnInitDialog(void)
return CPropertyPage::OnInitDialog();
}
/*
* Disable a window in our dialog.
*/
void
PrefsCompressionPage::DisableWnd(int id)
void PrefsCompressionPage::DisableWnd(int id)
{
CWnd* pWnd;
pWnd = GetDlgItem(id);
@ -308,43 +263,30 @@ PrefsCompressionPage::DisableWnd(int id)
pWnd->EnableWindow(FALSE);
}
/*
* Enable the "apply" button.
*/
void
PrefsCompressionPage::OnChangeRange(UINT nID)
void PrefsCompressionPage::OnChangeRange(UINT nID)
{
SetModified(TRUE);
SetModified(TRUE); // enable the "apply" button
}
/*
* Convert values.
*
* Compression types match the NuThreadFormat enum in NufxLib.h, starting
* with IDC_DEFC_UNCOMPRESSED.
*/
void
PrefsCompressionPage::DoDataExchange(CDataExchange* pDX)
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;
DDX_Radio(pDX, IDC_DEFC_UNCOMPRESSED, fCompressType);
}
/*
* Context help request (question mark button).
*/
LONG
PrefsCompressionPage::OnHelp(UINT wParam, LONG lParam)
LONG PrefsCompressionPage::OnHelp(UINT wParam, LONG lParam)
{
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
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);
return 0; // doesn't matter
@ -366,16 +308,11 @@ BEGIN_MESSAGE_MAP(PrefsFviewPage, CPropertyPage)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
END_MESSAGE_MAP()
/*
* Set up our spin button.
*/
BOOL
PrefsFviewPage::OnInitDialog(void)
BOOL PrefsFviewPage::OnInitDialog(void)
{
//LOGI("OnInit!");
CSpinButtonCtrl* pSpin;
//LOGI("Configuring spin");
LOGV("Configuring spin");
pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_PVIEW_SIZE_SPIN);
ASSERT(pSpin != NULL);
@ -385,33 +322,24 @@ PrefsFviewPage::OnInitDialog(void)
uda.nInc = 64;
pSpin->SetRange(1, 32767);
pSpin->SetAccel(1, &uda);
LOGI("OnInit done!");
LOGD("OnInit done!");
return CPropertyPage::OnInitDialog();
}
/*
* Enable the "apply" button.
*/
void
PrefsFviewPage::OnChange(void)
void PrefsFviewPage::OnChange(void)
{
LOGI("OnChange");
SetModified(TRUE);
LOGD("OnChange");
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);
}
/*
* Convert values.
*/
void
PrefsFviewPage::DoDataExchange(CDataExchange* pDX)
void PrefsFviewPage::DoDataExchange(CDataExchange* pDX)
{
fReady = true;
//DDX_Check(pDX, IDC_PVIEW_EOL_RAW, fEOLConvRaw);
@ -449,20 +377,13 @@ PrefsFviewPage::DoDataExchange(CDataExchange* pDX)
DDV_MinMaxUInt(pDX, fMaxViewFileSizeKB, 1, 32767);
}
/*
* Context help request (question mark button).
*/
LONG
PrefsFviewPage::OnHelp(UINT wParam, LONG lParam)
LONG PrefsFviewPage::OnHelp(UINT wParam, LONG lParam)
{
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
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);
return 0; // doesn't matter
@ -484,11 +405,7 @@ BEGIN_MESSAGE_MAP(PrefsFilesPage, CPropertyPage)
END_MESSAGE_MAP()
/*
* Set up the "choose folder" button.
*/
BOOL
PrefsFilesPage::OnInitDialog(void)
BOOL PrefsFilesPage::OnInitDialog(void)
{
fChooseFolderButton.ReplaceDlgCtrl(this, IDC_PREF_CHOOSE_TEMP_FOLDER);
fChooseFolderButton.SetBitmapID(IDB_CHOOSE_FOLDER);
@ -496,20 +413,12 @@ PrefsFilesPage::OnInitDialog(void)
return CPropertyPage::OnInitDialog();
}
/*
* Enable the "apply" button.
*/
void
PrefsFilesPage::OnChange(void)
void PrefsFilesPage::OnChange(void)
{
SetModified(TRUE);
SetModified(TRUE); // enable the "apply" button
}
/*
* Convert values.
*/
void
PrefsFilesPage::DoDataExchange(CDataExchange* pDX)
void PrefsFilesPage::DoDataExchange(CDataExchange* pDX)
{
fReady = true;
DDX_Text(pDX, IDC_PREF_TEMP_FOLDER, fTempPath);
@ -529,12 +438,12 @@ PrefsFilesPage::DoDataExchange(CDataExchange* pDX)
}
}
/*
* They want to choose the folder from a menu hierarchy. Show them a list.
*/
void
PrefsFilesPage::OnChooseFolder(void)
void PrefsFilesPage::OnChooseFolder(void)
{
/*
* They want to choose the folder from a menu hierarchy. Show them a list.
*/
ChooseDirDialog chooseDir(this);
CWnd* pEditWnd;
CString editPath;
@ -547,7 +456,7 @@ PrefsFilesPage::OnChooseFolder(void)
chooseDir.SetPathName(editPath);
if (chooseDir.DoModal() == IDOK) {
const WCHAR* ccp = chooseDir.GetPathName();
LOGI("New temp path chosen = '%ls'", ccp);
LOGD("New temp path chosen = '%ls'", ccp);
pEditWnd->SetWindowText(ccp);
@ -556,20 +465,13 @@ PrefsFilesPage::OnChooseFolder(void)
}
}
/*
* Context help request (question mark button).
*/
LONG
PrefsFilesPage::OnHelp(UINT wParam, LONG lParam)
LONG PrefsFilesPage::OnHelp(UINT wParam, LONG lParam)
{
WinHelp((DWORD) ((HELPINFO*) lParam)->iCtrlId, HELP_CONTEXTPOPUP);
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);
return 0; // doesn't matter
@ -589,9 +491,6 @@ BEGIN_MESSAGE_MAP(PrefsSheet, CPropertySheet)
ON_MESSAGE(WM_HELP, OnHelp)
END_MESSAGE_MAP()
/*
* Construct the preferences dialog from the individual pages.
*/
PrefsSheet::PrefsSheet(CWnd* pParentWnd) :
CPropertySheet(L"Preferences", pParentWnd)
{
@ -605,31 +504,15 @@ PrefsSheet::PrefsSheet(CWnd* pParentWnd) :
//m_psh.dwFlags |= PSH_HASHELP;
}
/*
* 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)
BOOL PrefsSheet::OnNcCreate(LPCREATESTRUCT cs)
{
//LOGI("PrefsSheet OnNcCreate");
LOGV("PrefsSheet OnNcCreate");
BOOL val = CPropertySheet::OnNcCreate(cs);
ModifyStyleEx(0, WS_EX_CONTEXTHELP);
return val;
}
/*
* 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)
void PrefsSheet::OnApplyNow(void)
{
BOOL result;
@ -666,7 +549,7 @@ PrefsSheet::OnApplyNow(void)
}
/* reset all to "unmodified" state */
LOGI("All 'applies' were successful");
LOGD("All 'applies' were successful");
((MainWindow*) AfxGetMainWnd())->ApplyNow(this);
fGeneralPage.SetModified(FALSE);
fGeneralPage.fDefaultsPushed = false;
@ -676,36 +559,17 @@ PrefsSheet::OnApplyNow(void)
fFilesPage.SetModified(FALSE);
}
/*
* 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)
void PrefsSheet::OnIDHelp(void)
{
LOGI("PrefsSheet OnIDHelp");
LOGD("PrefsSheet OnIDHelp");
SendMessage(WM_COMMANDHELP);
}
/*
* 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)
LONG PrefsSheet::OnHelp(UINT wParam, LONG lParam)
{
HELPINFO* lpHelpInfo = (HELPINFO*) lParam;
LOGI("PrefsSheet OnHelp");
LOGD("PrefsSheet OnHelp");
DWORD context = lpHelpInfo->iCtrlId;
WinHelp(context, HELP_CONTEXTPOPUP);

View File

@ -51,7 +51,7 @@ public:
bool* fOurAssociations;
protected:
virtual void DoDataExchange(CDataExchange* pDX);
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void);
afx_msg void OnChangeRange(UINT);
@ -87,8 +87,8 @@ public:
BOOL fProDOSUseSparse;
protected:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void);
//afx_msg void OnChangeRange(UINT);
@ -114,14 +114,21 @@ public:
int fCompressType; // radio button index
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 LONG OnHelp(UINT wParam, LONG lParam);
afx_msg LONG OnCommandHelp(UINT wParam, LONG lParam);
private:
/*
* Disable a window in our dialog.
*/
void DisableWnd(int id);
DECLARE_MESSAGE_MAP()
@ -173,8 +180,8 @@ public:
UINT fMaxViewFileSizeKB;
protected:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void);
afx_msg void OnChangeRange(UINT);
@ -201,8 +208,8 @@ public:
CString fExtViewerExts;
protected:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
afx_msg void OnChange(void);
afx_msg void OnChooseFolder(void);
@ -221,6 +228,9 @@ protected:
class PrefsSheet : public CPropertySheet
{
public:
/*
* Construct the preferences dialog from the individual pages.
*/
PrefsSheet(CWnd* pParentWnd = NULL);
PrefsGeneralPage fGeneralPage;
@ -230,11 +240,44 @@ public:
PrefsFilesPage fFilesPage;
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();
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()
};

View File

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

View File

@ -24,13 +24,21 @@ protected:
/* get basic goodies, based on the DC */
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);
// 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);
/*
* Returns the width of the string.
*/
int StringWidth(const CString& str);
static const WCHAR kCourierNew[];
@ -64,7 +72,13 @@ public:
/* set the DC and the parent window (for the cancel box) */
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 fromPage, int toPage);
/* this is used to set up the page range selection in print dialog */
@ -73,9 +87,26 @@ public:
}
private:
/*
* Compute the number of pages in fpContentList.
*/
void CalcNumPages(void);
/*
* Kick off the print job.
*/
int StartPrint(void);
/*
* Print all pages.
*
* Returns 0 on success, nonzero on failure.
*/
int DoPrint(void);
/*
* Print page N of the content list, where N is a 1-based count.
*/
void DoPrintPage(int page);
enum {
@ -110,20 +141,50 @@ public:
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);
/*
* Print all pages.
*/
int PrintAll(CRichEditCtrl* pREC, const WCHAR* title);
/*
* Print a range of pages.
*/
int PrintPages(CRichEditCtrl* pREC, const WCHAR* title, int startPage,
int endPage);
/*
* Print the selected area.
*/
int PrintSelection(CRichEditCtrl* pREC, const WCHAR* title, long startChar,
long endChar);
private:
/*
* Start the printing process by posting a print-cancel dialog.
*/
int StartPrint(CRichEditCtrl* pREC, const WCHAR* title,
int* pNumPages, bool doPrint);
/*
* Do some prep work before printing.
*/
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);
/*
* Send the contents of the rich edit control to the printer DC.
*/
int DoPrint(CRichEditCtrl* pREC, const WCHAR* title, int* pNumPages,
bool doPrint);

View File

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

View File

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

View File

@ -30,9 +30,15 @@ public:
int fCompressionType;
private:
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
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 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.
*/
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
@ -110,16 +110,7 @@ static const struct {
* ==========================================================================
*/
/*
* 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
void MyRegistry::OneTimeInstall(void) const
{
/* start by stomping on our appIDs */
LOGI(" Removing appIDs");
@ -149,17 +140,7 @@ MyRegistry::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
MyRegistry::OneTimeUninstall(void) const
void MyRegistry::OneTimeUninstall(void) const
{
/* drop any associations we hold */
int i;
@ -195,40 +176,29 @@ MyRegistry::OneTimeUninstall(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
const WCHAR* MyRegistry::GetAppRegistryKey(void) const
{
return kCompanyName;
}
/*
* See if an AppID is one we recognize.
*/
bool
MyRegistry::IsOurAppID(const WCHAR* id) const
bool MyRegistry::IsOurAppID(const WCHAR* id) const
{
return (wcsicmp(id, kAppIDNuFX) == 0 ||
wcsicmp(id, kAppIDDiskImage) == 0 ||
wcsicmp(id, kAppIDBinaryII) == 0);
}
/*
* 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
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();
ASSERT(exeName != NULL && wcslen(exeName) > 0);
@ -239,11 +209,7 @@ MyRegistry::FixBasicSettings(void) const
ConfigureAppID(kAppIDDiskImage, L"Disk Image (CiderPress)", exeName, 3);
}
/*
* Set up the registry goodies for one appID.
*/
void
MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
void MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
const WCHAR* exeName, int iconIdx) const
{
LOGI(" Configuring '%ls' for '%ls'", appID, exeName);
@ -296,12 +262,7 @@ MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
RegCloseKey(hAppKey);
}
/*
* 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,
void MyRegistry::ConfigureAppIDSubFields(HKEY hAppKey, const WCHAR* descr,
const WCHAR* exeName) const
{
HKEY hShellKey, hOpenKey, hCommandKey;
@ -362,60 +323,24 @@ MyRegistry::ConfigureAppIDSubFields(HKEY hAppKey, const WCHAR* descr,
}
/*
* Return the number of file type associations.
*/
int
MyRegistry::GetNumFileAssocs(void) const
int MyRegistry::GetNumFileAssocs(void) const
{
return NELEM(kFileTypeAssoc);
}
#if 0
/*
* 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,
void MyRegistry::GetFileAssoc(int idx, CString* pExt, CString* pHandler,
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));
long res;
@ -455,13 +380,7 @@ MyRegistry::GetFileAssoc(int idx, CString* pExt, CString* pHandler,
RegCloseKey(hExtKey);
}
/*
* 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
int MyRegistry::GetAssocAppName(const CString& appID, CString* pCmd) const
{
CString keyName;
WCHAR buf[260];
@ -507,11 +426,7 @@ MyRegistry::GetAssocAppName(const CString& appID, CString* pCmd) const
return result;
}
/*
* Reduce a compound string to just its first token.
*/
void
MyRegistry::ReduceToToken(CString* pStr) const
void MyRegistry::ReduceToToken(CString* pStr) const
{
WCHAR* argv[1];
int argc = 1;
@ -525,19 +440,19 @@ MyRegistry::ReduceToToken(CString* pStr) const
free(mangle);
}
/*
* 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
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;
bool weOwnIt;
int result = 0;
@ -564,15 +479,7 @@ MyRegistry::SetFileAssoc(int idx, bool wantIt) const
return 0;
}
/*
* 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
bool MyRegistry::GetAssocState(const WCHAR* ext) const
{
WCHAR buf[260];
HKEY hExtKey = NULL;
@ -596,15 +503,7 @@ MyRegistry::GetAssocState(const WCHAR* ext) const
return result;
}
/*
* 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
int MyRegistry::DisownExtension(const WCHAR* ext) const
{
ASSERT(ext != NULL);
ASSERT(ext[0] == '.');
@ -614,20 +513,14 @@ MyRegistry::DisownExtension(const WCHAR* ext) const
if (RegDeleteKeyNT(HKEY_CLASSES_ROOT, ext) == ERROR_SUCCESS) {
LOGI(" HKCR\\%ls subtree deleted", ext);
} else {
LOGI(" Failed deleting HKCR\\'%ls'", ext);
LOGW(" Failed deleting HKCR\\'%ls'", ext);
return -1;
}
return 0;
}
/*
* Take ownership of a file extension.
*
* Returns 0 on success, -1 on error.
*/
int
MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
int MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
{
ASSERT(ext != NULL);
ASSERT(ext[0] == '.');
@ -645,7 +538,7 @@ MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
} else if (res == ERROR_FILE_NOT_FOUND) {
LOGI(" No HKCR\\%ls subtree to delete", ext);
} else {
LOGI(" Failed deleting HKCR\\'%ls'", ext);
LOGW(" Failed deleting HKCR\\'%ls'", ext);
goto bail;
}
@ -660,7 +553,7 @@ MyRegistry::OwnExtension(const WCHAR* ext, const WCHAR* appID) const
LOGI(" Set '%ls' to '%ls'", ext, appID);
result = 0;
} 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;
}
}
@ -681,8 +574,7 @@ bail:
// Windows NT. This is by design.
//
#define MAX_KEY_LENGTH 256 // not in any header I can find ++ATM
DWORD
MyRegistry::RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const
DWORD MyRegistry::RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const
{
DWORD dwRtn, dwSubKeyLength;
LPTSTR pSubKey = NULL;

View File

@ -28,7 +28,25 @@ public:
kRegFailed, // error occurred during registration
} 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;
/*
* 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;
/*
@ -41,18 +59,34 @@ public:
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;
// Fix basic settings, e.g. HKCR AppID classes.
void FixBasicSettings(void) const;
/*
* Return the number of file type associations.
*/
int GetNumFileAssocs(void) const;
/*
* Return information on a file association.
*/
void GetFileAssoc(int idx, CString* pExt, CString* pHandler,
bool* pOurs) const;
/*
* Sets the state of a file association.
*/
int SetFileAssoc(int idx, bool wantIt) const;
static unsigned short ComputeStringCRC(const char* str);
//static uint16_t ComputeStringCRC(const char* str);
private:
typedef struct FileTypeAssoc {
@ -62,21 +96,65 @@ private:
static const FileTypeAssoc kFileTypeAssoc[];
/*
* See if an AppID is one we recognize.
*/
bool IsOurAppID(const WCHAR* id) const;
/*
* Set up the registry goodies for one appID.
*/
void ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
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,
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;
/*
* Reduce a compound string to just its first token.
*/
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;
/*
* Drop ownership of a file extension. We assume we own it.
*
* Returns 0 on success, -1 on error.
*/
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;
DWORD RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const;
/* key validation */
static unsigned short CalcCRC16(unsigned short seed,
const unsigned char* ptr, int count);
//static uint16_t CalcCRC16(uint16_t seed,
// const uint8_t* ptr, int count);
static char* StripStrings(const char* str1, const char* str2);
void ComputeKey(const char* chBuf, int salt, long* pKeyLo, long* pKeyHi);
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.
* See the file LICENSE for distribution terms.
*/
/*
* Support for RenameEntryDialog.
*/
#include "stdafx.h"
#include "RenameEntryDialog.h"
#include "HelpTopics.h"
@ -17,11 +14,7 @@ BEGIN_MESSAGE_MAP(RenameEntryDialog, CDialog)
END_MESSAGE_MAP()
/*
* Set up the control.
*/
BOOL
RenameEntryDialog::OnInitDialog(void)
BOOL RenameEntryDialog::OnInitDialog(void)
{
ASSERT(fBasePath.IsEmpty());
fOldFile = fOldName;
@ -62,15 +55,10 @@ RenameEntryDialog::OnInitDialog(void)
return FALSE; // we set the focus
}
/*
* Convert values.
*/
void
RenameEntryDialog::DoDataExchange(CDataExchange* pDX)
void RenameEntryDialog::DoDataExchange(CDataExchange* pDX)
{
CString msg, failed;
msg = "";
failed.LoadString(IDS_MB_APP_NAME);
/* fNewName must come last, or the focus will be set on the wrong field
@ -105,31 +93,22 @@ fail:
return;
}
/*
* 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)
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);
}
/*
* Context help request (question mark button).
*/
BOOL
RenameEntryDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
BOOL RenameEntryDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it
}
/*
* User pressed the "Help" button.
*/
void
RenameEntryDialog::OnHelp(void)
void RenameEntryDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_RENAME_ENTRY, HELP_CONTEXT);
}

View File

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

View File

@ -3,16 +3,6 @@
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
* 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 "RenameVolumeDialog.h"
#include "DiskFSTree.h"
@ -25,11 +15,7 @@ BEGIN_MESSAGE_MAP(RenameVolumeDialog, CDialog)
ON_WM_HELPINFO()
END_MESSAGE_MAP()
/*
* Set up the control.
*/
BOOL
RenameVolumeDialog::OnInitDialog(void)
BOOL RenameVolumeDialog::OnInitDialog(void)
{
/* do the DoDataExchange stuff */
CDialog::OnInitDialog();
@ -58,16 +44,11 @@ RenameVolumeDialog::OnInitDialog(void)
return FALSE; // we set the focus
}
/*
* Convert values.
*/
void
RenameVolumeDialog::DoDataExchange(CDataExchange* pDX)
void RenameVolumeDialog::DoDataExchange(CDataExchange* pDX)
{
CString msg, failed;
//DiskImgLib::DiskFS* pDiskFS = fpArchive->GetDiskFS();
msg = "";
failed.LoadString(IDS_MB_APP_NAME);
/* put fNewName last so it gets the focus after failure */
@ -130,12 +111,7 @@ fail:
return;
}
/*
* 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)
void RenameVolumeDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
{
CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_RENAMEVOL_TREE);
HTREEITEM selected;
@ -160,21 +136,13 @@ RenameVolumeDialog::OnSelChanged(NMHDR* pnmh, LRESULT* pResult)
*pResult = 0;
}
/*
* Context help request (question mark button).
*/
BOOL
RenameVolumeDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
BOOL RenameVolumeDialog::OnHelpInfo(HELPINFO* lpHelpInfo)
{
WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
return TRUE; // yes, we handled it
}
/*
* User pressed Ye Olde Helppe Button.
*/
void
RenameVolumeDialog::OnHelp(void)
void RenameVolumeDialog::OnHelp(void)
{
WinHelp(HELP_TOPIC_RENAME_VOLUME, HELP_CONTEXT);
}

View File

@ -5,6 +5,13 @@
*/
/*
* 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
#define APP_RENAMEVOLUME_H
@ -32,11 +39,15 @@ public:
DiskImgLib::DiskFS* fpChosenDiskFS;
protected:
// overrides
virtual BOOL OnInitDialog(void);
virtual void DoDataExchange(CDataExchange* pDX);
virtual BOOL OnInitDialog(void) override;
virtual void DoDataExchange(CDataExchange* pDX) override;
/*
* 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 BOOL OnHelpInfo(HELPINFO* lpHelpInfo);
afx_msg void OnHelp(void);

View File

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

View File

@ -9,6 +9,11 @@
#ifndef 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,
bool fullSqHeader, int blockSize);

View File

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

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