2014-11-04 00:26:53 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2009 by CiderPress authors. All Rights Reserved.
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Bridge between DiskImg and GenericArchive.
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "DiskArchive.h"
|
|
|
|
#include "NufxArchive.h"
|
|
|
|
#include "Preferences.h"
|
|
|
|
#include "Main.h"
|
|
|
|
#include "ImageFormatDialog.h"
|
|
|
|
#include "RenameEntryDialog.h"
|
|
|
|
#include "ConfirmOverwriteDialog.h"
|
|
|
|
#include "../diskimg/DiskImgDetail.h"
|
2015-01-15 18:22:08 +00:00
|
|
|
#include "../reformat/Charset.h"
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
static const char kEmptyFolderMarker[] = ".$$EmptyFolder";
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskEntry
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int DiskEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
|
2014-11-04 00:26:53 +00:00
|
|
|
CString* pErrMsg) const
|
|
|
|
{
|
|
|
|
DIError dierr;
|
2014-11-18 05:13:13 +00:00
|
|
|
A2FileDescr* pOpenFile = NULL;
|
|
|
|
char* dataBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
bool rsrcFork;
|
|
|
|
bool needAlloc = true;
|
|
|
|
int result = -1;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpFile != NULL);
|
|
|
|
ASSERT(pErrMsg != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
*pErrMsg = "";
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (*ppText != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
needAlloc = false;
|
|
|
|
|
|
|
|
if (GetDamaged()) {
|
|
|
|
*pErrMsg = "File is damaged";
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (which == kDataThread)
|
|
|
|
rsrcFork = false;
|
|
|
|
else if (which == kRsrcThread)
|
|
|
|
rsrcFork = true;
|
|
|
|
else {
|
|
|
|
*pErrMsg = "No such fork";
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONGLONG len;
|
|
|
|
if (rsrcFork)
|
|
|
|
len = fpFile->GetRsrcLength();
|
|
|
|
else
|
|
|
|
len = fpFile->GetDataLength();
|
|
|
|
|
|
|
|
if (len == 0) {
|
|
|
|
if (needAlloc) {
|
|
|
|
*ppText = new char[1];
|
|
|
|
**ppText = '\0';
|
|
|
|
}
|
|
|
|
*pLength = 0;
|
|
|
|
result = IDOK;
|
|
|
|
goto bail;
|
|
|
|
} else if (len < 0) {
|
|
|
|
assert(rsrcFork); // forked files always have a data fork
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pErrMsg = L"That fork doesn't exist";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dierr = fpFile->Open(&pOpenFile, true, rsrcFork);
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pErrMsg = L"File open failed";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_PROGRESS_BEGIN();
|
2014-11-18 05:13:13 +00:00
|
|
|
pOpenFile->SetProgressUpdater(DiskArchive::ProgressCallback, len, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (needAlloc) {
|
|
|
|
dataBuf = new char[(int) len];
|
2014-11-18 05:13:13 +00:00
|
|
|
if (dataBuf == NULL) {
|
2014-11-19 22:54:24 +00:00
|
|
|
pErrMsg->Format(L"ERROR: allocation of %I64d bytes failed", len);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (*pLength < (long) len) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pErrMsg->Format(L"ERROR: buf size %ld too short (%ld)",
|
2014-11-04 00:26:53 +00:00
|
|
|
*pLength, (long) len);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
dataBuf = *ppText;
|
|
|
|
}
|
|
|
|
|
|
|
|
dierr = pOpenFile->Read(dataBuf, (size_t) len);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
if (dierr == kDIErrCancelled) {
|
|
|
|
result = IDCANCEL;
|
|
|
|
} else {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pErrMsg->Format(L"File read failed: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needAlloc)
|
|
|
|
*ppText = dataBuf;
|
|
|
|
*pLength = (long) len;
|
|
|
|
result = IDOK;
|
|
|
|
|
|
|
|
bail:
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pOpenFile != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
pOpenFile->Close();
|
|
|
|
if (result == IDOK) {
|
|
|
|
SET_PROGRESS_END();
|
|
|
|
ASSERT(pErrMsg->IsEmpty());
|
|
|
|
} else {
|
|
|
|
ASSERT(result == IDCANCEL || !pErrMsg->IsEmpty());
|
|
|
|
if (needAlloc) {
|
|
|
|
delete[] dataBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(*ppText == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int DiskEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
|
2014-11-04 00:26:53 +00:00
|
|
|
ConvertHighASCII convHA, CString* pErrMsg) const
|
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
A2FileDescr* pOpenFile = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
bool rsrcFork;
|
|
|
|
int result = -1;
|
|
|
|
|
|
|
|
ASSERT(IDOK != -1 && IDCANCEL != -1);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpFile != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (which == kDataThread)
|
|
|
|
rsrcFork = false;
|
|
|
|
else if (which == kRsrcThread)
|
|
|
|
rsrcFork = true;
|
|
|
|
else {
|
|
|
|
/* if we handle disk images, make sure we disable "conv" */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pErrMsg = L"No such fork";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONGLONG len;
|
|
|
|
if (rsrcFork)
|
|
|
|
len = fpFile->GetRsrcLength();
|
|
|
|
else
|
|
|
|
len = fpFile->GetDataLength();
|
|
|
|
|
|
|
|
if (len == 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Empty fork");
|
2014-11-04 00:26:53 +00:00
|
|
|
result = IDOK;
|
|
|
|
goto bail;
|
|
|
|
} else if (len < 0) {
|
|
|
|
assert(rsrcFork); // forked files always have a data fork
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pErrMsg = L"That fork doesn't exist";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
DIError dierr;
|
|
|
|
dierr = fpFile->Open(&pOpenFile, true, rsrcFork);
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pErrMsg = L"Unable to open file on disk image";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dierr = CopyData(pOpenFile, outfp, conv, convHA, pErrMsg);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
if (pErrMsg->IsEmpty()) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pErrMsg->Format(L"Failed while copying data: %hs\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = IDOK;
|
|
|
|
|
|
|
|
bail:
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pOpenFile != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
pOpenFile->Close();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
DIError DiskEntry::CopyData(A2FileDescr* pOpenFile, FILE* outfp, ConvertEOL conv,
|
2014-11-04 00:26:53 +00:00
|
|
|
ConvertHighASCII convHA, CString* pMsg) const
|
|
|
|
{
|
|
|
|
DIError dierr = kDIErrNone;
|
|
|
|
const int kChunkSize = 16384;
|
|
|
|
char buf[kChunkSize];
|
|
|
|
//bool firstChunk = true;
|
|
|
|
//EOLType sourceType;
|
|
|
|
bool lastCR = false;
|
|
|
|
LONGLONG srcLen, dataRem;
|
|
|
|
|
|
|
|
/* get the length of the open file */
|
|
|
|
dierr = pOpenFile->Seek(0, DiskImgLib::kSeekEnd);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
srcLen = pOpenFile->Tell();
|
|
|
|
dierr = pOpenFile->Rewind();
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
ASSERT(srcLen > 0); // empty files should've been caught earlier
|
|
|
|
|
|
|
|
SET_PROGRESS_BEGIN();
|
2014-11-18 05:13:13 +00:00
|
|
|
pOpenFile->SetProgressUpdater(DiskArchive::ProgressCallback, srcLen, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop until all data copied.
|
|
|
|
*/
|
|
|
|
dataRem = srcLen;
|
|
|
|
while (dataRem) {
|
|
|
|
int chunkLen;
|
|
|
|
|
|
|
|
if (dataRem > kChunkSize)
|
|
|
|
chunkLen = kChunkSize;
|
|
|
|
else
|
|
|
|
chunkLen = (int) dataRem;
|
|
|
|
|
|
|
|
/* read a chunk from the source file */
|
|
|
|
dierr = pOpenFile->Read(buf, chunkLen);
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pMsg->Format(L"File read failed: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write chunk to destination file */
|
|
|
|
int err = GenericEntry::WriteConvert(outfp, buf, chunkLen, &conv,
|
|
|
|
&convHA, &lastCR);
|
|
|
|
if (err != 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pMsg->Format(L"File write failed: %hs", strerror(err));
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = kDIErrGeneric;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataRem -= chunkLen;
|
|
|
|
//SET_PROGRESS_UPDATE(ComputePercent(srcLen - dataRem, srcLen));
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
pOpenFile->ClearProgressUpdater();
|
|
|
|
SET_PROGRESS_END();
|
|
|
|
return dierr;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskEntry::GetFeatureFlag(Feature feature) const
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
DiskImg::FSFormat format;
|
|
|
|
|
|
|
|
format = fpFile->GetDiskFS()->GetDiskImg()->GetFSFormat();
|
|
|
|
|
|
|
|
switch (feature) {
|
|
|
|
case kFeatureCanChangeType:
|
|
|
|
{
|
|
|
|
//if (GetRecordKind() == kRecordKindVolumeDir)
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatProDOS:
|
|
|
|
case DiskImg::kFormatPascal:
|
|
|
|
case DiskImg::kFormatMacHFS:
|
|
|
|
case DiskImg::kFormatDOS32:
|
|
|
|
case DiskImg::kFormatDOS33:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case kFeaturePascalTypes:
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatPascal:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case kFeatureDOSTypes:
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatDOS32:
|
|
|
|
case DiskImg::kFormatDOS33:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case kFeatureHFSTypes:
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatMacHFS:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case kFeatureHasFullAccess:
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatProDOS:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case kFeatureHasSimpleAccess:
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatDOS33:
|
|
|
|
case DiskImg::kFormatDOS32:
|
|
|
|
case DiskImg::kFormatCPM:
|
|
|
|
case DiskImg::kFormatMacHFS:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case kFeatureHasInvisibleFlag:
|
|
|
|
{
|
|
|
|
switch(format) {
|
|
|
|
case DiskImg::kFormatProDOS:
|
|
|
|
case DiskImg::kFormatMacHFS:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Unexpected feature flag %d", feature);
|
2014-11-04 00:26:53 +00:00
|
|
|
assert(false);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
assert(false);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ CString DiskArchive::AppInit(void)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
CString result("");
|
|
|
|
DIError dierr;
|
2015-01-04 19:29:51 +00:00
|
|
|
int32_t major, minor, bug;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Initializing DiskImg library");
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
// set this before initializing, so we can see init debug msgs
|
|
|
|
DiskImgLib::Global::SetDebugMsgHandler(DebugMsgHandler);
|
|
|
|
|
|
|
|
dierr = DiskImgLib::Global::AppInit();
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
result.Format(L"DiskImg DLL failed to initialize: %hs\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
DiskImgLib::Global::GetVersion(&major, &minor, &bug);
|
|
|
|
if (major != kDiskImgVersionMajor || minor < kDiskImgVersionMinor) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
result.Format(L"Older or incompatible version of DiskImg DLL found.\r\r"
|
|
|
|
L"Wanted v%d.%d.x, found %ld.%ld.%ld.",
|
2014-11-04 00:26:53 +00:00
|
|
|
kDiskImgVersionMajor, kDiskImgVersionMinor,
|
|
|
|
major, minor, bug);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ void DiskArchive::AppCleanup(void)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
DiskImgLib::Global::AppCleanup();
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ void DiskArchive::DebugMsgHandler(const char* file, int line,
|
|
|
|
const char* msg)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(file != NULL);
|
|
|
|
ASSERT(msg != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 01:54:34 +00:00
|
|
|
LOG_BASE(DebugLog::LOG_INFO, file, line, "<diskimg> %hs", msg);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ bool DiskArchive::ProgressCallback(DiskImgLib::A2FileDescr* pFile,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::di_off_t max, DiskImgLib::di_off_t current, void* state)
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
//::Sleep(10);
|
|
|
|
status = SET_PROGRESS_UPDATE(ComputePercent(current, max));
|
|
|
|
if (status == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("IDCANCEL returned from Main progress updater");
|
2014-11-04 00:26:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true; // tell DiskImgLib to continue what it's doing
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ bool DiskArchive::ScanProgressCallback(void* cookie, const char* str,
|
|
|
|
int count)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
CString fmt;
|
|
|
|
bool cont;
|
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
fmt = str;
|
|
|
|
else
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
fmt.Format(L"%hs (%%d)", str);
|
2014-11-04 00:26:53 +00:00
|
|
|
cont = SET_PROGRESS_COUNTER_2(fmt, count);
|
|
|
|
|
|
|
|
if (!cont) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("cancelled");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return cont;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
GenericArchive::OpenResult DiskArchive::Open(const WCHAR* filename,
|
|
|
|
bool readOnly, CString* pErrMsg)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
DIError dierr;
|
|
|
|
CString errMsg;
|
|
|
|
OpenResult result = kResultUnknown;
|
|
|
|
const Preferences* pPreferences = GET_PREFERENCES();
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpPrimaryDiskFS == NULL);
|
|
|
|
ASSERT(filename != NULL);
|
|
|
|
//ASSERT(ext != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pPreferences != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
fIsReadOnly = readOnly;
|
|
|
|
|
|
|
|
// special case for volume open
|
|
|
|
bool isVolume = false;
|
|
|
|
if (filename[0] >= 'A' && filename[0] <= 'Z' &&
|
|
|
|
filename[1] == ':' && filename[2] == '\\' &&
|
|
|
|
filename[3] == '\0')
|
|
|
|
{
|
|
|
|
isVolume = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open the image. This can be very slow for compressed images,
|
|
|
|
* especially 3.5" FDI images.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
CWaitCursor waitc;
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
// TODO(Unicode): modify DiskImg lib to accept wide paths
|
2014-11-23 18:34:57 +00:00
|
|
|
CStringA fileNameA(filename);
|
2015-01-05 05:04:01 +00:00
|
|
|
if (!PathName::TestNarrowConversion(filename, fileNameA, &errMsg)) {
|
|
|
|
result = kResultFailure;
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-23 18:34:57 +00:00
|
|
|
dierr = fDiskImg.OpenImage(fileNameA, PathProposal::kLocalFssep,
|
|
|
|
readOnly);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (dierr == kDIErrAccessDenied && !readOnly && !isVolume) {
|
|
|
|
// retry file open with read-only set
|
|
|
|
// don't do that for volumes -- assume they know what they want
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD(" Retrying open with read-only set");
|
2014-11-04 00:26:53 +00:00
|
|
|
fIsReadOnly = readOnly = true;
|
2014-11-23 18:34:57 +00:00
|
|
|
dierr = fDiskImg.OpenImage(fileNameA, PathProposal::kLocalFssep,
|
|
|
|
readOnly);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
if (dierr != kDIErrNone) {
|
2015-01-05 05:04:01 +00:00
|
|
|
if (dierr == kDIErrFileArchive) {
|
2014-11-04 00:26:53 +00:00
|
|
|
result = kResultFileArchive;
|
2015-01-05 05:04:01 +00:00
|
|
|
} else {
|
2014-11-04 00:26:53 +00:00
|
|
|
result = kResultFailure;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to open '%ls': %hs.", filename,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dierr = fDiskImg.AnalyzeImage();
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
result = kResultFailure;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Analysis of '%ls' failed: %hs", filename,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* allow them to override sector order and filesystem, if requested */
|
|
|
|
if (pPreferences->GetPrefBool(kPrQueryImageFormat)) {
|
|
|
|
ImageFormatDialog imf;
|
|
|
|
|
|
|
|
imf.InitializeValues(&fDiskImg);
|
|
|
|
imf.fFileSource = filename;
|
|
|
|
imf.SetQueryDisplayFormat(false);
|
|
|
|
imf.SetAllowGenericFormats(false);
|
|
|
|
|
|
|
|
if (imf.DoModal() != IDOK) {
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD("User bailed on IMF dialog");
|
2014-11-04 00:26:53 +00:00
|
|
|
result = kResultCancel;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (imf.fSectorOrder != fDiskImg.GetSectorOrder() ||
|
|
|
|
imf.fFSFormat != fDiskImg.GetFSFormat())
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Initial values overridden, forcing img format");
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = fDiskImg.OverrideFormat(fDiskImg.GetPhysicalFormat(),
|
|
|
|
imf.fFSFormat, imf.fSectorOrder);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
result = kResultFailure;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to access disk image using selected"
|
|
|
|
L" parameters. Error: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fDiskImg.GetFSFormat() == DiskImg::kFormatUnknown ||
|
|
|
|
fDiskImg.GetSectorOrder() == DiskImg::kSectorOrderUnknown)
|
|
|
|
{
|
|
|
|
result = kResultFailure;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to identify filesystem on '%ls'", filename);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create an appropriate DiskFS object */
|
|
|
|
fpPrimaryDiskFS = fDiskImg.OpenAppropriateDiskFS();
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fpPrimaryDiskFS == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
/* unknown FS should've been caught above! */
|
|
|
|
ASSERT(false);
|
|
|
|
result = kResultFailure;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Format of '%ls' not recognized.", filename);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
fpPrimaryDiskFS->SetScanForSubVolumes(DiskFS::kScanSubEnabled);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Scan all files and on the disk image, and recursively descend into
|
|
|
|
* sub-volumes. Can be slow on physical volumes.
|
|
|
|
*
|
|
|
|
* This is really only useful for ProDOS and HFS disks. Nothing else
|
|
|
|
* can be large enough to really get slow, and nothing else is likely
|
|
|
|
* to show up in a large multi-partition image.
|
|
|
|
*
|
|
|
|
* THOUGHT: only show the dialog if the volume is over a certain size.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
MainWindow* pMain = GET_MAIN_WINDOW();
|
|
|
|
ProgressCounterDialog* pProgress;
|
|
|
|
|
|
|
|
pProgress = new ProgressCounterDialog;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pProgress->Create(L"Examining contents, please wait...", pMain);
|
|
|
|
pProgress->SetCounterFormat(L"Scanning...");
|
2014-11-04 00:26:53 +00:00
|
|
|
pProgress->CenterWindow();
|
|
|
|
//pMain->PeekAndPump(); // redraw
|
|
|
|
CWaitCursor waitc;
|
|
|
|
|
|
|
|
/* set up progress dialog and scan all files */
|
|
|
|
pMain->SetProgressCounterDialog(pProgress);
|
|
|
|
fDiskImg.SetScanProgressCallback(ScanProgressCallback, this);
|
|
|
|
|
|
|
|
dierr = fpPrimaryDiskFS->Initialize(&fDiskImg, DiskFS::kInitFull);
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
fDiskImg.SetScanProgressCallback(NULL, NULL);
|
|
|
|
pMain->SetProgressCounterDialog(NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
pProgress->DestroyWindow();
|
|
|
|
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
if (dierr == kDIErrCancelled) {
|
|
|
|
result = kResultCancel;
|
|
|
|
} else {
|
|
|
|
result = kResultFailure;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Error reading list of files from disk: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LoadContents() != 0) {
|
|
|
|
result = kResultFailure;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg = L"Failed while loading contents of disk image.";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Force read-only flag if underlying FS doesn't allow RW. We need to
|
|
|
|
* consider embedded filesystems, so we only set RO if none of the
|
|
|
|
* filesystems are writable.
|
|
|
|
*
|
|
|
|
* BUG: this only checks the first level. Should be fully recursive.
|
|
|
|
*/
|
|
|
|
if (!fpPrimaryDiskFS->GetReadWriteSupported()) {
|
|
|
|
const DiskFS::SubVolume* pSubVol;
|
|
|
|
|
|
|
|
fIsReadOnly = true;
|
2014-11-18 05:13:13 +00:00
|
|
|
pSubVol = fpPrimaryDiskFS->GetNextSubVolume(NULL);
|
|
|
|
while (pSubVol != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pSubVol->GetDiskFS()->GetReadWriteSupported()) {
|
|
|
|
fIsReadOnly = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSubVol = fpPrimaryDiskFS->GetNextSubVolume(pSubVol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* force read-only if the primary is damaged */
|
|
|
|
if (fpPrimaryDiskFS->GetFSDamaged())
|
|
|
|
fIsReadOnly = true;
|
|
|
|
/* force read-only if the DiskImg thinks a wrapper is damaged */
|
|
|
|
if (fpPrimaryDiskFS->GetDiskImg()->GetReadOnly())
|
|
|
|
fIsReadOnly = true;
|
|
|
|
|
|
|
|
// /* force read-only on .gz/.zip unless pref allows */
|
|
|
|
// if (fDiskImg.GetOuterFormat() != DiskImg::kOuterFormatNone) {
|
|
|
|
// if (pPreferences->GetPrefBool(kPrWriteZips) == 0)
|
|
|
|
// fIsReadOnly = true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
SetPathName(filename);
|
|
|
|
result = kResultSuccess;
|
|
|
|
|
|
|
|
/* set any preferences-based settings */
|
|
|
|
PreferencesChanged();
|
|
|
|
|
|
|
|
bail:
|
|
|
|
*pErrMsg = errMsg;
|
|
|
|
if (!errMsg.IsEmpty()) {
|
|
|
|
assert(result == kResultFailure);
|
|
|
|
delete fpPrimaryDiskFS;
|
2014-11-18 05:13:13 +00:00
|
|
|
fpPrimaryDiskFS = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
} else {
|
|
|
|
assert(result != kResultFailure);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString DiskArchive::New(const WCHAR* fileName, const void* vOptions)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
const Preferences* pPreferences = GET_PREFERENCES();
|
|
|
|
NewOptions* pOptions = (NewOptions*) vOptions;
|
|
|
|
CString volName;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CStringA volNameA, fileNameA;
|
2014-11-04 00:26:53 +00:00
|
|
|
long numBlocks = -1;
|
|
|
|
long numTracks = -1;
|
|
|
|
int numSectors;
|
|
|
|
CString retmsg;
|
|
|
|
DIError dierr;
|
|
|
|
bool allowLowerCase;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fileName != NULL);
|
|
|
|
ASSERT(pOptions != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
allowLowerCase = pPreferences->GetPrefBool(kPrProDOSAllowLower) != 0;
|
|
|
|
|
|
|
|
switch (pOptions->base.format) {
|
|
|
|
case DiskImg::kFormatUnknown:
|
|
|
|
numBlocks = pOptions->blank.numBlocks;
|
|
|
|
break;
|
|
|
|
case DiskImg::kFormatProDOS:
|
|
|
|
volName = pOptions->prodos.volName;
|
|
|
|
numBlocks = pOptions->prodos.numBlocks;
|
|
|
|
break;
|
|
|
|
case DiskImg::kFormatPascal:
|
|
|
|
volName = pOptions->pascalfs.volName;
|
|
|
|
numBlocks = pOptions->pascalfs.numBlocks;
|
|
|
|
break;
|
|
|
|
case DiskImg::kFormatMacHFS:
|
|
|
|
volName = pOptions->hfs.volName;
|
|
|
|
numBlocks = pOptions->hfs.numBlocks;
|
|
|
|
break;
|
|
|
|
case DiskImg::kFormatDOS32:
|
|
|
|
numTracks = pOptions->dos.numTracks;
|
|
|
|
numSectors = pOptions->dos.numSectors;
|
|
|
|
|
|
|
|
if (numTracks < DiskFSDOS33::kMinTracks ||
|
|
|
|
numTracks > DiskFSDOS33::kMaxTracks)
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg = L"Invalid DOS32 track count";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (numSectors != 13) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg = L"Invalid DOS32 sector count";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (pOptions->dos.allocDOSTracks)
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
volName = L"DOS";
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatDOS33:
|
|
|
|
numTracks = pOptions->dos.numTracks;
|
|
|
|
numSectors = pOptions->dos.numSectors;
|
|
|
|
|
|
|
|
if (numTracks < DiskFSDOS33::kMinTracks ||
|
|
|
|
numTracks > DiskFSDOS33::kMaxTracks)
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg = L"Invalid DOS33 track count";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (numSectors != 16 && numSectors != 32) { // no 13-sector (yet)
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg = L"Invalid DOS33 sector count";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (pOptions->dos.allocDOSTracks)
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
volName = L"DOS";
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg = L"Unsupported disk format";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DiskArchive: new '%ls' %ld %hs in '%ls'",
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCWSTR) volName, numBlocks,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImg::ToString(pOptions->base.format), fileName);
|
|
|
|
|
|
|
|
bool canSkipFormat;
|
|
|
|
if (IsWin9x())
|
|
|
|
canSkipFormat = false;
|
|
|
|
else
|
|
|
|
canSkipFormat = true;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create an image with the appropriate characteristics. We set
|
|
|
|
* "skipFormat" because we know this will be a brand-new file, and
|
|
|
|
* we're not currently creating nibble images.
|
|
|
|
*
|
|
|
|
* GLITCH: under Win98/ME, brand-new files contain the previous contents
|
|
|
|
* of the hard drive. We need to explicitly zero them out. We don't
|
|
|
|
* want to do it under Win2K/XP because it can be slow for larger
|
|
|
|
* volumes.
|
|
|
|
*/
|
2015-01-15 18:22:08 +00:00
|
|
|
fileNameA = fileName; // TODO(Unicode)
|
2014-11-04 00:26:53 +00:00
|
|
|
if (numBlocks > 0) {
|
2014-11-18 05:13:13 +00:00
|
|
|
dierr = fDiskImg.CreateImage(fileNameA, NULL,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImg::kOuterFormatNone,
|
|
|
|
DiskImg::kFileFormatUnadorned,
|
|
|
|
DiskImg::kPhysicalFormatSectors,
|
2014-11-18 05:13:13 +00:00
|
|
|
NULL,
|
2014-11-04 00:26:53 +00:00
|
|
|
pOptions->base.sectorOrder,
|
|
|
|
DiskImg::kFormatGenericProDOSOrd, // arg must be generic
|
|
|
|
numBlocks,
|
|
|
|
canSkipFormat);
|
|
|
|
} else {
|
|
|
|
ASSERT(numTracks > 0);
|
2014-11-18 05:13:13 +00:00
|
|
|
dierr = fDiskImg.CreateImage(fileNameA, NULL,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImg::kOuterFormatNone,
|
|
|
|
DiskImg::kFileFormatUnadorned,
|
|
|
|
DiskImg::kPhysicalFormatSectors,
|
2014-11-18 05:13:13 +00:00
|
|
|
NULL,
|
2014-11-04 00:26:53 +00:00
|
|
|
pOptions->base.sectorOrder,
|
|
|
|
DiskImg::kFormatGenericProDOSOrd, // arg must be generic
|
|
|
|
numTracks, numSectors,
|
|
|
|
canSkipFormat);
|
|
|
|
}
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg.Format(L"Unable to create disk image: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pOptions->base.format == DiskImg::kFormatUnknown)
|
|
|
|
goto skip_format;
|
|
|
|
|
|
|
|
if (pOptions->base.format == DiskImg::kFormatDOS33 ||
|
|
|
|
pOptions->base.format == DiskImg::kFormatDOS32)
|
|
|
|
fDiskImg.SetDOSVolumeNum(pOptions->dos.volumeNum);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we don't allow lower case in ProDOS filenames, don't allow them
|
|
|
|
* in volume names either. This works because we don't allow ' ' in
|
|
|
|
* volume names; otherwise we'd need to invoke a ProDOS-specific call
|
|
|
|
* to convert the ' ' to '.'. (Or we could just do it ourselves.)
|
|
|
|
*
|
|
|
|
* We can't ask the ProDOS DiskFS to force upper case for us because
|
|
|
|
* the ProDOS DiskFS object doesn't yet exist.
|
|
|
|
*/
|
|
|
|
if (pOptions->base.format == DiskImg::kFormatProDOS && !allowLowerCase)
|
|
|
|
volName.MakeUpper();
|
|
|
|
|
|
|
|
/* format it */
|
2015-01-15 18:22:08 +00:00
|
|
|
// TODO(Unicode): for HFS, we need to convert Unicode to MOR
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
volNameA = volName;
|
|
|
|
dierr = fDiskImg.FormatImage(pOptions->base.format, volNameA);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg.Format(L"Unable to format disk image: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
fpPrimaryDiskFS = fDiskImg.OpenAppropriateDiskFS(false);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fpPrimaryDiskFS == NULL) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg = L"Unable to create DiskFS.";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* prep it */
|
|
|
|
dierr = fpPrimaryDiskFS->Initialize(&fDiskImg, DiskFS::kInitFull);
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg.Format(L"Error reading list of files from disk: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is pretty meaningless, but do it to ensure we're initialized */
|
|
|
|
if (LoadContents() != 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
retmsg = L"Failed while loading contents of disk image.";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
skip_format:
|
|
|
|
SetPathName(fileName);
|
|
|
|
|
|
|
|
/* set any preferences-based settings */
|
|
|
|
PreferencesChanged();
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return retmsg;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString DiskArchive::Close(void)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fpPrimaryDiskFS != NULL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DiskArchive shutdown closing disk image");
|
2014-11-04 00:26:53 +00:00
|
|
|
delete fpPrimaryDiskFS;
|
2014-11-18 05:13:13 +00:00
|
|
|
fpPrimaryDiskFS = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DIError dierr;
|
|
|
|
dierr = fDiskImg.CloseImage();
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd();
|
|
|
|
CString msg, failed;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
msg.Format(L"Failed while closing disk image: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&failed, IDS_FAILED);
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGE("During close: %ls", (LPCWSTR) msg);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
pMainWin->MessageBox(msg, failed, MB_OK);
|
|
|
|
}
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return L"";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString DiskArchive::Flush(void)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
DIError dierr;
|
|
|
|
CWaitCursor waitc;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
assert(fpPrimaryDiskFS != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
dierr = fpPrimaryDiskFS->Flush(DiskImg::kFlushAll);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
CString errMsg;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Attempt to flush the current archive failed: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
return errMsg;
|
|
|
|
}
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return L"";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::IsModified(void) const
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
assert(fpPrimaryDiskFS != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
return fpPrimaryDiskFS->GetDiskImg()->GetDirtyFlag();
|
|
|
|
}
|
|
|
|
|
2015-01-13 23:54:10 +00:00
|
|
|
CString DiskArchive::GetDescription() const
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2015-01-13 23:54:10 +00:00
|
|
|
CString str = L"Disk Image";
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-13 23:54:10 +00:00
|
|
|
if (fpPrimaryDiskFS != NULL && fpPrimaryDiskFS->GetVolumeID() != NULL) {
|
2015-01-15 22:21:01 +00:00
|
|
|
CString volumeId(Charset::ConvertMORToUNI(fpPrimaryDiskFS->GetVolumeID()));
|
Volume name and font fixes
More volume name MOR conversions. I think I got them all.
This also switches the "archive info", "add files", and "extract
files" dialogs to use the System Font. We were using "MS Sans
Serif" before, which looks a bit ratty on Windows 7 because it
doesn't take advantage of ClearType. (Apparently the ClearType
version is "Microsoft Sans Serif", though when you set the "use
system font" boolean to true it changes the font name to "MS Shell
Dlg".) The old font also seems to be missing certain glyphs, e.g.
my HFS volume name had 'TM' in it, but that just showed up as a box
(which is why, in case you were wondering, these changes ended up
together).
The new font seems to work equally well on WinXP, so I may enable
it for all dialogs in a follow-up change. As far as I can tell it
has the same font metrics -- I haven't seen anything weird looking
in the dialogs I've updated so far.
Also, bumped the version to 4.0.0-b3.
2015-01-15 19:25:26 +00:00
|
|
|
str.Format(L"Disk Image - %ls", (LPCWSTR) volumeId);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
}
|
2015-01-13 23:54:10 +00:00
|
|
|
return str;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int DiskArchive::LoadContents(void)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DiskArchive LoadContents");
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpPrimaryDiskFS != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
MainWindow* pMain = GET_MAIN_WINDOW();
|
|
|
|
ExclusiveModelessDialog* pWaitDlg = new ExclusiveModelessDialog;
|
|
|
|
pWaitDlg->Create(IDD_LOADING, pMain);
|
|
|
|
pWaitDlg->CenterWindow();
|
|
|
|
pMain->PeekAndPump(); // redraw
|
|
|
|
CWaitCursor waitc;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
result = LoadDiskFSContents(fpPrimaryDiskFS, L"");
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
SET_PROGRESS_COUNTER(-1);
|
|
|
|
|
|
|
|
pWaitDlg->DestroyWindow();
|
|
|
|
//pMain->PeekAndPump(); // redraw
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString DiskArchive::Reload()
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
fReloadFlag = true; // tell everybody that cached data is invalid
|
|
|
|
|
|
|
|
(void) fpPrimaryDiskFS->Flush(DiskImg::kFlushFastOnly);
|
|
|
|
|
|
|
|
DeleteEntries(); // a GenericArchive operation
|
|
|
|
|
|
|
|
if (LoadContents() != 0)
|
|
|
|
return "Disk image reload failed.";
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int DiskArchive::InternalReload(CWnd* pMsgWnd)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
CString errMsg;
|
|
|
|
|
|
|
|
errMsg = Reload();
|
|
|
|
|
|
|
|
if (!errMsg.IsEmpty()) {
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int DiskArchive::LoadDiskFSContents(DiskFS* pDiskFS, const WCHAR* volName)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2015-01-09 01:41:53 +00:00
|
|
|
static const char* kBlankFileNameMOR = "<blank filename>";
|
2014-11-04 00:26:53 +00:00
|
|
|
A2File* pFile;
|
|
|
|
DiskEntry* pNewEntry;
|
|
|
|
DiskFS::SubVolume* pSubVol;
|
|
|
|
const Preferences* pPreferences = GET_PREFERENCES();
|
|
|
|
bool wantCoerceDOSFilenames = false;
|
|
|
|
CString ourSubVolName;
|
|
|
|
|
|
|
|
wantCoerceDOSFilenames = pPreferences->GetPrefBool(kPrCoerceDOSFilenames);
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Notes for disk image '%ls':", volName);
|
|
|
|
LOGI("%hs", pDiskFS->GetDiskImg()->GetNotes());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pDiskFS != NULL);
|
|
|
|
pFile = pDiskFS->GetNextFile(NULL);
|
|
|
|
while (pFile != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewEntry = new DiskEntry(pFile);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pNewEntry == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
|
|
|
|
2015-01-09 01:41:53 +00:00
|
|
|
CStringA path(pFile->GetPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
if (path.IsEmpty())
|
2015-01-09 01:41:53 +00:00
|
|
|
path = kBlankFileNameMOR;
|
2014-11-04 00:26:53 +00:00
|
|
|
if (DiskImg::UsesDOSFileStructure(pFile->GetFSFormat()) &&
|
|
|
|
wantCoerceDOSFilenames)
|
|
|
|
{
|
|
|
|
InjectLowercase(&path);
|
|
|
|
}
|
2015-01-09 01:41:53 +00:00
|
|
|
pNewEntry->SetPathNameMOR(path);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (volName[0] != '\0')
|
|
|
|
pNewEntry->SetSubVolName(volName);
|
|
|
|
pNewEntry->SetFssep(pFile->GetFssep());
|
|
|
|
pNewEntry->SetFileType(pFile->GetFileType());
|
|
|
|
pNewEntry->SetAuxType(pFile->GetAuxType());
|
|
|
|
pNewEntry->SetAccess(pFile->GetAccess());
|
|
|
|
if (pFile->GetCreateWhen() == 0)
|
|
|
|
pNewEntry->SetCreateWhen(kDateNone);
|
|
|
|
else
|
|
|
|
pNewEntry->SetCreateWhen(pFile->GetCreateWhen());
|
|
|
|
if (pFile->GetModWhen() == 0)
|
|
|
|
pNewEntry->SetModWhen(kDateNone);
|
|
|
|
else
|
|
|
|
pNewEntry->SetModWhen(pFile->GetModWhen());
|
|
|
|
pNewEntry->SetSourceFS(pFile->GetFSFormat());
|
|
|
|
pNewEntry->SetHasDataFork(true);
|
|
|
|
if (pFile->IsVolumeDirectory()) {
|
|
|
|
/* volume directory entry; only on ProDOS/HFS */
|
|
|
|
ASSERT(pFile->GetRsrcLength() < 0);
|
|
|
|
pNewEntry->SetRecordKind(GenericEntry::kRecordKindVolumeDir);
|
|
|
|
//pNewEntry->SetUncompressedLen(pFile->GetDataLength());
|
|
|
|
pNewEntry->SetDataForkLen(pFile->GetDataLength());
|
|
|
|
pNewEntry->SetCompressedLen(pFile->GetDataLength());
|
|
|
|
} else if (pFile->IsDirectory()) {
|
|
|
|
/* directory entry */
|
|
|
|
ASSERT(pFile->GetRsrcLength() < 0);
|
|
|
|
pNewEntry->SetRecordKind(GenericEntry::kRecordKindDirectory);
|
|
|
|
//pNewEntry->SetUncompressedLen(pFile->GetDataLength());
|
|
|
|
pNewEntry->SetDataForkLen(pFile->GetDataLength());
|
|
|
|
pNewEntry->SetCompressedLen(pFile->GetDataLength());
|
|
|
|
} else if (pFile->GetRsrcLength() >= 0) {
|
|
|
|
/* has resource fork */
|
|
|
|
pNewEntry->SetRecordKind(GenericEntry::kRecordKindForkedFile);
|
|
|
|
pNewEntry->SetDataForkLen(pFile->GetDataLength());
|
|
|
|
pNewEntry->SetRsrcForkLen(pFile->GetRsrcLength());
|
|
|
|
//pNewEntry->SetUncompressedLen(
|
|
|
|
// pFile->GetDataLength() + pFile->GetRsrcLength() );
|
|
|
|
pNewEntry->SetCompressedLen(
|
|
|
|
pFile->GetDataSparseLength() + pFile->GetRsrcSparseLength() );
|
|
|
|
pNewEntry->SetHasRsrcFork(true);
|
|
|
|
} else {
|
|
|
|
/* just data fork */
|
|
|
|
pNewEntry->SetRecordKind(GenericEntry::kRecordKindFile);
|
|
|
|
//pNewEntry->SetUncompressedLen(pFile->GetDataLength());
|
|
|
|
pNewEntry->SetDataForkLen(pFile->GetDataLength());
|
|
|
|
pNewEntry->SetCompressedLen(pFile->GetDataSparseLength());
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (pNewEntry->GetSourceFS()) {
|
|
|
|
case DiskImg::kFormatDOS33:
|
|
|
|
case DiskImg::kFormatDOS32:
|
|
|
|
case DiskImg::kFormatUNIDOS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"DOS");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
2015-01-10 02:36:05 +00:00
|
|
|
case DiskImg::kFormatGutenberg:
|
|
|
|
pNewEntry->SetFormatStr(L"Gutenb");
|
|
|
|
break;
|
2014-11-04 00:26:53 +00:00
|
|
|
case DiskImg::kFormatProDOS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"ProDOS");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatPascal:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"Pascal");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatCPM:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"CP/M");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatMSDOS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"MS-DOS");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatRDOS33:
|
|
|
|
case DiskImg::kFormatRDOS32:
|
|
|
|
case DiskImg::kFormatRDOS3:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"RDOS");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatMacHFS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"HFS");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"???");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pNewEntry->SetDamaged(pFile->GetQuality() == A2File::kQualityDamaged);
|
|
|
|
pNewEntry->SetSuspicious(pFile->GetQuality() == A2File::kQualitySuspicious);
|
|
|
|
|
|
|
|
AddEntry(pNewEntry);
|
|
|
|
|
|
|
|
/* this is not very useful -- all the heavy lifting was done earlier */
|
|
|
|
if ((GetNumEntries() % 100) == 0)
|
|
|
|
SET_PROGRESS_COUNTER(GetNumEntries());
|
|
|
|
|
|
|
|
pFile = pDiskFS->GetNextFile(pFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load all sub-volumes.
|
|
|
|
*
|
|
|
|
* We define the sub-volume name to use for the next layer down. We
|
|
|
|
* prepend an underscore to the unmodified name. So long as the volume
|
|
|
|
* name is a valid Windows path -- which should hold true for most disks,
|
|
|
|
* though possibly not for Pascal -- it can be extracted directly with
|
|
|
|
* its full path with no risk of conflict. (The extraction code relies
|
|
|
|
* on this, so don't put a ':' in the subvol name or Windows will choke.)
|
|
|
|
*/
|
2014-11-18 05:13:13 +00:00
|
|
|
pSubVol = pDiskFS->GetNextSubVolume(NULL);
|
|
|
|
while (pSubVol != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
CString concatSubVolName;
|
|
|
|
int ret;
|
|
|
|
|
2015-01-15 22:21:01 +00:00
|
|
|
const char* subVolNameMOR = pSubVol->GetDiskFS()->GetVolumeName();
|
|
|
|
if (subVolNameMOR == NULL) {
|
2015-01-15 18:22:08 +00:00
|
|
|
subVolNameMOR = "+++"; // call it *something*
|
|
|
|
}
|
|
|
|
CString subVolName(Charset::ConvertMORToUNI(subVolNameMOR));
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-15 18:22:08 +00:00
|
|
|
if (volName[0] == '\0') {
|
|
|
|
concatSubVolName.Format(L"_%ls", (LPCWSTR) subVolName);
|
|
|
|
} else {
|
|
|
|
concatSubVolName.Format(L"%ls_%ls", volName, (LPCWSTR) subVolName);
|
|
|
|
}
|
2014-11-04 00:26:53 +00:00
|
|
|
ret = LoadDiskFSContents(pSubVol->GetDiskFS(), concatSubVolName);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
pSubVol = pDiskFS->GetNextSubVolume(pSubVol);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void DiskArchive::PreferencesChanged(void)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
const Preferences* pPreferences = GET_PREFERENCES();
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fpPrimaryDiskFS != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
fpPrimaryDiskFS->SetParameter(DiskFS::kParmProDOS_AllowLowerCase,
|
|
|
|
pPreferences->GetPrefBool(kPrProDOSAllowLower) != 0);
|
|
|
|
fpPrimaryDiskFS->SetParameter(DiskFS::kParmProDOS_AllocSparse,
|
|
|
|
pPreferences->GetPrefBool(kPrProDOSUseSparse) != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
long DiskArchive::GetCapability(Capability cap)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
switch (cap) {
|
|
|
|
case kCapCanTest:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case kCapCanRenameFullPath:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case kCapCanRecompress:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case kCapCanEditComment:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case kCapCanAddDisk:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case kCapCanConvEOLOnAdd:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case kCapCanCreateSubdir:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case kCapCanRenameVolume:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT(false);
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive -- add files
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::BulkAdd(ActionProgressDialog* pActionProgress,
|
2014-11-04 00:26:53 +00:00
|
|
|
const AddFilesDialog* pAddOpts)
|
|
|
|
{
|
|
|
|
NuError nerr;
|
|
|
|
CString errMsg;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR curDir[MAX_PATH] = L"";
|
2014-11-04 00:26:53 +00:00
|
|
|
bool retVal = false;
|
|
|
|
|
2014-12-02 06:07:39 +00:00
|
|
|
LOGD("Opts: '%ls' typePres=%d", (LPCWSTR) pAddOpts->fStoragePrefix,
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pAddOpts->fTypePreservation);
|
2014-12-02 06:07:39 +00:00
|
|
|
LOGD(" sub=%d strip=%d ovwr=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
pAddOpts->fIncludeSubfolders, pAddOpts->fStripFolderNames,
|
|
|
|
pAddOpts->fOverwriteExisting);
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpAddDataHead == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* these reset on every new add */
|
|
|
|
fOverwriteExisting = false;
|
|
|
|
fOverwriteNoAsk = false;
|
|
|
|
|
|
|
|
/* we screen for clashes with existing files later; this just ensures
|
|
|
|
"batch uniqueness" */
|
|
|
|
fpPrimaryDiskFS->SetParameter(DiskFS::kParm_CreateUnique, true);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the current directory and change to the one from the file dialog.
|
|
|
|
*/
|
2014-12-04 00:10:03 +00:00
|
|
|
const CString& directory = pAddOpts->GetDirectory();
|
|
|
|
LOGI("Selected path = '%ls'", (LPCWSTR) directory);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (GetCurrentDirectory(NELEM(curDir), curDir) == 0) {
|
|
|
|
errMsg = L"Unable to get current directory.\n";
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pActionProgress, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-12-04 00:10:03 +00:00
|
|
|
if (SetCurrentDirectory(directory) == false) {
|
|
|
|
errMsg.Format(L"Unable to set current directory to '%ls'.\n",
|
|
|
|
(LPCWSTR) directory);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pActionProgress, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-12-04 00:10:03 +00:00
|
|
|
const CStringArray& fileNames = pAddOpts->GetFileNames();
|
|
|
|
for (int i = 0; i < fileNames.GetCount(); i++) {
|
|
|
|
const CString& name = fileNames.GetAt(i);
|
|
|
|
LOGI(" file '%ls'", (LPCWSTR) name);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* add the file, calling DoAddFile via the generic AddFile */
|
2014-12-04 00:10:03 +00:00
|
|
|
nerr = AddFile(pAddOpts, name, &errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (errMsg.IsEmpty())
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Failed while adding file '%ls': %hs.",
|
2014-12-04 00:10:03 +00:00
|
|
|
(LPCWSTR) name, NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrAborted) {
|
|
|
|
ShowFailureMsg(pActionProgress, errMsg, IDS_FAILED);
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fpAddDataHead == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
CString title;
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&title, IDS_MB_APP_NAME);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg = L"No files added.\n";
|
2014-11-04 00:26:53 +00:00
|
|
|
pActionProgress->MessageBox(errMsg, title, MB_OK | MB_ICONWARNING);
|
|
|
|
} else {
|
|
|
|
/* add all pending files */
|
|
|
|
retVal = true;
|
|
|
|
errMsg = ProcessFileAddData(pAddOpts->fpTargetDiskFS,
|
|
|
|
pAddOpts->fConvEOL);
|
|
|
|
if (!errMsg.IsEmpty()) {
|
|
|
|
CString title;
|
|
|
|
ShowFailureMsg(pActionProgress, errMsg, IDS_FAILED);
|
|
|
|
retVal = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* success or failure, reload the contents */
|
|
|
|
errMsg = Reload();
|
|
|
|
if (!errMsg.IsEmpty())
|
|
|
|
retVal = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
FreeAddDataList();
|
|
|
|
if (SetCurrentDirectory(curDir) == false) {
|
2014-12-04 00:10:03 +00:00
|
|
|
errMsg.Format(L"Unable to reset current directory to '%ls'.\n", curDir);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pActionProgress, errMsg, IDS_FAILED);
|
|
|
|
// bummer, but don't signal failure
|
|
|
|
}
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError DiskArchive::DoAddFile(const AddFilesDialog* pAddOpts,
|
2015-01-05 05:04:01 +00:00
|
|
|
LocalFileDetails* pDetails)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
2014-12-05 01:05:48 +00:00
|
|
|
* Any fields we want to keep from the FileDetails struct need to be
|
2014-11-21 21:18:20 +00:00
|
|
|
* copied out. It's a "hairy" struct, so we need to duplicate the strings.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nuerr = kNuErrNone;
|
|
|
|
DiskFS* pDiskFS = pAddOpts->fpTargetDiskFS;
|
|
|
|
|
|
|
|
DIError dierr;
|
|
|
|
int neededLen = 64; // reasonable guess
|
2014-11-18 05:13:13 +00:00
|
|
|
char* fsNormalBuf = NULL; // name as it will appear on disk image
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGI(" +++ ADD file: orig='%ls' strip='%ls'",
|
|
|
|
(LPCWSTR) pDetails->GetLocalPathName(),
|
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
retry:
|
|
|
|
/*
|
|
|
|
* Convert "storageName" to a filesystem-normalized path.
|
|
|
|
*/
|
|
|
|
delete[] fsNormalBuf;
|
|
|
|
fsNormalBuf = new char[neededLen];
|
2015-01-05 05:04:01 +00:00
|
|
|
dierr = pDiskFS->NormalizePath(pDetails->GetStoragePathNameMOR(),
|
2014-11-04 00:26:53 +00:00
|
|
|
PathProposal::kDefaultStoredFssep, fsNormalBuf, &neededLen);
|
|
|
|
if (dierr == kDIErrDataOverrun) {
|
|
|
|
/* not long enough, try again *once* */
|
|
|
|
delete[] fsNormalBuf;
|
|
|
|
fsNormalBuf = new char[neededLen];
|
2015-01-05 05:04:01 +00:00
|
|
|
dierr = pDiskFS->NormalizePath(pDetails->GetStoragePathNameMOR(),
|
2014-11-04 00:26:53 +00:00
|
|
|
PathProposal::kDefaultStoredFssep, fsNormalBuf, &neededLen);
|
|
|
|
}
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
nuerr = kNuErrInternal;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test to see if the file already exists. If it does, give the user
|
|
|
|
* the opportunity to rename it, overwrite the original, or skip
|
|
|
|
* adding it.
|
|
|
|
*
|
|
|
|
* The FS-normalized path may not reflect the actual storage name,
|
|
|
|
* because some features (like ProDOS "allow lower case") aren't
|
|
|
|
* factored in until later. However, it should be close enough -- it
|
|
|
|
* has to be, or we'd be in trouble for saying it's going to overwrite
|
|
|
|
* the file in the archive.
|
|
|
|
*/
|
|
|
|
A2File* pExisting;
|
|
|
|
pExisting = pDiskFS->GetFileByName(fsNormalBuf);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pExisting != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
NuResult result;
|
|
|
|
|
|
|
|
result = HandleReplaceExisting(pExisting, pDetails);
|
|
|
|
if (result == kNuAbort) {
|
|
|
|
nuerr = kNuErrAborted;
|
|
|
|
goto bail;
|
|
|
|
} else if (result == kNuSkip) {
|
|
|
|
nuerr = kNuErrSkipped;
|
|
|
|
goto bail;
|
|
|
|
} else if (result == kNuRename) {
|
|
|
|
goto retry;
|
|
|
|
} else if (result == kNuOverwrite) {
|
|
|
|
/* delete the existing file immediately */
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD(" Deleting existing file '%hs'", fsNormalBuf);
|
2014-11-04 00:26:53 +00:00
|
|
|
dierr = pDiskFS->DeleteFile(pExisting);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
// Would be nice to show a dialog and explain *why*, but
|
|
|
|
// I'm not sure we have a window here.
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGE(" Deletion failed (err=%d)", dierr);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGE("GLITCH: bad return %d from HandleReplaceExisting",result);
|
2014-11-04 00:26:53 +00:00
|
|
|
assert(false);
|
|
|
|
nuerr = kNuErrInternal;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Put all the goodies into a new FileAddData object, and add it to
|
|
|
|
* the end of the list.
|
|
|
|
*/
|
|
|
|
FileAddData* pAddData;
|
|
|
|
pAddData = new FileAddData(pDetails, fsNormalBuf);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pAddData == NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
nuerr = kNuErrMalloc;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD("FSNormalized is '%hs'", pAddData->GetFSNormalPath());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
AddToAddDataList(pAddData);
|
|
|
|
|
|
|
|
bail:
|
|
|
|
delete[] fsNormalBuf;
|
|
|
|
return nuerr;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuResult DiskArchive::HandleReplaceExisting(const A2File* pExisting,
|
2015-01-05 05:04:01 +00:00
|
|
|
LocalFileDetails* pDetails)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
NuResult result;
|
|
|
|
|
|
|
|
if (fOverwriteNoAsk) {
|
|
|
|
if (fOverwriteExisting)
|
|
|
|
return kNuOverwrite;
|
|
|
|
else
|
|
|
|
return kNuSkip;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConfirmOverwriteDialog confOvwr;
|
|
|
|
|
2015-01-15 23:33:12 +00:00
|
|
|
confOvwr.fExistingFile = Charset::ConvertMORToUNI(pExisting->GetPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
confOvwr.fExistingFileModWhen = pExisting->GetModWhen();
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
PathName srcPath(pDetails->GetLocalPathName());
|
|
|
|
confOvwr.fNewFileSource = pDetails->GetLocalPathName();
|
2014-11-04 00:26:53 +00:00
|
|
|
confOvwr.fNewFileModWhen = srcPath.GetModWhen();
|
|
|
|
|
|
|
|
if (confOvwr.DoModal() == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("User cancelled out of add-to-diskimg replace-existing");
|
2014-11-04 00:26:53 +00:00
|
|
|
return kNuAbort;
|
|
|
|
}
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
// TODO: if they rename one fork, we need to track that fact and
|
|
|
|
// carry it over to the other fork -- otherwise they can rename
|
|
|
|
// the data and resource forks into separate files.
|
2014-11-04 00:26:53 +00:00
|
|
|
if (confOvwr.fResultRename) {
|
|
|
|
/*
|
|
|
|
* Replace the name in FileDetails. They were asked to modify
|
|
|
|
* the already-normalized version of the filename. We will run
|
|
|
|
* it back through the FS-specific normalizer, which will handle
|
|
|
|
* any oddities they type in.
|
|
|
|
*
|
|
|
|
* We don't want to run it through PathProposal.LocalToArchive
|
|
|
|
* because that'll strip out ':' in the pathnames.
|
|
|
|
*
|
|
|
|
* Ideally the rename dialog would have a way to validate the
|
|
|
|
* full path and reject "OK" if it's not valid. Instead, we just
|
|
|
|
* allow the FS normalizer to force the filename to be valid.
|
|
|
|
*/
|
2015-01-05 05:04:01 +00:00
|
|
|
pDetails->SetStrippedLocalPathName(confOvwr.fExistingFile);
|
|
|
|
LOGI("Trying rename to '%ls'",
|
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
return kNuRename;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (confOvwr.fResultApplyToAll) {
|
|
|
|
fOverwriteNoAsk = true;
|
|
|
|
if (confOvwr.fResultOverwrite)
|
|
|
|
fOverwriteExisting = true;
|
|
|
|
else
|
|
|
|
fOverwriteExisting = false;
|
|
|
|
}
|
|
|
|
if (confOvwr.fResultOverwrite)
|
|
|
|
result = kNuOverwrite;
|
|
|
|
else
|
|
|
|
result = kNuSkip;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString DiskArchive::ProcessFileAddData(DiskFS* pDiskFS, int addOptsConvEOL)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
CString errMsg;
|
|
|
|
FileAddData* pData;
|
2014-11-18 05:13:13 +00:00
|
|
|
unsigned char* dataBuf = NULL;
|
|
|
|
unsigned char* rsrcBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
long dataLen, rsrcLen;
|
|
|
|
MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd();
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("--- ProcessFileAddData");
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* map the EOL conversion to something we can use */
|
|
|
|
GenericEntry::ConvertEOL convEOL;
|
|
|
|
|
|
|
|
switch (addOptsConvEOL) {
|
|
|
|
case AddFilesDialog::kConvEOLNone:
|
|
|
|
convEOL = GenericEntry::kConvertEOLOff;
|
|
|
|
break;
|
|
|
|
case AddFilesDialog::kConvEOLType:
|
|
|
|
// will be adjusted each time through the loop
|
|
|
|
convEOL = GenericEntry::kConvertEOLOff;
|
|
|
|
break;
|
|
|
|
case AddFilesDialog::kConvEOLAuto:
|
|
|
|
convEOL = GenericEntry::kConvertEOLAuto;
|
|
|
|
break;
|
|
|
|
case AddFilesDialog::kConvEOLAll:
|
|
|
|
convEOL = GenericEntry::kConvertEOLOn;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(false);
|
|
|
|
convEOL = GenericEntry::kConvertEOLOff;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pData = fpAddDataHead;
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pData != NULL) {
|
2015-01-05 05:04:01 +00:00
|
|
|
const LocalFileDetails* pDataDetails = NULL;
|
|
|
|
const LocalFileDetails* pRsrcDetails = NULL;
|
|
|
|
const LocalFileDetails* pDetails = pData->GetDetails();
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const char* typeStr = "????"; // for debug msg only
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
switch (pDetails->GetEntryKind()) {
|
|
|
|
case LocalFileDetails::kFileKindDataFork:
|
2014-11-04 00:26:53 +00:00
|
|
|
pDataDetails = pDetails;
|
|
|
|
typeStr = "data";
|
|
|
|
break;
|
2015-01-05 05:04:01 +00:00
|
|
|
case LocalFileDetails::kFileKindRsrcFork:
|
2014-11-04 00:26:53 +00:00
|
|
|
pRsrcDetails = pDetails;
|
|
|
|
typeStr = "rsrc";
|
|
|
|
break;
|
2015-01-05 05:04:01 +00:00
|
|
|
case LocalFileDetails::kFileKindDiskImage:
|
2014-11-04 00:26:53 +00:00
|
|
|
pDataDetails = pDetails;
|
|
|
|
typeStr = "disk";
|
|
|
|
break;
|
2015-01-05 05:04:01 +00:00
|
|
|
case LocalFileDetails::kFileKindBothForks:
|
|
|
|
case LocalFileDetails::kFileKindDirectory:
|
2014-11-04 00:26:53 +00:00
|
|
|
default:
|
|
|
|
assert(false);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return L"internal error";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pData->GetOtherFork() != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pDetails = pData->GetOtherFork()->GetDetails();
|
|
|
|
typeStr = "both";
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
switch (pDetails->GetEntryKind()) {
|
|
|
|
case LocalFileDetails::kFileKindDataFork:
|
2014-11-18 05:13:13 +00:00
|
|
|
assert(pDataDetails == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
pDataDetails = pDetails;
|
|
|
|
break;
|
2015-01-05 05:04:01 +00:00
|
|
|
case LocalFileDetails::kFileKindRsrcFork:
|
2014-11-18 05:13:13 +00:00
|
|
|
assert(pRsrcDetails == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
pRsrcDetails = pDetails;
|
|
|
|
break;
|
2015-01-05 05:04:01 +00:00
|
|
|
case LocalFileDetails::kFileKindDiskImage:
|
2014-11-04 00:26:53 +00:00
|
|
|
assert(false);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return L"(internal) add other disk error";
|
2015-01-05 05:04:01 +00:00
|
|
|
case LocalFileDetails::kFileKindBothForks:
|
|
|
|
case LocalFileDetails::kFileKindDirectory:
|
2014-11-04 00:26:53 +00:00
|
|
|
default:
|
|
|
|
assert(false);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return L"internal error";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Adding file '%ls' (%hs)",
|
2015-01-05 05:04:01 +00:00
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName(), typeStr);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pDataDetails != NULL || pRsrcDetails != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The current implementation of DiskImg/DiskFS requires writing each
|
|
|
|
* fork in one shot. This means loading the entire thing into
|
|
|
|
* memory. Not so bad for ProDOS, with its 16MB maximum file size,
|
|
|
|
* but it could be awkward for HFS (not to mention HFS Plus!).
|
|
|
|
*/
|
|
|
|
DiskFS::CreateParms parms;
|
2015-01-05 05:04:01 +00:00
|
|
|
/* use the FS-normalized path here */
|
|
|
|
/* (do we have to? do we want to?) */
|
|
|
|
parms.pathName = pData->GetFSNormalPath();
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pRsrcDetails != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
parms.storageType = kNuStorageExtended;
|
|
|
|
else
|
|
|
|
parms.storageType = kNuStorageSeedling;
|
2015-01-05 05:04:01 +00:00
|
|
|
/* copy the rest out of the LocalFileDetails */
|
|
|
|
parms.fssep = pDetails->GetFssep();
|
|
|
|
parms.fileType = pDetails->GetFileType();
|
|
|
|
parms.auxType = pDetails->GetExtraType();
|
|
|
|
parms.access = pDetails->GetAccess();
|
|
|
|
parms.createWhen = NufxArchive::DateTimeToSeconds(&pDetails->GetCreateWhen());
|
|
|
|
parms.modWhen = NufxArchive::DateTimeToSeconds(&pDetails->GetModWhen());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
dataLen = rsrcLen = -1;
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pDataDetails != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
/* figure out text conversion, including high ASCII for DOS */
|
|
|
|
/* (HA conversion only happens if text conversion happens) */
|
|
|
|
GenericEntry::ConvertHighASCII convHA;
|
|
|
|
if (addOptsConvEOL == AddFilesDialog::kConvEOLType) {
|
2015-01-05 05:04:01 +00:00
|
|
|
if (pDataDetails->GetFileType() == kFileTypeTXT ||
|
|
|
|
pDataDetails->GetFileType() == kFileTypeSRC)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Enabling text conversion by type");
|
2014-11-04 00:26:53 +00:00
|
|
|
convEOL = GenericEntry::kConvertEOLOn;
|
|
|
|
} else {
|
|
|
|
convEOL = GenericEntry::kConvertEOLOff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (DiskImg::UsesDOSFileStructure(pDiskFS->GetDiskImg()->GetFSFormat()))
|
|
|
|
convHA = GenericEntry::kConvertHAOn;
|
|
|
|
else
|
|
|
|
convHA = GenericEntry::kConvertHAOff;
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
errMsg = LoadFile(pDataDetails->GetLocalPathName(), &dataBuf, &dataLen,
|
2014-11-04 00:26:53 +00:00
|
|
|
convEOL, convHA);
|
|
|
|
if (!errMsg.IsEmpty())
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pRsrcDetails != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
/* no text conversion on resource forks */
|
2015-01-05 05:04:01 +00:00
|
|
|
errMsg = LoadFile(pRsrcDetails->GetLocalPathName(), &rsrcBuf, &rsrcLen,
|
2014-11-04 00:26:53 +00:00
|
|
|
GenericEntry::kConvertEOLOff, GenericEntry::kConvertHAOff);
|
|
|
|
if (!errMsg.IsEmpty())
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* really ought to do this separately for each thread */
|
|
|
|
SET_PROGRESS_BEGIN();
|
2015-01-15 23:33:12 +00:00
|
|
|
CString pathNameW(Charset::ConvertMORToUNI(parms.pathName));
|
2015-01-05 05:04:01 +00:00
|
|
|
SET_PROGRESS_UPDATE2(0, pDetails->GetLocalPathName(), pathNameW);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
DIError dierr;
|
|
|
|
dierr = AddForksToDisk(pDiskFS, &parms, dataBuf, dataLen,
|
|
|
|
rsrcBuf, rsrcLen);
|
|
|
|
SET_PROGRESS_END();
|
|
|
|
if (dierr != kDIErrNone) {
|
2015-01-15 23:33:12 +00:00
|
|
|
errMsg.Format(L"Unable to add '%ls' to image: %hs.",
|
|
|
|
(LPCWSTR) pathNameW, DiskImgLib::DIStrError(dierr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
delete[] dataBuf;
|
|
|
|
delete[] rsrcBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
dataBuf = rsrcBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
pData = pData->GetNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
delete[] dataBuf;
|
|
|
|
delete[] rsrcBuf;
|
|
|
|
return errMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
// 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,
|
2014-11-04 00:26:53 +00:00
|
|
|
GenericEntry::ConvertEOL conv, GenericEntry::ConvertHighASCII convHA) const
|
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
const char kCharLF = '\n';
|
|
|
|
const char kCharCR = '\r';
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
|
|
|
FILE* fp;
|
|
|
|
long fileLen;
|
|
|
|
|
|
|
|
ASSERT(convHA == GenericEntry::kConvertHAOn ||
|
|
|
|
convHA == GenericEntry::kConvertHAOff);
|
|
|
|
ASSERT(conv == GenericEntry::kConvertEOLOn ||
|
|
|
|
conv == GenericEntry::kConvertEOLOff ||
|
|
|
|
conv == GenericEntry::kConvertEOLAuto);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pathName != NULL);
|
|
|
|
ASSERT(pBuf != NULL);
|
|
|
|
ASSERT(pLen != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
fp = _wfopen(pathName, L"rb");
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fp == NULL) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to open '%ls': %hs.", pathName,
|
2014-11-04 00:26:53 +00:00
|
|
|
strerror(errno));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fseek(fp, 0, SEEK_END) != 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to seek to end of '%ls': %hs", pathName,
|
2014-11-04 00:26:53 +00:00
|
|
|
strerror(errno));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
fileLen = ftell(fp);
|
|
|
|
if (fileLen < 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to determine length of '%ls': %hs", pathName,
|
2014-11-04 00:26:53 +00:00
|
|
|
strerror(errno));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
rewind(fp);
|
|
|
|
|
|
|
|
if (fileLen == 0) { // handle zero-length files
|
2014-11-18 05:13:13 +00:00
|
|
|
*pBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
*pLen = 0;
|
|
|
|
goto bail;
|
|
|
|
} else if (fileLen > 0x00ffffff) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg = L"Cannot add files larger than 16MB to a disk image.";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-11-21 02:10:18 +00:00
|
|
|
*pBuf = new uint8_t[fileLen];
|
2014-11-18 05:13:13 +00:00
|
|
|
if (*pBuf == NULL) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to allocate %ld bytes for '%ls'.",
|
2014-11-04 00:26:53 +00:00
|
|
|
fileLen, pathName);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We're ready to load the file. We need to sort out EOL conversion.
|
|
|
|
* Since we always convert to CR, we know the file will stay the same
|
|
|
|
* size or get smaller, which means the buffer we've allocated is
|
|
|
|
* guaranteed to hold the file even if we convert it.
|
|
|
|
*
|
|
|
|
* If the text mode is "auto", we need to load a piece of the file and
|
|
|
|
* analyze it.
|
|
|
|
*/
|
|
|
|
if (conv == GenericEntry::kConvertEOLAuto) {
|
|
|
|
GenericEntry::EOLType eolType;
|
|
|
|
GenericEntry::ConvertHighASCII dummy;
|
|
|
|
|
|
|
|
int chunkLen = 16384; // nice big chunk
|
|
|
|
if (chunkLen > fileLen)
|
|
|
|
chunkLen = fileLen;
|
|
|
|
|
|
|
|
if (fread(*pBuf, chunkLen, 1, fp) != 1) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to read initial chunk of '%ls': %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
pathName, strerror(errno));
|
|
|
|
delete[] *pBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
*pBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
rewind(fp);
|
|
|
|
|
|
|
|
conv = GenericEntry::DetermineConversion(*pBuf, chunkLen,
|
|
|
|
&eolType, &dummy);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("LoadFile DetermineConv returned conv=%d eolType=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
conv, eolType);
|
|
|
|
if (conv == GenericEntry::kConvertEOLOn &&
|
|
|
|
eolType == GenericEntry::kEOLCR)
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" (skipping conversion due to matching eolType)");
|
2014-11-04 00:26:53 +00:00
|
|
|
conv = GenericEntry::kConvertEOLOff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ASSERT(conv != GenericEntry::kConvertEOLAuto);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The "high ASCII" conversion is either on or off. In this context,
|
|
|
|
* "on" means "convert all text files", and "off" means "don't convert
|
|
|
|
* text files". We never convert non-text files. Conversion should
|
|
|
|
* always be "on" for DOS 3.2/3.3, and "off" for everything else (except
|
|
|
|
* RDOS, should we choose to make that writeable).
|
|
|
|
*/
|
|
|
|
if (conv == GenericEntry::kConvertEOLOff) {
|
|
|
|
/* fast path */
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" +++ NOT converting text '%ls'", pathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (fread(*pBuf, fileLen, 1, fp) != 1) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to read '%ls': %hs.", pathName, strerror(errno));
|
2014-11-04 00:26:53 +00:00
|
|
|
delete[] *pBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
*pBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Convert as we go.
|
|
|
|
*
|
|
|
|
* Observation: if we copy a binary file to a DOS disk, and force
|
|
|
|
* the text conversion, we will convert 0x0a to 0x0d, and thence
|
|
|
|
* to 0x8d. However, we may still have some 0x8a bytes lying around,
|
|
|
|
* because we don't convert 0x8a in the original file to anything.
|
|
|
|
* This means that a CR->CRLF or LF->CRLF conversion can't be
|
|
|
|
* "undone" on a DOS disk. (Not that anyone cares.)
|
|
|
|
*/
|
|
|
|
long count = fileLen;
|
|
|
|
int mask, ic;
|
|
|
|
bool lastCR = false;
|
|
|
|
unsigned char* buf = *pBuf;
|
|
|
|
|
|
|
|
if (convHA == GenericEntry::kConvertHAOn)
|
|
|
|
mask = 0x80;
|
|
|
|
else
|
|
|
|
mask = 0x00;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" +++ Converting text '%ls', mask=0x%02x", pathName, mask);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
while (count--) {
|
|
|
|
ic = getc(fp);
|
|
|
|
|
|
|
|
if (ic == kCharCR) {
|
|
|
|
*buf++ = (unsigned char) (kCharCR | mask);
|
|
|
|
lastCR = true;
|
|
|
|
} else if (ic == kCharLF) {
|
|
|
|
if (!lastCR)
|
|
|
|
*buf++ = (unsigned char) (kCharCR | mask);
|
|
|
|
lastCR = false;
|
|
|
|
} else {
|
|
|
|
if (ic == '\0')
|
|
|
|
*buf++ = (unsigned char) ic; // don't conv 0x00
|
|
|
|
else
|
|
|
|
*buf++ = (unsigned char) (ic | mask);
|
|
|
|
lastCR = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fileLen = buf - *pBuf;
|
|
|
|
}
|
|
|
|
|
|
|
|
(void) fclose(fp);
|
|
|
|
|
|
|
|
*pLen = fileLen;
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return errMsg;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
DIError DiskArchive::AddForksToDisk(DiskFS* pDiskFS,
|
|
|
|
const DiskFS::CreateParms* pParms,
|
2014-11-04 00:26:53 +00:00
|
|
|
const unsigned char* dataBuf, long dataLen,
|
|
|
|
const unsigned char* rsrcBuf, long rsrcLen) const
|
|
|
|
{
|
|
|
|
DIError dierr = kDIErrNone;
|
|
|
|
const int kFileTypeBIN = 0x06;
|
|
|
|
const int kFileTypeINT = 0xfa;
|
|
|
|
const int kFileTypeBAS = 0xfc;
|
2014-11-18 05:13:13 +00:00
|
|
|
A2File* pNewFile = NULL;
|
|
|
|
A2FileDescr* pOpenFile = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskFS::CreateParms parmCopy;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make a temporary copy, pointers and all, so we can rewrite some of
|
|
|
|
* the fields. This is sort of bad, because we're making copies of a
|
|
|
|
* const char* filename pointer whose underlying storage we're not
|
|
|
|
* really familiar with. However, so long as we don't try to retain
|
|
|
|
* it after this function returns we should be fine.
|
|
|
|
*
|
|
|
|
* Might be better to make CreateParms a class instead of a struct,
|
|
|
|
* make the pathName field new[] storage, and write a copy constructor
|
|
|
|
* for the operation below. This will be fine for now.
|
|
|
|
*/
|
|
|
|
memcpy(&parmCopy, pParms, sizeof(parmCopy));
|
|
|
|
|
|
|
|
if (rsrcLen >= 0) {
|
|
|
|
ASSERT(parmCopy.storageType == kNuStorageExtended);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look for "empty directory holders" that we put into NuFX archives
|
|
|
|
* when doing disk-to-archive conversions. These make no sense if
|
|
|
|
* there's no fssep (because it's coming from DOS), or if there's no
|
|
|
|
* base path, so we can ignore those cases. We can also ignore it if
|
|
|
|
* the file is forked or is already a directory.
|
|
|
|
*/
|
|
|
|
if (parmCopy.fssep != '\0' && parmCopy.storageType == kNuStorageSeedling) {
|
|
|
|
const char* cp;
|
|
|
|
cp = strrchr(parmCopy.pathName, parmCopy.fssep);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (cp != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
if (strcmp(cp+1, kEmptyFolderMarker) == 0 && dataLen == 0) {
|
|
|
|
/* drop the junk on the end */
|
|
|
|
parmCopy.storageType = kNuStorageDirectory;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CStringA replacementFileName(parmCopy.pathName);;
|
2014-11-04 00:26:53 +00:00
|
|
|
replacementFileName =
|
|
|
|
replacementFileName.Left(cp - parmCopy.pathName -1);
|
|
|
|
parmCopy.pathName = replacementFileName;
|
|
|
|
parmCopy.fileType = 0x0f; // DIR
|
|
|
|
parmCopy.access &= ~(A2FileProDOS::kAccessInvisible);
|
|
|
|
dataLen = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is a subdir create request (from the clipboard or an "empty
|
|
|
|
* directory placeholder" in a NuFX archive), handle it here. If we're
|
|
|
|
* on a filesystem that doesn't have subdirectories, just skip it.
|
|
|
|
*/
|
|
|
|
if (parmCopy.storageType == kNuStorageDirectory) {
|
|
|
|
A2File* pDummyFile;
|
|
|
|
ASSERT(dataLen < 0 && rsrcLen < 0);
|
|
|
|
|
|
|
|
if (DiskImg::IsHierarchical(pDiskFS->GetDiskImg()->GetFSFormat())) {
|
|
|
|
dierr = pDiskFS->CreateFile(&parmCopy, &pDummyFile);
|
|
|
|
if (dierr == kDIErrDirectoryExists)
|
|
|
|
dierr = kDIErrNone; // dirs are not made unique
|
|
|
|
goto bail;
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Ignoring subdir create req on non-hierarchic FS");
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't try to put resource forks onto a DOS disk */
|
|
|
|
if (!DiskImg::HasResourceForks(pDiskFS->GetDiskImg()->GetFSFormat())) {
|
|
|
|
if (rsrcLen >= 0) {
|
|
|
|
rsrcLen = -1;
|
|
|
|
parmCopy.storageType = kNuStorageSeedling;
|
|
|
|
|
|
|
|
if (dataLen < 0) {
|
|
|
|
/* this was a resource-fork-only file */
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("--- nothing left to write for '%hs'",
|
2014-11-04 00:26:53 +00:00
|
|
|
parmCopy.pathName);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ASSERT(parmCopy.storageType == kNuStorageSeedling);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* quick kluge to get the right file type on large DOS files */
|
|
|
|
if (DiskImg::UsesDOSFileStructure(pDiskFS->GetDiskImg()->GetFSFormat()) &&
|
|
|
|
dataLen >= 65536)
|
|
|
|
{
|
|
|
|
if (parmCopy.fileType == kFileTypeBIN ||
|
|
|
|
parmCopy.fileType == kFileTypeINT ||
|
|
|
|
parmCopy.fileType == kFileTypeBAS)
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("+++ switching DOS file type to $f2");
|
2014-11-04 00:26:53 +00:00
|
|
|
parmCopy.fileType = 0xf2; // DOS 'S' file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the file on the disk. The storage type determines whether
|
|
|
|
* it has data+rsrc forks or just data (there's no such thing in
|
|
|
|
* ProDOS as "just a resource fork"). There's no need to open the
|
|
|
|
* fork if we're not going to write to it.
|
|
|
|
*
|
|
|
|
* This holds for resource forks as well, because the storage type
|
|
|
|
* determines whether or not the file is forked, and we've asserted
|
|
|
|
* that a file with a non-(-1) rsrcLen is forked.
|
|
|
|
*/
|
|
|
|
dierr = pDiskFS->CreateFile(&parmCopy, &pNewFile);
|
|
|
|
if (dierr != kDIErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" CreateFile failed: %hs", DiskImgLib::DIStrError(dierr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: if this was an empty directory holder, pNewFile will be set
|
2014-11-18 05:13:13 +00:00
|
|
|
* to NULL. We used to avoid handling this by just not opening the file
|
2014-11-04 00:26:53 +00:00
|
|
|
* if it had a length of zero. However, DOS 3.3 needs to write some
|
|
|
|
* kinds of zero-length files, because e.g. a zero-length 'B' file
|
|
|
|
* actually has 4 bytes of data in it.
|
|
|
|
*
|
2014-11-18 05:13:13 +00:00
|
|
|
* Of course, if dataLen is zero then dataBuf is NULL, so we need to
|
2014-11-04 00:26:53 +00:00
|
|
|
* supply a dummy write buffer. None of this is an issue for resource
|
|
|
|
* forks, because DOS 3.3 doesn't have those.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (dataLen > 0 ||
|
2014-11-18 05:13:13 +00:00
|
|
|
(dataLen == 0 && pNewFile != NULL))
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pNewFile != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
unsigned char dummyBuf[1] = { '\0' };
|
|
|
|
|
|
|
|
dierr = pNewFile->Open(&pOpenFile, false, false);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
pOpenFile->SetProgressUpdater(DiskArchive::ProgressCallback,
|
2014-11-18 05:13:13 +00:00
|
|
|
dataLen, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
dierr = pOpenFile->Write(dataBuf != NULL ? dataBuf : dummyBuf, dataLen);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
dierr = pOpenFile->Close();
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
2014-11-18 05:13:13 +00:00
|
|
|
pOpenFile = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rsrcLen > 0) {
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pNewFile != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
dierr = pNewFile->Open(&pOpenFile, false, true);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
pOpenFile->SetProgressUpdater(DiskArchive::ProgressCallback,
|
2014-11-18 05:13:13 +00:00
|
|
|
rsrcLen, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
dierr = pOpenFile->Write(rsrcBuf, rsrcLen);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
dierr = pOpenFile->Close();
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
goto bail;
|
2014-11-18 05:13:13 +00:00
|
|
|
pOpenFile = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pOpenFile != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
pOpenFile->Close();
|
2014-11-18 05:13:13 +00:00
|
|
|
if (dierr != kDIErrNone && pNewFile != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
/*
|
|
|
|
* Clean up the partially-written file. This does not, of course,
|
|
|
|
* erase any subdirectories that were created to contain this file.
|
|
|
|
* Not worth worrying about.
|
|
|
|
*/
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Deleting newly-created file '%hs'", parmCopy.pathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
(void) pDiskFS->DeleteFile(pNewFile);
|
|
|
|
}
|
|
|
|
return dierr;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void DiskArchive::AddToAddDataList(FileAddData* pData)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pData != NULL);
|
|
|
|
ASSERT(pData->GetNext() == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Run through the entire existing list, looking for a match. This is
|
|
|
|
* O(n^2) behavior, but I'm expecting N to be relatively small (under
|
|
|
|
* 1000 in almost all cases).
|
|
|
|
*/
|
|
|
|
FileAddData* pSearch = fpAddDataHead;
|
2015-01-05 05:04:01 +00:00
|
|
|
LocalFileDetails::FileKind dataKind, listKind;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
dataKind = pData->GetDetails()->GetEntryKind();
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pSearch != NULL) {
|
|
|
|
if (pSearch->GetOtherFork() == NULL &&
|
2015-01-05 05:04:01 +00:00
|
|
|
wcscmp(pSearch->GetDetails()->GetStrippedLocalPathName(),
|
|
|
|
pData->GetDetails()->GetStrippedLocalPathName()) == 0)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
//NuThreadID dataID = pData->GetDetails()->threadID;
|
|
|
|
//NuThreadID listID = pSearch->GetDetails()->threadID;
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
listKind = pSearch->GetDetails()->GetEntryKind();
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* got a name match */
|
|
|
|
if (dataKind != listKind &&
|
2015-01-05 05:04:01 +00:00
|
|
|
(dataKind == LocalFileDetails::kFileKindDataFork ||
|
|
|
|
dataKind == LocalFileDetails::kFileKindRsrcFork) &&
|
|
|
|
(listKind == LocalFileDetails::kFileKindDataFork ||
|
|
|
|
listKind == LocalFileDetails::kFileKindRsrcFork))
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
/* looks good, hook it in here instead of the list */
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGD("--- connecting forks of '%ls' and '%ls'",
|
2015-01-05 05:04:01 +00:00
|
|
|
(LPCWSTR) pData->GetDetails()->GetLocalPathName(),
|
|
|
|
(LPCWSTR) pSearch->GetDetails()->GetLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
pSearch->SetOtherFork(pData);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pSearch = pSearch->GetNext();
|
|
|
|
}
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fpAddDataHead == NULL) {
|
|
|
|
assert(fpAddDataTail == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
fpAddDataHead = fpAddDataTail = pData;
|
|
|
|
} else {
|
|
|
|
fpAddDataTail->SetNext(pData);
|
|
|
|
fpAddDataTail = pData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void DiskArchive::FreeAddDataList(void)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
FileAddData* pData;
|
|
|
|
FileAddData* pNext;
|
|
|
|
|
|
|
|
pData = fpAddDataHead;
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pData != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pNext = pData->GetNext();
|
|
|
|
delete pData->GetOtherFork();
|
|
|
|
delete pData;
|
|
|
|
pData = pNext;
|
|
|
|
}
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
fpAddDataHead = fpAddDataTail = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive -- create subdir
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::CreateSubdir(CWnd* pMsgWnd, GenericEntry* pParentEntry,
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* newName)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(newName != NULL && wcslen(newName) > 0);
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskEntry* pEntry = (DiskEntry*) pParentEntry;
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pEntry != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
A2File* pFile = pEntry->GetA2File();
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pFile != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskFS* pDiskFS = pFile->GetDiskFS();
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pDiskFS != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (!pFile->IsDirectory()) {
|
|
|
|
ASSERT(false);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
DIError dierr;
|
2014-11-18 05:13:13 +00:00
|
|
|
A2File* pNewFile = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskFS::CreateParms parms;
|
2015-01-15 23:33:12 +00:00
|
|
|
CStringA pathNameMOR;
|
2014-11-18 05:13:13 +00:00
|
|
|
time_t now = time(NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the full path.
|
|
|
|
*/
|
|
|
|
if (pFile->IsVolumeDirectory()) {
|
2015-01-15 23:33:12 +00:00
|
|
|
pathNameMOR = newName;
|
2014-11-04 00:26:53 +00:00
|
|
|
} else {
|
2015-01-15 23:33:12 +00:00
|
|
|
pathNameMOR = pParentEntry->GetPathNameMOR();
|
|
|
|
pathNameMOR += pParentEntry->GetFssep();
|
|
|
|
pathNameMOR += newName;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(wcschr(newName, pParentEntry->GetFssep()) == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* using NufxLib constants; they match with ProDOS */
|
|
|
|
memset(&parms, 0, sizeof(parms));
|
2015-01-15 23:33:12 +00:00
|
|
|
parms.pathName = pathNameMOR;
|
2014-11-04 00:26:53 +00:00
|
|
|
parms.fssep = pParentEntry->GetFssep();
|
|
|
|
parms.storageType = kNuStorageDirectory;
|
|
|
|
parms.fileType = 0x0f; // ProDOS DIR
|
|
|
|
parms.auxType = 0;
|
|
|
|
parms.access = kNuAccessUnlocked;
|
|
|
|
parms.createWhen = now;
|
|
|
|
parms.modWhen = now;
|
|
|
|
|
|
|
|
dierr = pDiskFS->CreateFile(&parms, &pNewFile);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
CString errMsg;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to create subdirectory: %hs.\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InternalReload(pMsgWnd) != 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive -- delete selection
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ int DiskArchive::CompareDisplayNamesDesc(const void* ventry1,
|
|
|
|
const void* ventry2)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
const DiskEntry* pEntry1 = *((const DiskEntry**) ventry1);
|
|
|
|
const DiskEntry* pEntry2 = *((const DiskEntry**) ventry2);
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return wcsicmp(pEntry2->GetDisplayName(), pEntry1->GetDisplayName());
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
|
|
|
SelectionEntry* pSelEntry;
|
|
|
|
DiskEntry* pEntry;
|
|
|
|
DIError dierr;
|
|
|
|
bool retVal = false;
|
|
|
|
|
|
|
|
SET_PROGRESS_BEGIN();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start by copying the DiskEntry pointers out of the selection set and
|
|
|
|
* into an array. The selection set was created such that there is one
|
|
|
|
* entry in the set for each file. (The file viewer likes to have one
|
|
|
|
* entry for each thread.)
|
|
|
|
*/
|
|
|
|
int numEntries = pSelSet->GetNumEntries();
|
|
|
|
ASSERT(numEntries > 0);
|
|
|
|
DiskEntry** entryArray = new DiskEntry*[numEntries];
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
pSelEntry = pSelSet->IterNext();
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pSelEntry != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry = (DiskEntry*) pSelEntry->GetEntry();
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pEntry != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
entryArray[idx++] = pEntry;
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Added 0x%08lx '%ls'", (long) entryArray[idx-1],
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCWSTR) entryArray[idx-1]->GetDisplayName());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
pSelEntry = pSelSet->IterNext();
|
|
|
|
}
|
|
|
|
ASSERT(idx == numEntries);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sort the file array by descending filename.
|
|
|
|
*/
|
|
|
|
::qsort(entryArray, numEntries, sizeof(DiskEntry*), CompareDisplayNamesDesc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Run through the sorted list, deleting each entry.
|
|
|
|
*/
|
|
|
|
for (idx = 0; idx < numEntries; idx++) {
|
|
|
|
A2File* pFile;
|
|
|
|
|
|
|
|
pEntry = entryArray[idx];
|
|
|
|
pFile = pEntry->GetA2File();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We shouldn't be here at all if the main volume were opened
|
|
|
|
* read-only. However, it's possible that the main is read-write
|
|
|
|
* and our sub-volumes are read-only (probably because we don't
|
|
|
|
* support write access to the filesystem).
|
|
|
|
*/
|
|
|
|
if (!pFile->GetDiskFS()->GetReadWriteSupported()) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to delete '%ls' on '%hs': operation not supported.",
|
|
|
|
(LPCWSTR) pEntry->GetDisplayName(),
|
|
|
|
(LPCSTR) pFile->GetDiskFS()->GetVolumeName());
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2015-01-09 01:41:53 +00:00
|
|
|
LOGI(" Deleting '%ls' from '%hs'", (LPCWSTR) pEntry->GetPathNameUNI(),
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCSTR) pFile->GetDiskFS()->GetVolumeName());
|
2015-01-09 01:41:53 +00:00
|
|
|
// TODO: should be using display name for progress updater?
|
|
|
|
SET_PROGRESS_UPDATE2(0, pEntry->GetPathNameUNI(), NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the DiskFS to delete the file. As soon as this completes,
|
|
|
|
* "pFile" is invalid and must not be dereferenced.
|
|
|
|
*/
|
|
|
|
dierr = pFile->GetDiskFS()->DeleteFile(pFile);
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to delete '%ls' on '%hs': %hs.",
|
|
|
|
(LPCWSTR) pEntry->GetDisplayName(),
|
|
|
|
(LPCSTR) pFile->GetDiskFS()->GetVolumeName(),
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
SET_PROGRESS_UPDATE(100);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Be paranoid and zap the pointer, on the off chance somebody
|
|
|
|
* tries to redraw the content list from the deleted data.
|
|
|
|
*
|
|
|
|
* In practice we don't work this way -- the stuff that gets drawn
|
|
|
|
* on the screen comes out of GenericEntry, not A2File. If this
|
|
|
|
* changes we'll need to raise the "reload" flag here, before the
|
|
|
|
* reload, to prevent the ContentList from chasing a bad pointer.
|
|
|
|
*/
|
2014-11-18 05:13:13 +00:00
|
|
|
pEntry->SetA2File(NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
retVal = true;
|
|
|
|
|
|
|
|
bail:
|
|
|
|
SET_PROGRESS_END();
|
|
|
|
delete[] entryArray;
|
|
|
|
if (InternalReload(pMsgWnd) != 0)
|
|
|
|
retVal = false;
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive -- rename files
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
|
|
|
bool retVal = false;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Renaming %d entries", pSelSet->GetNumEntries());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For each item in the selection set, bring up the "rename" dialog,
|
|
|
|
* and ask the GenericEntry to process it.
|
|
|
|
*
|
|
|
|
* If they hit "cancel" or there's an error, we still flush the
|
|
|
|
* previous changes. This is so that we don't have to create the
|
|
|
|
* same sort of deferred-write feature when renaming things in other
|
|
|
|
* sorts of archives (e.g. disk archives).
|
|
|
|
*/
|
|
|
|
SelectionEntry* pSelEntry = pSelSet->IterNext();
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pSelEntry != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
RenameEntryDialog renameDlg(pMsgWnd);
|
|
|
|
DiskEntry* pEntry = (DiskEntry*) pSelEntry->GetEntry();
|
|
|
|
|
2015-01-09 01:41:53 +00:00
|
|
|
LOGI(" Renaming '%ls'", (LPCWSTR) pEntry->GetPathNameUNI());
|
2014-11-04 00:26:53 +00:00
|
|
|
if (!SetRenameFields(pMsgWnd, pEntry, &renameDlg))
|
|
|
|
break;
|
|
|
|
|
|
|
|
int result;
|
|
|
|
if (pEntry->GetA2File()->IsVolumeDirectory())
|
|
|
|
result = IDIGNORE; // don't allow rename of volume dir
|
|
|
|
else
|
|
|
|
result = renameDlg.DoModal();
|
|
|
|
if (result == IDOK) {
|
|
|
|
DIError dierr;
|
|
|
|
DiskFS* pDiskFS;
|
|
|
|
A2File* pFile;
|
|
|
|
|
|
|
|
pFile = pEntry->GetA2File();
|
|
|
|
pDiskFS = pFile->GetDiskFS();
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CStringA newNameA(renameDlg.fNewName);
|
|
|
|
dierr = pDiskFS->RenameFile(pFile, newNameA);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to rename '%ls' to '%ls': %hs.",
|
2015-01-09 01:41:53 +00:00
|
|
|
(LPCWSTR) pEntry->GetPathNameUNI(),
|
|
|
|
(LPCWSTR) renameDlg.fNewName,
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD("Rename of '%ls' to '%ls' succeeded",
|
2015-01-09 01:41:53 +00:00
|
|
|
(LPCWSTR) pEntry->GetDisplayName(),
|
|
|
|
(LPCWSTR) renameDlg.fNewName);
|
2014-11-04 00:26:53 +00:00
|
|
|
} else if (result == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Canceling out of remaining renames");
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
/* 3rd possibility is IDIGNORE, i.e. skip this entry */
|
2015-01-09 01:41:53 +00:00
|
|
|
LOGI("Skipping rename of '%ls'", (LPCWSTR) pEntry->GetDisplayName());
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pSelEntry = pSelSet->IterNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reload GenericArchive from disk image */
|
|
|
|
if (InternalReload(pMsgWnd) == kNuErrNone)
|
|
|
|
retVal = true;
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::SetRenameFields(CWnd* pMsgWnd, DiskEntry* pEntry,
|
2014-11-04 00:26:53 +00:00
|
|
|
RenameEntryDialog* pDialog)
|
|
|
|
{
|
|
|
|
DiskFS* pDiskFS;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pEntry != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Figure out if we're allowed to change the entire path. (This is
|
|
|
|
* doing it the hard way, but what the hell.)
|
|
|
|
*/
|
|
|
|
long cap = GetCapability(GenericArchive::kCapCanRenameFullPath);
|
|
|
|
bool renameFullPath = (cap != 0);
|
|
|
|
|
|
|
|
// a bit round-about, but it works
|
|
|
|
pDiskFS = pEntry->GetA2File()->GetDiskFS();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure rename is allowed. It's nice to do these *before* putting
|
|
|
|
* up the rename dialog, so that the user doesn't do a bunch of typing
|
|
|
|
* before being told that it's pointless.
|
|
|
|
*/
|
|
|
|
if (!pDiskFS->GetReadWriteSupported()) {
|
|
|
|
CString errMsg;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to rename '%ls': operation not supported.",
|
2015-01-09 01:41:53 +00:00
|
|
|
(LPCWSTR) pEntry->GetPathNameUNI());
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (pDiskFS->GetFSDamaged()) {
|
|
|
|
CString errMsg;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to rename '%ls': the disk it's on appears to be damaged.",
|
2015-01-09 01:41:53 +00:00
|
|
|
(LPCWSTR) pEntry->GetPathNameUNI());
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDialog->SetCanRenameFullPath(renameFullPath);
|
2015-01-09 01:41:53 +00:00
|
|
|
pDialog->fOldName = pEntry->GetPathNameUNI();
|
2014-11-04 00:26:53 +00:00
|
|
|
pDialog->fFssep = pEntry->GetFssep();
|
|
|
|
pDialog->fpArchive = this;
|
|
|
|
pDialog->fpEntry = pEntry;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString DiskArchive::TestPathName(const GenericEntry* pGenericEntry,
|
2014-11-04 00:26:53 +00:00
|
|
|
const CString& basePath, const CString& newName, char newFssep) const
|
|
|
|
{
|
|
|
|
const DiskEntry* pEntry = (DiskEntry*) pGenericEntry;
|
|
|
|
DiskImg::FSFormat format;
|
2014-11-18 22:30:51 +00:00
|
|
|
CString errMsg, pathName;
|
|
|
|
CStringA newNameA;
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskFS* pDiskFS;
|
|
|
|
|
|
|
|
if (basePath.IsEmpty()) {
|
|
|
|
pathName = newName;
|
|
|
|
} else {
|
|
|
|
pathName = basePath;
|
|
|
|
pathName += newFssep;
|
|
|
|
pathName += newName;
|
|
|
|
}
|
|
|
|
|
|
|
|
pDiskFS = pEntry->GetA2File()->GetDiskFS();
|
|
|
|
format = pDiskFS->GetDiskImg()->GetFSFormat();
|
|
|
|
|
|
|
|
/* look for an existing file, but don't compare against self */
|
|
|
|
A2File* existingFile;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CStringA pathNameA(pathName);
|
|
|
|
existingFile = pDiskFS->GetFileByName(pathNameA);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (existingFile != NULL && existingFile != pEntry->GetA2File()) {
|
2014-11-18 22:30:51 +00:00
|
|
|
errMsg = L"A file with that name already exists.";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
newNameA = newName;
|
2014-11-04 00:26:53 +00:00
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatProDOS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSProDOS::IsValidFileName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_FILENAME_PRODOS);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatDOS33:
|
|
|
|
case DiskImg::kFormatDOS32:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSDOS33::IsValidFileName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_FILENAME_DOS);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatPascal:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSPascal::IsValidFileName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_FILENAME_PASCAL);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatMacHFS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSHFS::IsValidFileName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_FILENAME_HFS);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg = L"Not supported by TestPathName!";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bail:
|
|
|
|
return errMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive -- rename a volume
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::RenameVolume(CWnd* pMsgWnd, DiskFS* pDiskFS,
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* newName)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
DIError dierr;
|
|
|
|
CString errMsg;
|
|
|
|
bool retVal = true;
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CStringA newNameA(newName);
|
|
|
|
dierr = pDiskFS->RenameVolume(newNameA);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to rename volume: %hs.\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
retVal = false;
|
|
|
|
/* fall through to reload anyway */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reload GenericArchive from disk image */
|
|
|
|
if (InternalReload(pMsgWnd) != 0)
|
|
|
|
retVal = false;
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString DiskArchive::TestVolumeName(const DiskFS* pDiskFS,
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* newName) const
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
DiskImg::FSFormat format;
|
|
|
|
CString errMsg;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pDiskFS != NULL);
|
|
|
|
ASSERT(newName != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
format = pDiskFS->GetDiskImg()->GetFSFormat();
|
|
|
|
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CStringA newNameA(newName);
|
2014-11-04 00:26:53 +00:00
|
|
|
switch (format) {
|
|
|
|
case DiskImg::kFormatProDOS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSProDOS::IsValidVolumeName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_VOLNAME_PRODOS);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatDOS33:
|
|
|
|
case DiskImg::kFormatDOS32:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSDOS33::IsValidVolumeName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_VOLNAME_DOS);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatPascal:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSPascal::IsValidVolumeName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_VOLNAME_PASCAL);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
case DiskImg::kFormatMacHFS:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (!DiskFSHFS::IsValidVolumeName(newNameA))
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&errMsg, IDS_VALID_VOLNAME_HFS);
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
default:
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg = L"Not supported by TestVolumeName!";
|
2014-12-16 19:04:31 +00:00
|
|
|
break;
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return errMsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive -- set file properties
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool DiskArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
|
2014-11-04 00:26:53 +00:00
|
|
|
const FileProps* pProps)
|
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* Technically we should reload the GenericArchive from the disk image,
|
|
|
|
* but the set of changes is pretty small, so we just make them here.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
DIError dierr;
|
|
|
|
DiskEntry* pEntry = (DiskEntry*) pGenericEntry;
|
|
|
|
A2File* pFile = pEntry->GetA2File();
|
|
|
|
|
|
|
|
dierr = pFile->GetDiskFS()->SetFileInfo(pFile, pProps->fileType,
|
|
|
|
pProps->auxType, pProps->access);
|
|
|
|
if (dierr != kDIErrNone) {
|
|
|
|
CString errMsg;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to set file info: %hs.\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
DiskImgLib::DIStrError(dierr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do this in lieu of reloading GenericArchive */
|
|
|
|
pEntry->SetFileType(pFile->GetFileType());
|
|
|
|
pEntry->SetAuxType(pFile->GetAuxType());
|
|
|
|
pEntry->SetAccess(pFile->GetAccess());
|
|
|
|
|
|
|
|
/* DOS 3.2/3.3 may change these as well */
|
|
|
|
DiskImg::FSFormat fsFormat;
|
|
|
|
fsFormat = pFile->GetDiskFS()->GetDiskImg()->GetFSFormat();
|
|
|
|
if (fsFormat == DiskImg::kFormatDOS32 || fsFormat == DiskImg::kFormatDOS33) {
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD(" (reloading additional fields after DOS SFI)");
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->SetDataForkLen(pFile->GetDataLength());
|
|
|
|
pEntry->SetCompressedLen(pFile->GetDataSparseLength());
|
|
|
|
pEntry->SetSuspicious(pFile->GetQuality() == A2File::kQualitySuspicious);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear the dirty flag in trivial cases */
|
|
|
|
(void) fpPrimaryDiskFS->Flush(DiskImg::kFlushFastOnly);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
|
|
|
* DiskArchive -- transfer files to another archive
|
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
GenericArchive::XferStatus DiskArchive::XferSelection(CWnd* pMsgWnd,
|
|
|
|
SelectionSet* pSelSet, ActionProgressDialog* pActionProgress,
|
|
|
|
const XferFileOptions* pXferOpts)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DiskArchive XferSelection!");
|
2015-01-05 05:04:01 +00:00
|
|
|
uint8_t* dataBuf = NULL;
|
|
|
|
uint8_t* rsrcBuf = NULL;
|
|
|
|
LocalFileDetails fileDetails;
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg, extractErrMsg, cmpStr;
|
|
|
|
CString fixedPathName;
|
|
|
|
XferStatus retval = kXferFailed;
|
|
|
|
|
|
|
|
pXferOpts->fTarget->XferPrepare(pXferOpts);
|
|
|
|
|
|
|
|
SelectionEntry* pSelEntry = pSelSet->IterNext();
|
2014-11-18 05:13:13 +00:00
|
|
|
for ( ; pSelEntry != NULL; pSelEntry = pSelSet->IterNext()) {
|
2014-11-04 00:26:53 +00:00
|
|
|
long dataLen=-1, rsrcLen=-1;
|
|
|
|
DiskEntry* pEntry = (DiskEntry*) pSelEntry->GetEntry();
|
|
|
|
int typeOverride = -1;
|
|
|
|
int result;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(dataBuf == NULL);
|
|
|
|
ASSERT(rsrcBuf == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (pEntry->GetDamaged()) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" XFER skipping damaged entry '%ls'",
|
2015-01-09 01:41:53 +00:00
|
|
|
(LPCWSTR) pEntry->GetDisplayName());
|
2014-11-04 00:26:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do a quick de-colonizing pass for non-ProDOS volumes, then prepend
|
|
|
|
* the subvolume name (if any).
|
|
|
|
*/
|
2015-01-09 01:41:53 +00:00
|
|
|
fixedPathName = pEntry->GetPathNameUNI();
|
2014-11-04 00:26:53 +00:00
|
|
|
if (fixedPathName.IsEmpty())
|
2015-01-05 05:04:01 +00:00
|
|
|
fixedPathName = L"(no filename)";
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pEntry->GetFSFormat() != DiskImg::kFormatProDOS)
|
|
|
|
fixedPathName.Replace(PathProposal::kDefaultStoredFssep, '.');
|
2015-01-09 01:41:53 +00:00
|
|
|
if (!pEntry->GetSubVolName().IsEmpty()) {
|
|
|
|
CString tmpStr = pEntry->GetSubVolName();
|
|
|
|
tmpStr += (char) PathProposal::kDefaultStoredFssep;
|
2014-11-04 00:26:53 +00:00
|
|
|
tmpStr += fixedPathName;
|
|
|
|
fixedPathName = tmpStr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pEntry->GetRecordKind() == GenericEntry::kRecordKindVolumeDir) {
|
|
|
|
/* this is the volume dir */
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD(" XFER not transferring volume dir '%ls'",
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCWSTR) fixedPathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
continue;
|
|
|
|
} else if (pEntry->GetRecordKind() == GenericEntry::kRecordKindDirectory) {
|
|
|
|
if (pXferOpts->fPreserveEmptyFolders) {
|
|
|
|
/* if this is an empty directory, create a fake entry */
|
|
|
|
cmpStr = fixedPathName;
|
|
|
|
cmpStr += (char)PathProposal::kDefaultStoredFssep;
|
|
|
|
|
|
|
|
if (pSelSet->CountMatchingPrefix(cmpStr) == 0) {
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD("FOUND empty dir '%ls'", (LPCWSTR) fixedPathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
cmpStr += kEmptyFolderMarker;
|
|
|
|
dataBuf = new unsigned char[1];
|
|
|
|
dataLen = 0;
|
2015-01-05 05:04:01 +00:00
|
|
|
fileDetails.SetEntryKind(LocalFileDetails::kFileKindDataFork);
|
|
|
|
fileDetails.SetStrippedLocalPathName(cmpStr);
|
|
|
|
fileDetails.SetFileType(0); // NON
|
|
|
|
fileDetails.SetAccess(
|
|
|
|
pEntry->GetAccess() | GenericEntry::kAccessInvisible);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto have_stuff2;
|
|
|
|
} else {
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD("NOT empty dir '%ls'", (LPCWSTR) fixedPathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD(" XFER not transferring directory '%ls'",
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCWSTR) fixedPathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Xfer '%ls' (data=%d rsrc=%d)",
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
(LPCWSTR) fixedPathName, pEntry->GetHasDataFork(),
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetHasRsrcFork());
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
dataBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
dataLen = 0;
|
|
|
|
result = pEntry->ExtractThreadToBuffer(GenericEntry::kDataThread,
|
|
|
|
(char**) &dataBuf, &dataLen, &extractErrMsg);
|
|
|
|
if (result == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Cancelled during data extract!");
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail; /* abort anything that was pending */
|
|
|
|
} else if (result != IDOK) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Failed while extracting '%ls': %ls.",
|
2014-11-19 22:54:24 +00:00
|
|
|
(LPCWSTR) fixedPathName, (LPCWSTR) extractErrMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(dataBuf != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(dataLen >= 0);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (pXferOpts->fConvDOSText &&
|
|
|
|
DiskImg::UsesDOSFileStructure(pEntry->GetFSFormat()) &&
|
|
|
|
pEntry->GetFileType() == kFileTypeTXT)
|
|
|
|
{
|
|
|
|
/* don't need to convert EOL, so just strip in place */
|
|
|
|
long len;
|
|
|
|
unsigned char* ucp;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Converting DOS text in '%ls'", fixedPathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
for (ucp = dataBuf, len = dataLen; len > 0; len--, ucp++)
|
|
|
|
*ucp = *ucp & 0x7f;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if 0 // annoying to invoke PTX reformatter from here... ReformatHolder, etc.
|
|
|
|
if (pXferOpts->fConvPascalText &&
|
|
|
|
pEntry->GetFSFormat() == DiskImg::kFormatPascal &&
|
|
|
|
pEntry->GetFileType() == kFileTypePTX)
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("WOULD CONVERT ptx '%ls'", fixedPathName);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (pEntry->GetHasRsrcFork()) {
|
2014-11-18 05:13:13 +00:00
|
|
|
rsrcBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
rsrcLen = 0;
|
|
|
|
result = pEntry->ExtractThreadToBuffer(GenericEntry::kRsrcThread,
|
|
|
|
(char**) &rsrcBuf, &rsrcLen, &extractErrMsg);
|
|
|
|
if (result == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Cancelled during rsrc extract!");
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail; /* abort anything that was pending */
|
|
|
|
} else if (result != IDOK) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Failed while extracting '%ls': %ls.",
|
2014-11-19 22:54:24 +00:00
|
|
|
(LPCWSTR) fixedPathName, (LPCWSTR) extractErrMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(rsrcBuf == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
if (pEntry->GetHasDataFork() && pEntry->GetHasRsrcFork()) {
|
|
|
|
fileDetails.SetEntryKind(LocalFileDetails::kFileKindBothForks);
|
|
|
|
} else if (pEntry->GetHasDataFork()) {
|
|
|
|
fileDetails.SetEntryKind(LocalFileDetails::kFileKindDataFork);
|
|
|
|
} else if (pEntry->GetHasRsrcFork()) {
|
|
|
|
fileDetails.SetEntryKind(LocalFileDetails::kFileKindRsrcFork);
|
|
|
|
} else {
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(false);
|
2015-01-05 05:04:01 +00:00
|
|
|
fileDetails.SetEntryKind(LocalFileDetails::kFileKindUnknown);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2015-01-05 05:04:01 +00:00
|
|
|
* Set up the rest of the LocalFileDetails fields.
|
2014-11-04 00:26:53 +00:00
|
|
|
*/
|
2015-01-05 05:04:01 +00:00
|
|
|
fileDetails.SetStrippedLocalPathName(fixedPathName);
|
|
|
|
fileDetails.SetFileType(pEntry->GetFileType());
|
|
|
|
fileDetails.SetAccess(pEntry->GetAccess());
|
2014-11-04 00:26:53 +00:00
|
|
|
have_stuff2:
|
2015-01-05 05:04:01 +00:00
|
|
|
fileDetails.SetFileSysFmt(pEntry->GetSourceFS());
|
|
|
|
fileDetails.SetFssep(PathProposal::kDefaultStoredFssep);
|
|
|
|
fileDetails.SetExtraType(pEntry->GetAuxType());
|
|
|
|
fileDetails.SetStorageType(kNuStorageUnknown); // let NufxLib deal
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
NuDateTime ndt;
|
2014-11-04 00:26:53 +00:00
|
|
|
time_t when;
|
2014-11-18 05:13:13 +00:00
|
|
|
when = time(NULL);
|
2015-01-05 05:04:01 +00:00
|
|
|
UNIXTimeToDateTime(&when, &ndt);
|
|
|
|
fileDetails.SetArchiveWhen(ndt);
|
2014-11-04 00:26:53 +00:00
|
|
|
when = pEntry->GetModWhen();
|
2015-01-05 05:04:01 +00:00
|
|
|
UNIXTimeToDateTime(&when, &ndt);
|
|
|
|
fileDetails.SetModWhen(ndt);
|
2014-11-04 00:26:53 +00:00
|
|
|
when = pEntry->GetCreateWhen();
|
2015-01-05 05:04:01 +00:00
|
|
|
UNIXTimeToDateTime(&when, &ndt);
|
|
|
|
fileDetails.SetCreateWhen(ndt);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
pActionProgress->SetArcName(fileDetails.GetStrippedLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pActionProgress->SetProgress(0) == IDCANCEL) {
|
|
|
|
retval = kXferCancelled;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
errMsg = pXferOpts->fTarget->XferFile(&fileDetails, &dataBuf, dataLen,
|
|
|
|
&rsrcBuf, rsrcLen);
|
|
|
|
if (!errMsg.IsEmpty()) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("XferFile failed!");
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Failed while transferring '%ls': %ls.",
|
|
|
|
(LPCWSTR) pEntry->GetDisplayName(), (LPCWSTR) errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(dataBuf == NULL);
|
|
|
|
ASSERT(rsrcBuf == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
if (pActionProgress->SetProgress(100) == IDCANCEL) {
|
|
|
|
retval = kXferCancelled;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//MainWindow* pMainWin;
|
|
|
|
//pMainWin = (MainWindow*)::AfxGetMainWnd();
|
|
|
|
//pMainWin->EventPause(1000);
|
|
|
|
|
|
|
|
retval = kXferOK;
|
|
|
|
|
|
|
|
bail:
|
|
|
|
if (retval != kXferOK)
|
|
|
|
pXferOpts->fTarget->XferAbort(pMsgWnd);
|
|
|
|
else
|
|
|
|
pXferOpts->fTarget->XferFinish(pMsgWnd);
|
|
|
|
delete[] dataBuf;
|
|
|
|
delete[] rsrcBuf;
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void DiskArchive::XferPrepare(const XferFileOptions* pXferOpts)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DiskArchive::XferPrepare");
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
//fpPrimaryDiskFS->SetParameter(DiskFS::kParmProDOS_AllowLowerCase,
|
|
|
|
// pXferOpts->fAllowLowerCase);
|
|
|
|
//fpPrimaryDiskFS->SetParameter(DiskFS::kParmProDOS_AllocSparse,
|
|
|
|
// pXferOpts->fUseSparseBlocks);
|
|
|
|
fpPrimaryDiskFS->SetParameter(DiskFS::kParm_CreateUnique, true);
|
|
|
|
|
|
|
|
//fXferStoragePrefix = pXferOpts->fStoragePrefix;
|
|
|
|
fpXferTargetFS = pXferOpts->fpTargetFS;
|
|
|
|
}
|
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
CString DiskArchive::XferFile(LocalFileDetails* pDetails, uint8_t** pDataBuf,
|
2014-11-21 02:10:18 +00:00
|
|
|
long dataLen, uint8_t** pRsrcBuf, long rsrcLen)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
DiskFS* pDiskFS;
|
|
|
|
CString errMsg;
|
|
|
|
DIError dierr = kDIErrNone;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" XFER: transfer '%ls' (dataLen=%ld rsrcLen=%ld)",
|
2015-01-05 05:04:01 +00:00
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName(), dataLen, rsrcLen);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pDataBuf != NULL);
|
|
|
|
ASSERT(pRsrcBuf != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-05 05:04:01 +00:00
|
|
|
const DiskFS::CreateParms& createParms = pDetails->GetCreateParms();
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fpXferTargetFS == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
pDiskFS = fpPrimaryDiskFS;
|
|
|
|
else
|
|
|
|
pDiskFS = fpXferTargetFS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Strip the high ASCII from DOS and RDOS text files, unless we're adding
|
|
|
|
* them to a DOS disk. Likewise, if we're adding non-DOS text files to
|
|
|
|
* a DOS disk, we need to add the high bit.
|
|
|
|
*
|
|
|
|
* DOS converts both TXT and SRC to 'T', so we have to handle both here.
|
|
|
|
* Ideally we'd just ask DOS, "do you think this is a text file?", but it's
|
|
|
|
* not worth adding a new interface just for that.
|
|
|
|
*/
|
|
|
|
bool srcIsDOS, dstIsDOS;
|
2015-01-05 05:04:01 +00:00
|
|
|
srcIsDOS = DiskImg::UsesDOSFileStructure(pDetails->GetFileSysFmt());
|
2014-11-04 00:26:53 +00:00
|
|
|
dstIsDOS = DiskImg::UsesDOSFileStructure(pDiskFS->GetDiskImg()->GetFSFormat());
|
|
|
|
if (dataLen > 0 &&
|
2015-01-05 05:04:01 +00:00
|
|
|
(pDetails->GetFileType() == kFileTypeTXT ||
|
|
|
|
pDetails->GetFileType() == kFileTypeSRC))
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
unsigned char* ucp = *pDataBuf;
|
|
|
|
long len = dataLen;
|
|
|
|
|
|
|
|
if (srcIsDOS && !dstIsDOS) {
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGD(" Stripping high ASCII from '%ls'",
|
2015-01-05 05:04:01 +00:00
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
while (len--)
|
|
|
|
*ucp++ &= 0x7f;
|
|
|
|
} else if (!srcIsDOS && dstIsDOS) {
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD(" Adding high ASCII to '%ls'",
|
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
while (len--) {
|
|
|
|
if (*ucp != '\0')
|
|
|
|
*ucp |= 0x80;
|
|
|
|
ucp++;
|
|
|
|
}
|
|
|
|
} else if (srcIsDOS && dstIsDOS) {
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGD(" --- not altering DOS-to-DOS text '%ls'",
|
2015-01-05 05:04:01 +00:00
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
} else {
|
2015-01-05 05:04:01 +00:00
|
|
|
LOGD(" --- non-DOS transfer '%ls'",
|
|
|
|
(LPCWSTR) pDetails->GetStrippedLocalPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add a file with one or two forks */
|
|
|
|
if (createParms.storageType == kNuStorageDirectory) {
|
|
|
|
ASSERT(dataLen < 0 && rsrcLen < 0);
|
|
|
|
} else {
|
|
|
|
ASSERT(dataLen >= 0 || rsrcLen >= 0); // at least one fork
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we still have something to write, write it */
|
|
|
|
dierr = AddForksToDisk(pDiskFS, &createParms, *pDataBuf, dataLen,
|
|
|
|
*pRsrcBuf, rsrcLen);
|
|
|
|
if (dierr != kDIErrNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"%hs", DiskImgLib::DIStrError(dierr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
delete[] *pDataBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
*pDataBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
delete[] *pRsrcBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
*pRsrcBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
bail:
|
|
|
|
return errMsg;
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void DiskArchive::XferAbort(CWnd* pMsgWnd)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
// Can't undo previous actions.
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DiskArchive::XferAbort");
|
2014-11-04 00:26:53 +00:00
|
|
|
InternalReload(pMsgWnd);
|
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void DiskArchive::XferFinish(CWnd* pMsgWnd)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DiskArchive::XferFinish");
|
2014-11-04 00:26:53 +00:00
|
|
|
InternalReload(pMsgWnd);
|
|
|
|
}
|