2007-03-27 17:47:10 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Bridge between NufxLib and GenericArchive.
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "NufxArchive.h"
|
|
|
|
#include "ConfirmOverwriteDialog.h"
|
|
|
|
#include "RenameEntryDialog.h"
|
|
|
|
#include "RecompressOptionsDialog.h"
|
|
|
|
#include "AddClashDialog.h"
|
|
|
|
#include "Main.h"
|
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
|
|
|
#include "../nufxlib/NufxLib.h"
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NufxLib doesn't currently allow an fssep of '\0', so we use this instead
|
|
|
|
* to indicate the absence of an fssep char. Not quite right, but it'll do
|
|
|
|
* until NufxLib gets fixed.
|
|
|
|
*/
|
|
|
|
const unsigned char kNufxNoFssep = 0xff;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxEntry
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int NufxEntry::ExtractThreadToBuffer(int which, char** ppText, long* pLength,
|
2014-11-04 00:26:53 +00:00
|
|
|
CString* pErrMsg) const
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
2014-11-18 05:13:13 +00:00
|
|
|
char* dataBuf = NULL;
|
|
|
|
NuDataSink* pDataSink = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
NuThread thread;
|
|
|
|
unsigned long actualThreadEOF;
|
|
|
|
NuThreadIdx threadIdx;
|
|
|
|
bool needAlloc = true;
|
|
|
|
int result = -1;
|
|
|
|
|
|
|
|
ASSERT(IDOK != -1 && IDCANCEL != -1); // make sure return vals don't clash
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (*ppText != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
needAlloc = false;
|
|
|
|
|
|
|
|
FindThreadInfo(which, &thread, pErrMsg);
|
|
|
|
if (!pErrMsg->IsEmpty())
|
|
|
|
goto bail;
|
|
|
|
threadIdx = thread.threadIdx;
|
|
|
|
actualThreadEOF = thread.actualThreadEOF;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We've got the right thread. Create an appropriately-sized buffer
|
|
|
|
* and extract the data into it (WITHOUT doing EOL conversion).
|
|
|
|
*
|
|
|
|
* First check for a length of zero.
|
|
|
|
*/
|
|
|
|
if (actualThreadEOF == 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Empty thread");
|
2014-11-04 00:26:53 +00:00
|
|
|
if (needAlloc) {
|
|
|
|
*ppText = new char[1];
|
|
|
|
**ppText = '\0';
|
|
|
|
}
|
|
|
|
*pLength = 0;
|
|
|
|
result = IDOK;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needAlloc) {
|
|
|
|
dataBuf = new char[actualThreadEOF];
|
2014-11-18 05:13:13 +00:00
|
|
|
if (dataBuf == 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
|
|
|
pErrMsg->Format(L"allocation of %ld bytes failed",
|
2014-11-04 00:26:53 +00:00
|
|
|
actualThreadEOF);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (*pLength < (long) actualThreadEOF) {
|
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"buf size %ld too short (%ld)",
|
2014-11-04 00:26:53 +00:00
|
|
|
*pLength, actualThreadEOF);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
dataBuf = *ppText;
|
|
|
|
}
|
|
|
|
nerr = NuCreateDataSinkForBuffer(true, kNuConvertOff,
|
|
|
|
(unsigned char*)dataBuf, actualThreadEOF, &pDataSink);
|
|
|
|
if (nerr != kNuErrNone) {
|
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"unable to create buffer data sink: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_PROGRESS_BEGIN();
|
|
|
|
nerr = NuExtractThread(fpArchive, threadIdx, pDataSink);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr == kNuErrAborted) {
|
|
|
|
result = IDCANCEL;
|
|
|
|
//::sprintf(errorBuf, "Cancelled.\n");
|
|
|
|
} else if (nerr == kNuErrBadFormat) {
|
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"The compression method used on this file is not supported "
|
|
|
|
L"by your copy of \"nufxlib.dll\". For more information, "
|
|
|
|
L"please visit us on the web at "
|
|
|
|
L"http://www.faddensoft.com/ciderpress/");
|
2014-11-04 00:26:53 +00:00
|
|
|
} 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"unable to extract thread %ld: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
threadIdx, NuStrError(nerr));
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needAlloc)
|
|
|
|
*ppText = dataBuf;
|
|
|
|
*pLength = actualThreadEOF;
|
|
|
|
result = IDOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pDataSink != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
NuFreeDataSink(pDataSink);
|
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int NufxEntry::ExtractThreadToFile(int which, FILE* outfp, ConvertEOL conv,
|
2014-11-04 00:26:53 +00:00
|
|
|
ConvertHighASCII convHA, CString* pErrMsg) const
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
NuDataSink* pDataSink = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
NuThread thread;
|
|
|
|
unsigned long actualThreadEOF;
|
|
|
|
NuThreadIdx threadIdx;
|
|
|
|
int result = -1;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(outfp != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
//CString errMsg;
|
|
|
|
FindThreadInfo(which, &thread, pErrMsg);
|
|
|
|
if (!pErrMsg->IsEmpty())
|
|
|
|
goto bail;
|
|
|
|
threadIdx = thread.threadIdx;
|
|
|
|
actualThreadEOF = thread.actualThreadEOF;
|
|
|
|
|
|
|
|
/* we've got the right thread, see if it's empty */
|
|
|
|
if (actualThreadEOF == 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Empty thread");
|
2014-11-04 00:26:53 +00:00
|
|
|
result = IDOK;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set EOL conversion flags */
|
|
|
|
NuValue nuConv;
|
|
|
|
switch (conv) {
|
|
|
|
case kConvertEOLOff: nuConv = kNuConvertOff; break;
|
|
|
|
case kConvertEOLOn: nuConv = kNuConvertOn; break;
|
|
|
|
case kConvertEOLAuto: nuConv = kNuConvertAuto; break;
|
|
|
|
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
|
|
|
pErrMsg->Format(L"internal error: bad conv flag %d", conv);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (which == kDiskImageThread) {
|
|
|
|
/* override the above; never EOL-convert a disk image */
|
|
|
|
nuConv = kNuConvertOff;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (convHA) {
|
|
|
|
case kConvertHAOff:
|
|
|
|
nerr = NuSetValue(fpArchive, kNuValueStripHighASCII, false);
|
|
|
|
break;
|
|
|
|
case kConvertHAOn:
|
|
|
|
case kConvertHAAuto:
|
|
|
|
nerr = NuSetValue(fpArchive, kNuValueStripHighASCII, true);
|
|
|
|
break;
|
|
|
|
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
|
|
|
pErrMsg->Format(L"internal error: bad convHA flag %d", convHA);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make sure we convert to CRLF */
|
|
|
|
nerr = NuSetValue(fpArchive, kNuValueEOL, kNuEOLCRLF); // for Win32
|
|
|
|
if (nerr != kNuErrNone) {
|
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 setting EOL value: %hs", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a data sink for "outfp" */
|
|
|
|
nerr = NuCreateDataSinkForFP(true, nuConv, outfp, &pDataSink);
|
|
|
|
if (nerr != kNuErrNone) {
|
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"unable to create FP data sink: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* extract the thread to the file */
|
|
|
|
SET_PROGRESS_BEGIN();
|
|
|
|
nerr = NuExtractThread(fpArchive, threadIdx, pDataSink);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr == kNuErrAborted) {
|
|
|
|
/* user hit the "cancel" button */
|
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"cancelled";
|
2014-11-04 00:26:53 +00:00
|
|
|
result = IDCANCEL;
|
|
|
|
} else if (nerr == kNuErrBadFormat) {
|
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"The compression method used on this file is not supported "
|
|
|
|
L"by your copy of \"nufxlib.dll\". For more information, "
|
|
|
|
L"please visit us on the web at "
|
|
|
|
L"http://www.faddensoft.com/ciderpress/");
|
2014-11-04 00:26:53 +00:00
|
|
|
} 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"unable to extract thread %ld: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
threadIdx, NuStrError(nerr));
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = IDOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
if (result == IDOK) {
|
|
|
|
SET_PROGRESS_END();
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pDataSink != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
NuFreeDataSink(pDataSink);
|
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxEntry::FindThreadInfo(int which, NuThread* pRetThread,
|
2014-11-04 00:26:53 +00:00
|
|
|
CString* pErrMsg) const
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
|
|
|
|
ASSERT(pErrMsg->IsEmpty());
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Retrieve the record from the archive.
|
|
|
|
*/
|
|
|
|
const NuRecord* pRecord;
|
|
|
|
nerr = NuGetRecord(fpArchive, fRecordIdx, &pRecord);
|
|
|
|
if (nerr != kNuErrNone) {
|
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"NufxLib unable to locate record %ld: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
fRecordIdx, NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the right thread.
|
|
|
|
*/
|
|
|
|
const NuThread* pThread;
|
|
|
|
unsigned long wantedThreadID;
|
|
|
|
switch (which) {
|
|
|
|
case kDataThread: wantedThreadID = kNuThreadIDDataFork; break;
|
|
|
|
case kRsrcThread: wantedThreadID = kNuThreadIDRsrcFork; break;
|
|
|
|
case kDiskImageThread: wantedThreadID = kNuThreadIDDiskImage; break;
|
|
|
|
case kCommentThread: wantedThreadID = kNuThreadIDComment; 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
|
|
|
pErrMsg->Format(L"looking for bogus thread 0x%02x", which);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
int i;
|
2014-11-18 05:13:13 +00:00
|
|
|
pThread = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
for (i = 0; i < (int)NuRecordGetNumThreads(pRecord); i++) {
|
|
|
|
pThread = NuGetThread(pRecord, i);
|
2014-11-19 22:54:24 +00:00
|
|
|
assert(pThread != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (NuGetThreadID(pThread) == wantedThreadID)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == (int)NuRecordGetNumThreads(pRecord)) {
|
|
|
|
/* didn't find the thread we wanted */
|
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"searched %d threads but couldn't find 0x%02x",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuRecordGetNumThreads(pRecord), which);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-11-19 22:54:24 +00:00
|
|
|
assert(pThread != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
memcpy(pRetThread, pThread, sizeof(*pRetThread));
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//static const char* gShortFormatNames[] = {
|
|
|
|
// "unc", "squ", "lz1", "lz2", "u12", "u16", "dfl", "bzp"
|
|
|
|
//};
|
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
|
|
|
static const WCHAR* gFormatNames[] = {
|
|
|
|
L"Uncompr", L"Squeeze", L"LZW/1", L"LZW/2", L"LZC-12",
|
|
|
|
L"LZC-16", L"Deflate", L"Bzip2"
|
2007-03-27 17:47:10 +00:00
|
|
|
};
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxEntry::AnalyzeRecord(const NuRecord* pRecord)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* The "best format" and "record type" stuff assume that the entire
|
|
|
|
* record contains only a disk thread or a file thread, and that any
|
|
|
|
* format is interesting so long as it isn't "no compression". In
|
|
|
|
* general these will be true, because ShrinkIt and NuLib create files
|
|
|
|
* this way.
|
|
|
|
*
|
|
|
|
* You could, of course, create a single record with a data thread and
|
|
|
|
* a disk image thread, but it's a fair bet ShrinkIt would ignore one
|
|
|
|
* or the other.
|
|
|
|
*
|
|
|
|
* NOTE: we don't currently work around the GSHK zero-length file bug.
|
|
|
|
* Such records, which have a filename thread but no data threads at all,
|
|
|
|
* will be categorized as "unknown". We could detect the situation and
|
|
|
|
* correct it, but we might as well flag it in a user-visible way.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
const NuThread* pThread;
|
|
|
|
NuThreadID threadID;
|
|
|
|
unsigned long idx;
|
|
|
|
RecordKind recordKind;
|
|
|
|
unsigned long uncompressedLen;
|
|
|
|
unsigned long compressedLen;
|
|
|
|
unsigned short format;
|
|
|
|
|
|
|
|
recordKind = kRecordKindUnknown;
|
|
|
|
uncompressedLen = compressedLen = 0;
|
|
|
|
format = kNuThreadFormatUncompressed;
|
|
|
|
|
|
|
|
for (idx = 0; idx < pRecord->recTotalThreads; idx++) {
|
|
|
|
pThread = NuGetThread(pRecord, idx);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pThread != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
threadID = NuMakeThreadID(pThread->thThreadClass,
|
|
|
|
pThread->thThreadKind);
|
|
|
|
|
|
|
|
if (pThread->thThreadClass == kNuThreadClassData) {
|
|
|
|
/* replace what's there if this might be more interesting */
|
|
|
|
if (format == kNuThreadFormatUncompressed)
|
|
|
|
format = (unsigned short) pThread->thThreadFormat;
|
|
|
|
|
|
|
|
if (threadID == kNuThreadIDRsrcFork)
|
|
|
|
recordKind = kRecordKindForkedFile;
|
|
|
|
else if (threadID == kNuThreadIDDiskImage)
|
|
|
|
recordKind = kRecordKindDisk;
|
|
|
|
else if (threadID == kNuThreadIDDataFork &&
|
|
|
|
recordKind == kRecordKindUnknown)
|
|
|
|
recordKind = kRecordKindFile;
|
|
|
|
|
|
|
|
/* sum up, so we get both forks of forked files */
|
|
|
|
//uncompressedLen += pThread->actualThreadEOF;
|
|
|
|
compressedLen += pThread->thCompThreadEOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (threadID == kNuThreadIDDataFork) {
|
|
|
|
if (!GetHasDataFork() && !GetHasDiskImage()) {
|
|
|
|
SetHasDataFork(true);
|
|
|
|
SetDataForkLen(pThread->actualThreadEOF);
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("WARNING: ignoring second disk image / data fork");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (threadID == kNuThreadIDRsrcFork) {
|
|
|
|
if (!GetHasRsrcFork()) {
|
|
|
|
SetHasRsrcFork(true);
|
|
|
|
SetRsrcForkLen(pThread->actualThreadEOF);
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("WARNING: ignoring second data fork");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (threadID == kNuThreadIDDiskImage) {
|
|
|
|
if (!GetHasDiskImage() && !GetHasDataFork()) {
|
|
|
|
SetHasDiskImage(true);
|
|
|
|
SetDataForkLen(pThread->actualThreadEOF);
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("WARNING: ignoring second disk image / data fork");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (threadID == kNuThreadIDComment) {
|
|
|
|
SetHasComment(true);
|
|
|
|
if (pThread->actualThreadEOF != 0)
|
|
|
|
SetHasNonEmptyComment(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SetRecordKind(recordKind);
|
|
|
|
//SetUncompressedLen(uncompressedLen);
|
|
|
|
SetCompressedLen(compressedLen);
|
|
|
|
|
|
|
|
if (format >= 0 && format < NELEM(gFormatNames))
|
|
|
|
SetFormatStr(gFormatNames[format]);
|
|
|
|
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
|
|
|
SetFormatStr(L"Unknown");
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ CString NufxArchive::AppInit(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
CString result("");
|
2015-01-04 19:29:51 +00:00
|
|
|
int32_t major, minor, bug;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
nerr = NuGetVersion(&major, &minor, &bug, NULL, NULL);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
result = "Unable to get version number from NufxLib.";
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (major != kNuVersionMajor || minor < kNuVersionMinor) {
|
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 NufxLib DLL found.\r\r"
|
|
|
|
L"Wanted v%d.%d.x, found %ld.%ld.%ld.",
|
2014-11-04 00:26:53 +00:00
|
|
|
kNuVersionMajor, kNuVersionMinor,
|
|
|
|
major, minor, bug);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (bug != kNuVersionBug) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Different 'bug' version (built vX.X.%d, dll vX.X.%d)",
|
2014-11-04 00:26:53 +00:00
|
|
|
kNuVersionBug, bug);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set NufxLib's global error message handler */
|
|
|
|
NuSetGlobalErrorMessageHandler(NufxErrorMsgHandler);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ bool NufxArchive::IsCompressionSupported(NuThreadFormat format)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuFeature feature;
|
|
|
|
|
|
|
|
switch (format) {
|
|
|
|
case kNuThreadFormatUncompressed:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case kNuThreadFormatHuffmanSQ:
|
|
|
|
feature = kNuFeatureCompressSQ;
|
|
|
|
break;
|
|
|
|
case kNuThreadFormatLZW1:
|
|
|
|
case kNuThreadFormatLZW2:
|
|
|
|
feature = kNuFeatureCompressLZW;
|
|
|
|
break;
|
|
|
|
case kNuThreadFormatLZC12:
|
|
|
|
case kNuThreadFormatLZC16:
|
|
|
|
feature = kNuFeatureCompressLZC;
|
|
|
|
break;
|
|
|
|
case kNuThreadFormatDeflate:
|
|
|
|
feature = kNuFeatureCompressDeflate;
|
|
|
|
break;
|
|
|
|
case kNuThreadFormatBzip2:
|
|
|
|
feature = kNuFeatureCompressBzip2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(false);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
NuError nerr;
|
|
|
|
nerr = NuTestFeature(feature);
|
|
|
|
if (nerr == kNuErrNone)
|
|
|
|
return true;
|
|
|
|
return false;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuResult NufxArchive::NufxErrorMsgHandler(NuArchive*, void* vErrorMessage)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage;
|
|
|
|
|
2014-11-19 01:10:23 +00:00
|
|
|
LOG_BASE(pErrorMessage->isDebug ? DebugLog::LOG_DEBUG : DebugLog::LOG_WARN,
|
2014-11-18 21:05:15 +00:00
|
|
|
pErrorMessage->file, pErrorMessage->line, "<nufxlib> %hs",
|
2014-11-18 01:54:34 +00:00
|
|
|
pErrorMessage->message);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return kNuOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/NuResult NufxArchive::ProgressUpdater(NuArchive* pArchive,
|
|
|
|
void* vpProgress)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
// "oldName" ends up on top, "newName" on bottom.
|
2014-11-04 00:26:53 +00:00
|
|
|
const NuProgressData* pProgress = (const NuProgressData*) vpProgress;
|
|
|
|
NufxArchive* pThis;
|
|
|
|
MainWindow* pMainWin = (MainWindow*)::AfxGetMainWnd();
|
|
|
|
int status;
|
|
|
|
const char* oldName;
|
|
|
|
const char* newName;
|
|
|
|
int perc;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pProgress != NULL);
|
|
|
|
ASSERT(pMainWin != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pArchive != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
(void) NuGetExtraData(pArchive, (void**) &pThis);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pThis != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
oldName = newName = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pProgress->operation == kNuOpAdd) {
|
2015-01-04 19:29:51 +00:00
|
|
|
oldName = pProgress->origPathnameUNI;
|
|
|
|
newName = pProgress->pathnameUNI;
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pThis->fProgressAsRecompress)
|
|
|
|
oldName = "-";
|
|
|
|
} else if (pProgress->operation == kNuOpTest) {
|
2015-01-04 19:29:51 +00:00
|
|
|
oldName = pProgress->pathnameUNI;
|
2014-11-04 00:26:53 +00:00
|
|
|
} else if (pProgress->operation == kNuOpExtract) {
|
|
|
|
if (pThis->fProgressAsRecompress) {
|
2015-01-04 19:29:51 +00:00
|
|
|
oldName = pProgress->origPathnameUNI;
|
2014-11-04 00:26:53 +00:00
|
|
|
newName = "-";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
perc = pProgress->percentComplete;
|
|
|
|
if (pProgress->state == kNuProgressDone)
|
|
|
|
perc = 100;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("Progress: %d%% '%hs' '%hs'", perc,
|
2014-11-18 05:13:13 +00:00
|
|
|
// oldName == NULL ? "(null)" : oldName,
|
|
|
|
// newName == NULL ? "(null)" : newName);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
//status = pMainWin->SetProgressUpdate(perc, oldName, newName);
|
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
|
|
|
CString oldNameW(oldName);
|
|
|
|
CString newNameW(newName);
|
|
|
|
status = SET_PROGRESS_UPDATE2(perc, oldNameW, newNameW);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* check to see if user hit the "cancel" button on the progress dialog */
|
|
|
|
if (pProgress->state == kNuProgressAborted) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("(looks like we're aborting)");
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(status == IDCANCEL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (status == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Signaling NufxLib to abort");
|
2014-11-04 00:26:53 +00:00
|
|
|
return kNuAbort;
|
|
|
|
} else
|
|
|
|
return kNuOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
GenericArchive::OpenResult NufxArchive::Open(const WCHAR* filename,
|
|
|
|
bool readOnly, CString* pErrMsg)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
CString errMsg;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive == 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
|
|
|
CStringA filenameA(filename);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (!readOnly) {
|
|
|
|
CString tmpname = GenDerivedTempName(filename);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Opening file '%ls' rw (tmp='%ls')", filename, (LPCWSTR) tmpname);
|
2014-11-04 00:26:53 +00:00
|
|
|
fIsReadOnly = 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
|
|
|
CStringA tmpnameA(tmpname);
|
|
|
|
nerr = NuOpenRW(filenameA, tmpnameA, 0, &fpArchive);
|
2014-11-19 01:10:23 +00:00
|
|
|
|
|
|
|
if (nerr == kNuErrFileAccessDenied || nerr == EACCES) {
|
|
|
|
LOGI("Read-write failed with access denied, trying read-only");
|
|
|
|
readOnly = true;
|
|
|
|
}
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
if (readOnly) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Opening file '%ls' ro", (LPCWSTR) filename);
|
2014-11-04 00:26:53 +00:00
|
|
|
fIsReadOnly = 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
|
|
|
nerr = NuOpenRO(filenameA, &fpArchive);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
if (nerr != kNuErrNone) {
|
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, NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("FILE OPEN SUCCESS");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nerr = SetCallbacks();
|
|
|
|
if (nerr != kNuErrNone) {
|
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"Callback init failed";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
nerr = LoadContents();
|
|
|
|
if (nerr != kNuErrNone) {
|
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 reading archive contents: ";
|
2014-11-04 00:26:53 +00:00
|
|
|
errMsg += NuStrError(nerr);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPathName(filename);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
*pErrMsg = errMsg;
|
|
|
|
if (!errMsg.IsEmpty())
|
|
|
|
return kResultFailure;
|
|
|
|
else
|
|
|
|
return kResultSuccess;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString NufxArchive::New(const WCHAR* filename, const void* options)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
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
|
|
|
CString retmsg;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive == NULL);
|
|
|
|
ASSERT(options == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
CString tmpname = GenDerivedTempName(filename);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Creating file '%ls' (tmp='%ls')", filename, (LPCWSTR) tmpname);
|
2014-11-04 00:26:53 +00:00
|
|
|
fIsReadOnly = 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
|
|
|
CStringA filenameA(filename);
|
|
|
|
CStringA tmpnameA(tmpname);
|
|
|
|
nerr = NuOpenRW(filenameA, tmpnameA, kNuOpenCreat | kNuOpenExcl, &fpArchive);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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 open '%ls': %hs", filename, NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("NEW FILE SUCCESS");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nerr = SetCallbacks();
|
|
|
|
if (nerr != kNuErrNone) {
|
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"Callback init failed";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetPathName(filename);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return retmsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError NufxArchive::SetCallbacks(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
nerr = NuSetExtraData(fpArchive, this);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone)
|
|
|
|
goto bail;
|
2007-03-27 17:47:10 +00:00
|
|
|
// nerr = NuSetSelectionFilter(fpArchive, SelectionFilter);
|
2014-11-04 00:26:53 +00:00
|
|
|
// if (nerr != kNuErrNone)
|
|
|
|
// goto bail;
|
2007-03-27 17:47:10 +00:00
|
|
|
// nerr = NuSetOutputPathnameFilter(fpArchive, OutputPathnameFilter);
|
2014-11-04 00:26:53 +00:00
|
|
|
// if (nerr != kNuErrNone)
|
|
|
|
// goto bail;
|
2007-03-27 17:47:10 +00:00
|
|
|
NuSetProgressUpdater(fpArchive, ProgressUpdater);
|
|
|
|
// nerr = NuSetErrorHandler(fpArchive, ErrorHandler);
|
2014-11-04 00:26:53 +00:00
|
|
|
// if (nerr != kNuErrNone)
|
|
|
|
// goto bail;
|
2007-03-27 17:47:10 +00:00
|
|
|
NuSetErrorMessageHandler(fpArchive, NufxErrorMsgHandler);
|
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* let NufxLib worry about buggy records without data threads */
|
|
|
|
nerr = NuSetValue(fpArchive, kNuValueMaskDataless, kNuValueTrue);
|
|
|
|
if (nerr != kNuErrNone)
|
|
|
|
goto bail;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* set any values based on Preferences values */
|
|
|
|
PreferencesChanged();
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return nerr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxArchive::PreferencesChanged(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
const Preferences* pPreferences = GET_PREFERENCES();
|
|
|
|
bool val;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
val = pPreferences->GetPrefBool(kPrMimicShrinkIt);
|
2007-03-27 17:47:10 +00:00
|
|
|
nerr = NuSetValue(fpArchive, kNuValueMimicSHK, val);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("NuSetValue(kNuValueMimicSHK, %d) failed, err=%d", val, nerr);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(false);
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Set MimicShrinkIt to %d", val);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
val = pPreferences->GetPrefBool(kPrReduceSHKErrorChecks);
|
2007-03-27 17:47:10 +00:00
|
|
|
NuSetValue(fpArchive, kNuValueIgnoreLZW2Len, val);
|
|
|
|
NuSetValue(fpArchive, kNuValueIgnoreCRC, val);
|
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
val = pPreferences->GetPrefBool(kPrBadMacSHK);
|
|
|
|
NuSetValue(fpArchive, kNuValueHandleBadMac, val);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
long NufxArchive::GetCapability(Capability cap)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
switch (cap) {
|
|
|
|
case kCapCanTest:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case kCapCanRenameFullPath:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case kCapCanRecompress:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case kCapCanEditComment:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case kCapCanAddDisk:
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
case kCapCanConvEOLOnAdd:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case kCapCanCreateSubdir:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case kCapCanRenameVolume:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT(false);
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError NufxArchive::LoadContents(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* We will need to set an error handler if we want to be able to do things
|
|
|
|
* like "I found a bad CRC, did you want me to keep trying anyway?".
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
long counter = 0;
|
|
|
|
NuError result;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("NufxArchive LoadContents");
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
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;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
result = NuContents(fpArchive, ContentFunc);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
SET_PROGRESS_COUNTER(-1);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWaitDlg->DestroyWindow();
|
|
|
|
//pMain->PeekAndPump(); // redraw
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString NufxArchive::Reload(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
CString errMsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
fReloadFlag = true; // tell everybody that cached data is invalid
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
DeleteEntries(); // a GenericArchive operation
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = LoadContents();
|
|
|
|
if (nerr != kNuErrNone) {
|
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: unable to reload archive contents: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
DeleteEntries();
|
|
|
|
fIsReadOnly = true;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return errMsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError NufxArchive::InternalReload(CWnd* pMsgWnd)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
errMsg = Reload();
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (!errMsg.IsEmpty()) {
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
return kNuErrGeneric;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return kNuErrNone;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuResult NufxArchive::ContentFunc(NuArchive* pArchive, void* vpRecord)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
const NuRecord* pRecord = (const NuRecord*) vpRecord;
|
|
|
|
NufxArchive* pThis;
|
|
|
|
NufxEntry* pNewEntry;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pArchive != NULL);
|
|
|
|
ASSERT(vpRecord != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
NuGetExtraData(pArchive, (void**) &pThis);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewEntry = new NufxEntry(pArchive);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2015-01-04 19:29:51 +00:00
|
|
|
CStringW filenameW(pRecord->filenameMOR);
|
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->SetPathName(filenameW);
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewEntry->SetFssep(NuGetSepFromSysInfo(pRecord->recFileSysInfo));
|
|
|
|
pNewEntry->SetFileType(pRecord->recFileType);
|
|
|
|
pNewEntry->SetAuxType(pRecord->recExtraType);
|
|
|
|
pNewEntry->SetAccess(pRecord->recAccess);
|
|
|
|
pNewEntry->SetCreateWhen(DateTimeToSeconds(&pRecord->recCreateWhen));
|
|
|
|
pNewEntry->SetModWhen(DateTimeToSeconds(&pRecord->recModWhen));
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/*
|
|
|
|
* Our files are always ProDOS format. This is especially important
|
|
|
|
* when cutting & pasting, so that the DOS high ASCII converter gets
|
|
|
|
* invoked at appropriate times.
|
|
|
|
*/
|
|
|
|
pNewEntry->SetSourceFS(DiskImg::kFormatProDOS);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewEntry->AnalyzeRecord(pRecord);
|
|
|
|
pNewEntry->SetRecordIdx(pRecord->recordIdx);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pThis->AddEntry(pNewEntry);
|
|
|
|
if ((pThis->GetNumEntries() % 10) == 0)
|
|
|
|
SET_PROGRESS_COUNTER(pThis->GetNumEntries());
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return kNuOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ time_t NufxArchive::DateTimeToSeconds(const NuDateTime* pDateTime)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pDateTime->second == 0 &&
|
|
|
|
pDateTime->minute == 0 &&
|
|
|
|
pDateTime->hour == 0 &&
|
|
|
|
pDateTime->year == 0 &&
|
|
|
|
pDateTime->day == 0 &&
|
|
|
|
pDateTime->month == 0 &&
|
|
|
|
pDateTime->extra == 0 &&
|
|
|
|
pDateTime->weekDay == 0)
|
|
|
|
{
|
|
|
|
return kDateNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
int year;
|
|
|
|
if (pDateTime->year < 40)
|
|
|
|
year = pDateTime->year + 2000;
|
|
|
|
else
|
|
|
|
year = pDateTime->year + 1900;
|
|
|
|
|
|
|
|
if (year < 1969) {
|
|
|
|
/*
|
|
|
|
* Years like 1963 are valid on an Apple II but cannot be represented
|
|
|
|
* as a time_t, which starts in 1970. (Depending on GMT offsets,
|
|
|
|
* it actually starts a few hours earlier at the end of 1969.)
|
|
|
|
*
|
|
|
|
* I'm catching this here because of an assert in the CTime
|
|
|
|
* constructor. The constructor seems to do the right thing, and the
|
|
|
|
* assert won't be present in the shipping version, but it's annoying
|
|
|
|
* during debugging.
|
|
|
|
*/
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI(" Ignoring funky year %ld", year);
|
2014-11-04 00:26:53 +00:00
|
|
|
return kDateInvalid;
|
|
|
|
}
|
|
|
|
if (pDateTime->month > 11)
|
|
|
|
return kDateInvalid;
|
|
|
|
|
|
|
|
CTime modTime(year,
|
|
|
|
pDateTime->month+1,
|
|
|
|
pDateTime->day+1,
|
|
|
|
pDateTime->hour,
|
|
|
|
pDateTime->minute,
|
|
|
|
pDateTime->second);
|
|
|
|
return (time_t) modTime.GetTime();
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ NuResult NufxArchive::ArrayDeleteHandler(NuArchive* pArchive, void* ptr)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
delete[] ptr;
|
|
|
|
return kNuOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive -- add files (or disks)
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::BulkAdd(ActionProgressDialog* pActionProgress,
|
2014-11-04 00:26:53 +00:00
|
|
|
const AddFilesDialog* pAddOpts)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* This calls into the GenericArchive "AddFile" function, which does
|
|
|
|
* Win32-specific processing. That function calls our DoAddFile function,
|
|
|
|
* which does the NuFX stuff.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
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-11-18 21:05:15 +00:00
|
|
|
LOGI("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-11-18 21:05:15 +00:00
|
|
|
LOGI(" sub=%d strip=%d ovwr=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
pAddOpts->fIncludeSubfolders, pAddOpts->fStripFolderNames,
|
|
|
|
pAddOpts->fOverwriteExisting);
|
|
|
|
|
|
|
|
AddPrep(pActionProgress, pAddOpts);
|
|
|
|
|
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
|
|
|
pActionProgress->SetArcName(L"(Scanning files to be added...)");
|
|
|
|
pActionProgress->SetFileName(L"");
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* initialize count */
|
|
|
|
fNumAdded = 0;
|
|
|
|
|
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(fpMsgWnd, 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(fpMsgWnd, 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
|
|
|
|
|
|
|
/* this just provides the list of files to NufxLib */
|
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-16 19:04:31 +00:00
|
|
|
(LPCWSTR) name, NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrAborted) {
|
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* actually do the work */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr != kNuErrAborted) {
|
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 add files: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fNumAdded) {
|
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";
|
|
|
|
fpMsgWnd->MessageBox(errMsg, L"CiderPress", MB_OK | MB_ICONWARNING);
|
2014-11-04 00:26:53 +00:00
|
|
|
} else {
|
|
|
|
if (InternalReload(fpMsgWnd) == kNuErrNone)
|
|
|
|
retVal = true;
|
|
|
|
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
|
|
|
errMsg = L"Reload failed.";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
NuAbort(fpArchive); // abort anything that didn't get flushed
|
|
|
|
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(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
// bummer, but don't signal failure
|
|
|
|
}
|
|
|
|
AddFinish();
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::AddDisk(ActionProgressDialog* pActionProgress,
|
2014-11-04 00:26:53 +00:00
|
|
|
const AddFilesDialog* pAddOpts)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
CString errMsg;
|
|
|
|
const int kBlockSize = 512;
|
|
|
|
PathProposal pathProp;
|
|
|
|
PathName pathName;
|
|
|
|
DiskImg* pDiskImg;
|
2014-11-18 05:13:13 +00:00
|
|
|
NuDataSource* pSource = NULL;
|
|
|
|
unsigned char* diskData = 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
|
|
|
WCHAR curDir[MAX_PATH] = L"\\";
|
2014-11-04 00:26:53 +00:00
|
|
|
bool retVal = 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
|
|
|
CStringA storageNameA, origNameA;
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-12-04 00:10:03 +00:00
|
|
|
LOGI("AddDisk: '%ls' (count=%d)", (LPCWSTR) pAddOpts->GetDirectory(),
|
|
|
|
pAddOpts->GetFileNames().GetCount());
|
|
|
|
LOGI("Opts: stpfx='%ls' pres=%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-11-18 21:05:15 +00:00
|
|
|
LOGI(" sub=%d strip=%d ovwr=%d",
|
2014-11-04 00:26:53 +00:00
|
|
|
pAddOpts->fIncludeSubfolders, pAddOpts->fStripFolderNames,
|
|
|
|
pAddOpts->fOverwriteExisting);
|
|
|
|
|
2014-12-04 00:10:03 +00:00
|
|
|
if (pAddOpts->GetFileNames().GetCount() != 1) {
|
|
|
|
LOGW("GLITCH: expected only one filename, found %d",
|
|
|
|
pAddOpts->GetFileNames().GetCount());
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pDiskImg = pAddOpts->fpDiskImg;
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pDiskImg != 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
|
|
|
/* allocate storage for the entire disk */
|
2014-11-21 02:10:18 +00:00
|
|
|
diskData = new uint8_t[pDiskImg->GetNumBlocks() * kBlockSize];
|
2014-11-18 05:13:13 +00:00
|
|
|
if (diskData == 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 %d bytes.",
|
2014-11-04 00:26:53 +00:00
|
|
|
pDiskImg->GetNumBlocks() * kBlockSize);
|
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* prepare to add */
|
|
|
|
AddPrep(pActionProgress, pAddOpts);
|
|
|
|
|
2014-12-04 00:10:03 +00:00
|
|
|
const CString& directory = pAddOpts->GetDirectory();
|
|
|
|
const CStringArray& fileNames = pAddOpts->GetFileNames();
|
|
|
|
LOGD("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(fpMsgWnd, 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(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-12-04 00:10:03 +00:00
|
|
|
const CString& fileName = pAddOpts->GetFileNames().GetAt(0);
|
|
|
|
LOGI(" file '%ls'", (LPCWSTR) fileName);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* strip off preservation stuff, and ignore it */
|
2014-12-04 00:10:03 +00:00
|
|
|
pathProp.Init(fileName);
|
2014-11-04 00:26:53 +00:00
|
|
|
pathProp.fStripDiskImageSuffix = true;
|
|
|
|
pathProp.LocalToArchive(pAddOpts);
|
|
|
|
|
|
|
|
/* fill in the necessary file details */
|
|
|
|
NuFileDetails details;
|
|
|
|
memset(&details, 0, sizeof(details));
|
|
|
|
details.threadID = kNuThreadIDDiskImage;
|
|
|
|
details.storageType = kBlockSize;
|
|
|
|
details.access = kNuAccessUnlocked;
|
|
|
|
details.extraType = pAddOpts->fpDiskImg->GetNumBlocks();
|
2014-12-04 00:10:03 +00:00
|
|
|
origNameA = fileName; // narrowing conversion
|
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
|
|
|
storageNameA = pathProp.fStoredPathName;
|
|
|
|
details.origName = origNameA;
|
2015-01-04 19:29:51 +00:00
|
|
|
details.storageNameMOR = storageNameA;
|
2014-11-04 00:26:53 +00:00
|
|
|
details.fileSysID = kNuFileSysUnknown;
|
|
|
|
details.fileSysInfo = PathProposal::kDefaultStoredFssep;
|
|
|
|
|
|
|
|
time_t now, then;
|
|
|
|
|
2014-12-04 00:10:03 +00:00
|
|
|
pathName.SetPathName(fileName);
|
2014-11-18 05:13:13 +00:00
|
|
|
now = time(NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
then = pathName.GetModWhen();
|
|
|
|
UNIXTimeToDateTime(&now, &details.archiveWhen);
|
|
|
|
UNIXTimeToDateTime(&then, &details.modWhen);
|
|
|
|
UNIXTimeToDateTime(&then, &details.createWhen);
|
|
|
|
|
|
|
|
/* set up the progress updater */
|
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
|
|
|
pActionProgress->SetArcName(pathProp.fStoredPathName);
|
2014-12-04 00:10:03 +00:00
|
|
|
pActionProgress->SetFileName(fileName);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* read the disk now that we have progress update titles in place */
|
|
|
|
int block, numBadBlocks;
|
|
|
|
unsigned char* bufPtr;
|
|
|
|
numBadBlocks = 0;
|
|
|
|
for (block = 0, bufPtr = diskData; block < pDiskImg->GetNumBlocks(); block++)
|
|
|
|
{
|
|
|
|
DIError dierr;
|
|
|
|
dierr = pDiskImg->ReadBlock(block, bufPtr);
|
|
|
|
if (dierr != kDIErrNone)
|
|
|
|
numBadBlocks++;
|
|
|
|
bufPtr += kBlockSize;
|
|
|
|
}
|
|
|
|
if (numBadBlocks > 0) {
|
|
|
|
CString appName, msg;
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&appName, 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
|
|
|
msg.Format(L"Skipped %ld unreadable block%ls.", numBadBlocks,
|
|
|
|
numBadBlocks == 1 ? L"" : L"s");
|
2014-11-04 00:26:53 +00:00
|
|
|
fpMsgWnd->MessageBox(msg, appName, MB_OK | MB_ICONWARNING);
|
|
|
|
// keep going -- just a warning
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a data source for the disk */
|
|
|
|
nerr = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, 0,
|
|
|
|
diskData, 0, pAddOpts->fpDiskImg->GetNumBlocks() * kBlockSize,
|
2014-11-18 05:13:13 +00:00
|
|
|
NULL, &pSource);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
errMsg = "Unable to create NufxLib data source.";
|
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add the record; name conflicts cause the error handler to fire */
|
|
|
|
NuRecordIdx recordIdx;
|
|
|
|
nerr = NuAddRecord(fpArchive, &details, &recordIdx);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr != kNuErrAborted) {
|
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 adding record: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do the compression */
|
|
|
|
nerr = NuAddThread(fpArchive, recordIdx, kNuThreadIDDiskImage,
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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 adding thread: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource = NULL; /* NufxLib owns it now */
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* actually do the work */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr != kNuErrAborted) {
|
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 add disk: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InternalReload(fpMsgWnd) == kNuErrNone)
|
|
|
|
retVal = true;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
delete[] diskData;
|
|
|
|
NuAbort(fpArchive); // abort anything that didn't get flushed
|
|
|
|
NuFreeDataSource(pSource);
|
|
|
|
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(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
// bummer
|
|
|
|
}
|
|
|
|
AddFinish();
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError NufxArchive::DoAddFile(const AddFilesDialog* pAddOpts,
|
2014-11-04 00:26:53 +00:00
|
|
|
FileDetails* pDetails)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError err;
|
|
|
|
NuRecordIdx recordIdx = 0;
|
|
|
|
NuFileDetails nuFileDetails;
|
|
|
|
|
2007-03-27 17:47:10 +00:00
|
|
|
retry:
|
2014-11-04 00:26:53 +00:00
|
|
|
nuFileDetails = *pDetails; // stuff class contents into struct
|
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 origNameA(pDetails->origName);
|
|
|
|
err = NuAddFile(fpArchive, origNameA /*pathname*/,
|
2014-11-04 00:26:53 +00:00
|
|
|
&nuFileDetails, false, &recordIdx);
|
|
|
|
|
|
|
|
if (err == kNuErrNone) {
|
|
|
|
fNumAdded++;
|
|
|
|
} else if (err == kNuErrSkipped) {
|
|
|
|
/* "maybe overwrite" UI causes this if user declines */
|
|
|
|
// fall through with the error
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("DoAddFile: skipped '%ls'", (LPCWSTR) pDetails->origName);
|
2014-11-04 00:26:53 +00:00
|
|
|
} else if (err == kNuErrRecordExists) {
|
|
|
|
AddClashDialog dlg;
|
|
|
|
|
|
|
|
dlg.fWindowsName = pDetails->origName;
|
|
|
|
dlg.fStorageName = pDetails->storageName;
|
|
|
|
if (dlg.DoModal() != IDOK) {
|
|
|
|
err = kNuErrAborted;
|
|
|
|
goto bail_quiet;
|
|
|
|
}
|
|
|
|
if (dlg.fDoRename) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGD("add clash: rename to '%ls'", (LPCWSTR) dlg.fNewName);
|
2014-11-04 00:26:53 +00:00
|
|
|
pDetails->storageName = dlg.fNewName;
|
|
|
|
goto retry;
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGD("add clash: skip");
|
2014-11-04 00:26:53 +00:00
|
|
|
err = kNuErrSkipped;
|
|
|
|
// fall through with error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//if (err != kNuErrNone)
|
|
|
|
// goto bail;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
//bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
if (err != kNuErrNone && err != kNuErrAborted && err != kNuErrSkipped) {
|
|
|
|
CString msg;
|
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"Unable to add file '%ls': %hs.",
|
|
|
|
(LPCWSTR) pDetails->origName, NuStrError(err));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, msg, IDS_FAILED);
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
bail_quiet:
|
2014-11-04 00:26:53 +00:00
|
|
|
return err;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxArchive::AddPrep(CWnd* pMsgWnd, const AddFilesDialog* pAddOpts)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
const Preferences* pPreferences = GET_PREFERENCES();
|
|
|
|
int defaultCompression;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
fpMsgWnd = pMsgWnd;
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpMsgWnd != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
fpAddOpts = pAddOpts;
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpAddOpts != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
//fBulkProgress = true;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
defaultCompression = pPreferences->GetPrefLong(kPrCompressionType);
|
|
|
|
nerr = NuSetValue(fpArchive, kNuValueDataCompression,
|
|
|
|
defaultCompression + kNuCompressNone);
|
|
|
|
if (nerr != kNuErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("GLITCH: unable to set compression type to %d",
|
2014-11-04 00:26:53 +00:00
|
|
|
defaultCompression);
|
|
|
|
/* keep going */
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pAddOpts->fOverwriteExisting)
|
|
|
|
NuSetValue(fpArchive, kNuValueHandleExisting, kNuAlwaysOverwrite);
|
|
|
|
else
|
|
|
|
NuSetValue(fpArchive, kNuValueHandleExisting, kNuMaybeOverwrite);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
NuSetErrorHandler(fpArchive, BulkAddErrorHandler);
|
2014-11-04 00:26:53 +00:00
|
|
|
NuSetExtraData(fpArchive, this);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxArchive::AddFinish(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
NuSetErrorHandler(fpArchive, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
NuSetValue(fpArchive, kNuValueHandleExisting, kNuMaybeOverwrite);
|
2014-11-18 05:13:13 +00:00
|
|
|
fpMsgWnd = NULL;
|
|
|
|
fpAddOpts = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
//fBulkProgress = false;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ NuResult NufxArchive::BulkAddErrorHandler(NuArchive* pArchive,
|
|
|
|
void* vErrorStatus)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
const NuErrorStatus* pErrorStatus = (const NuErrorStatus*)vErrorStatus;
|
|
|
|
NufxArchive* pThis;
|
|
|
|
NuResult result;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pArchive != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
(void) NuGetExtraData(pArchive, (void**) &pThis);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pThis != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(pArchive == pThis->fpArchive);
|
|
|
|
|
|
|
|
/* default action is to abort the current operation */
|
|
|
|
result = kNuAbort;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When adding files, the NuAddFile and NuAddRecord calls can return
|
|
|
|
* immediate, specific results for a single add. The only reasons for
|
|
|
|
* calling here are to decide if an existing record should be replaced
|
|
|
|
* or not (without even an option to rename), or to decide what to do
|
|
|
|
* when the NuFlush call runs into a problem while adding a file.
|
|
|
|
*/
|
|
|
|
if (pErrorStatus->operation != kNuOpAdd) {
|
|
|
|
ASSERT(false);
|
|
|
|
return kNuAbort;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pErrorStatus->err == kNuErrRecordExists) {
|
|
|
|
/* if they want to update or freshen, don't hassle them */
|
|
|
|
//if (NState_GetModFreshen(pState) || NState_GetModUpdate(pState))
|
|
|
|
if (pThis->fpAddOpts->fOverwriteExisting) {
|
|
|
|
ASSERT(false); // should be handled by AddPrep()/NufxLib
|
|
|
|
result = kNuOverwrite;
|
|
|
|
} else
|
|
|
|
result = pThis->HandleReplaceExisting(pErrorStatus);
|
|
|
|
} else if (pErrorStatus->err == kNuErrFileNotFound) {
|
|
|
|
/* file was specified with NuAdd but removed during NuFlush */
|
|
|
|
result = pThis->HandleAddNotFound(pErrorStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuResult NufxArchive::HandleReplaceExisting(const NuErrorStatus* pErrorStatus)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuResult result = kNuOK;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pErrorStatus != NULL);
|
2015-01-04 19:29:51 +00:00
|
|
|
ASSERT(pErrorStatus->pathnameUNI != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
ASSERT(pErrorStatus->canOverwrite);
|
|
|
|
ASSERT(pErrorStatus->canSkip);
|
|
|
|
ASSERT(pErrorStatus->canAbort);
|
|
|
|
ASSERT(!pErrorStatus->canRename);
|
|
|
|
|
|
|
|
/* no firm policy, ask the user */
|
|
|
|
ConfirmOverwriteDialog confOvwr;
|
2015-01-04 19:29:51 +00:00
|
|
|
PathName path(pErrorStatus->pathnameUNI);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2015-01-04 19:29:51 +00:00
|
|
|
confOvwr.fExistingFile = pErrorStatus->pRecord->filenameMOR;
|
2014-11-04 00:26:53 +00:00
|
|
|
confOvwr.fExistingFileModWhen =
|
|
|
|
DateTimeToSeconds(&pErrorStatus->pRecord->recModWhen);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pErrorStatus->origPathname != NULL) {
|
2015-01-04 19:29:51 +00:00
|
|
|
// TODO: use wchar_t instead for origPathname
|
|
|
|
confOvwr.fNewFileSource = (char*) pErrorStatus->origPathname;
|
2014-11-04 00:26:53 +00:00
|
|
|
PathName checkPath(confOvwr.fNewFileSource);
|
|
|
|
confOvwr.fNewFileModWhen = checkPath.GetModWhen();
|
|
|
|
} else {
|
|
|
|
confOvwr.fNewFileSource = "???";
|
|
|
|
confOvwr.fNewFileModWhen = kDateNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
confOvwr.fAllowRename = false;
|
|
|
|
if (confOvwr.DoModal() == IDCANCEL) {
|
|
|
|
result = kNuAbort;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (confOvwr.fResultRename) {
|
|
|
|
ASSERT(false);
|
|
|
|
result = kNuAbort;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (confOvwr.fResultApplyToAll) {
|
|
|
|
if (confOvwr.fResultOverwrite) {
|
|
|
|
(void) NuSetValue(fpArchive, kNuValueHandleExisting,
|
|
|
|
kNuAlwaysOverwrite);
|
|
|
|
} else {
|
|
|
|
(void) NuSetValue(fpArchive, kNuValueHandleExisting,
|
|
|
|
kNuNeverOverwrite);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (confOvwr.fResultOverwrite)
|
|
|
|
result = kNuOverwrite;
|
|
|
|
else
|
|
|
|
result = kNuSkip;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuResult NufxArchive::HandleAddNotFound(const NuErrorStatus* pErrorStatus)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
2007-03-27 17:47:10 +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
|
|
|
errMsg.Format(L"Failed while adding '%hs': file no longer exists.",
|
2015-01-04 19:29:51 +00:00
|
|
|
pErrorStatus->pathnameUNI);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return kNuAbort;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive -- test files
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
NufxEntry* pEntry;
|
|
|
|
CString errMsg;
|
|
|
|
bool retVal = false;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Testing %d entries", pSelSet->GetNumEntries());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
SelectionEntry* pSelEntry = pSelSet->IterNext();
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pSelEntry != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry = (NufxEntry*) pSelEntry->GetEntry();
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Testing %ld '%ls'", pEntry->GetRecordIdx(),
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetPathName());
|
|
|
|
nerr = NuTestRecord(fpArchive, pEntry->GetRecordIdx());
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr == kNuErrAborted) {
|
|
|
|
CString title;
|
2014-12-16 19:04:31 +00:00
|
|
|
CheckedLoadString(&title, IDS_MB_APP_NAME);
|
2014-11-04 00:26:53 +00:00
|
|
|
errMsg = "Cancelled.";
|
|
|
|
pMsgWnd->MessageBox(errMsg, title, MB_OK);
|
|
|
|
} 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
|
|
|
errMsg.Format(L"Failed while testing '%ls': %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetPathName(), NuStrError(nerr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSelEntry = pSelSet->IterNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* show success message */
|
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"Tested %d file%ls, no errors found.",
|
2014-11-04 00:26:53 +00:00
|
|
|
pSelSet->GetNumEntries(),
|
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
|
|
|
pSelSet->GetNumEntries() == 1 ? L"" : L"s");
|
2014-11-04 00:26:53 +00:00
|
|
|
pMsgWnd->MessageBox(errMsg);
|
|
|
|
retVal = true;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive -- delete files
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::DeleteSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
NufxEntry* pEntry;
|
|
|
|
CString errMsg;
|
|
|
|
bool retVal = false;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Deleting %d entries", pSelSet->GetNumEntries());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* mark entries for deletion */
|
|
|
|
SelectionEntry* pSelEntry = pSelSet->IterNext();
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pSelEntry != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry = (NufxEntry*) pSelEntry->GetEntry();
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Deleting %ld '%ls'", pEntry->GetRecordIdx(),
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetPathName());
|
|
|
|
nerr = NuDeleteRecord(fpArchive, pEntry->GetRecordIdx());
|
|
|
|
if (nerr != kNuErrNone) {
|
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 record %d: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetRecordIdx(), NuStrError(nerr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
pSelEntry = pSelSet->IterNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* actually do the delete */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
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 all files: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
|
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (InternalReload(fpMsgWnd) == kNuErrNone)
|
|
|
|
retVal = true;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive -- rename files
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::RenameSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
|
|
|
NuError nerr;
|
|
|
|
bool retVal = false;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Renaming %d entries", pSelSet->GetNumEntries());
|
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);
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Rename, fullpath=%d", renameFullPath);
|
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
|
|
|
NufxEntry* pEntry = (NufxEntry*) pSelEntry->GetEntry();
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Renaming '%ls'", pEntry->GetPathName());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
RenameEntryDialog renameDlg(pMsgWnd);
|
|
|
|
renameDlg.SetCanRenameFullPath(renameFullPath);
|
|
|
|
renameDlg.SetCanChangeFssep(true);
|
|
|
|
renameDlg.fOldName = pEntry->GetPathName();
|
|
|
|
renameDlg.fFssep = pEntry->GetFssep();
|
|
|
|
renameDlg.fpArchive = this;
|
|
|
|
renameDlg.fpEntry = pEntry;
|
|
|
|
|
|
|
|
int result = renameDlg.DoModal();
|
|
|
|
if (result == IDOK) {
|
|
|
|
if (renameDlg.fFssep == '\0')
|
|
|
|
renameDlg.fFssep = kNufxNoFssep;
|
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);
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuRename(fpArchive, pEntry->GetRecordIdx(),
|
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, renameDlg.fFssep);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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': %hs.", pEntry->GetPathName(),
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
break;
|
|
|
|
}
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Rename of '%ls' to '%ls' succeeded",
|
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
|
|
|
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 */
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Skipping rename of '%ls'", pEntry->GetDisplayName());
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pSelEntry = pSelSet->IterNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush pending rename calls */
|
|
|
|
{
|
|
|
|
CWaitCursor waitc;
|
|
|
|
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
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 all files: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
|
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reload GenericArchive from NufxLib */
|
|
|
|
if (InternalReload(fpMsgWnd) == kNuErrNone)
|
|
|
|
retVal = true;
|
|
|
|
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString NufxArchive::TestPathName(const GenericEntry* pGenericEntry,
|
2014-11-04 00:26:53 +00:00
|
|
|
const CString& basePath, const CString& newName, char newFssep) const
|
2007-03-27 17:47:10 +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
|
|
|
CString errMsg;
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pGenericEntry != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
ASSERT(basePath.IsEmpty());
|
|
|
|
|
|
|
|
/* can't start or end with fssep */
|
|
|
|
if (newName.Left(1) == newFssep || newName.Right(1) == newFssep) {
|
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"Names in NuFX archives may not start or end with a "
|
|
|
|
L"path separator character (%c).",
|
2014-11-04 00:26:53 +00:00
|
|
|
newFssep);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if it's a disk image, don't allow complex paths */
|
|
|
|
if (pGenericEntry->GetRecordKind() == GenericEntry::kRecordKindDisk) {
|
|
|
|
if (newName.Find(newFssep) != -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"Disk image names may not contain a path separator "
|
|
|
|
L"character (%c).",
|
2014-11-04 00:26:53 +00:00
|
|
|
newFssep);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test for case-sensitive name collisions. Each individual path
|
|
|
|
* component must be compared
|
|
|
|
*/
|
|
|
|
GenericEntry* pEntry;
|
|
|
|
pEntry = GetEntries();
|
2014-11-18 05:13:13 +00:00
|
|
|
while (pEntry != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
if (pEntry != pGenericEntry &&
|
|
|
|
ComparePaths(pEntry->GetPathName(), pEntry->GetFssep(),
|
|
|
|
newName, newFssep) == 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 = L"An entry with that name already exists.";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pEntry = pEntry->GetNext();
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return errMsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive -- recompress
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::RecompressSelection(CWnd* pMsgWnd, SelectionSet* pSelSet,
|
2014-11-04 00:26:53 +00:00
|
|
|
const RecompressOptionsDialog* pRecompOpts)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* We have to uncompress the files into memory and then recompress them.
|
|
|
|
* We don't want to flush after every file (too slow), but we can't wait
|
|
|
|
* until they're expanded (unbounded memory requirements). So we have
|
|
|
|
* to keep expanding until we reach a certain limit, then call flush to
|
|
|
|
* push the changes out.
|
|
|
|
*
|
|
|
|
* Since we're essentially making the changes in place (it's actually
|
|
|
|
* all getting routed through the temp file), we need to delete the thread
|
|
|
|
* and re-add it. This isn't quite as thorough as "launder", which
|
|
|
|
* actually reconstructs the entire record.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
const int kMaxSizeInMemory = 2 * 1024 * 1024; // 2MB
|
|
|
|
CString errMsg;
|
|
|
|
NuError nerr;
|
|
|
|
bool retVal = false;
|
|
|
|
|
|
|
|
/* set the compression type */
|
|
|
|
nerr = NuSetValue(fpArchive, kNuValueDataCompression,
|
|
|
|
pRecompOpts->fCompressionType + kNuCompressNone);
|
|
|
|
if (nerr != kNuErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("GLITCH: unable to set compression type to %d",
|
2014-11-04 00:26:53 +00:00
|
|
|
pRecompOpts->fCompressionType);
|
|
|
|
/* keep going */
|
|
|
|
}
|
|
|
|
|
|
|
|
fProgressAsRecompress = true;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop over all items in the selection set. Because the selection
|
|
|
|
* set has one entry for each interesting thread, we don't need to
|
|
|
|
* pry the NuRecord open and play with it.
|
|
|
|
*
|
|
|
|
* We should only be here for data forks, resource forks, and disk
|
|
|
|
* images. Comments and filenames are not compressed, and so cannot
|
|
|
|
* be recompressed.
|
|
|
|
*/
|
|
|
|
SelectionEntry* pSelEntry = pSelSet->IterNext();
|
|
|
|
long sizeInMemory = 0;
|
|
|
|
bool result = true;
|
2014-11-18 05:13:13 +00:00
|
|
|
NufxEntry* pEntry = NULL;
|
|
|
|
for ( ; pSelEntry != NULL; pSelEntry = pSelSet->IterNext()) {
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry = (NufxEntry*) pSelEntry->GetEntry();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compress each thread in turn.
|
|
|
|
*/
|
|
|
|
if (pEntry->GetHasDataFork()) {
|
|
|
|
result = RecompressThread(pEntry, GenericEntry::kDataThread,
|
|
|
|
pRecompOpts, &sizeInMemory, &errMsg);
|
|
|
|
if (!result)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pEntry->GetHasRsrcFork()) {
|
|
|
|
result = RecompressThread(pEntry, GenericEntry::kRsrcThread,
|
|
|
|
pRecompOpts, &sizeInMemory, &errMsg);
|
|
|
|
if (!result)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (pEntry->GetHasDiskImage()) {
|
|
|
|
result = RecompressThread(pEntry, GenericEntry::kDiskImageThread,
|
|
|
|
pRecompOpts, &sizeInMemory, &errMsg);
|
|
|
|
if (!result)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* don't do anything with comments */
|
|
|
|
|
|
|
|
/* if we're sitting on too much, push it out */
|
|
|
|
if (sizeInMemory > kMaxSizeInMemory) {
|
|
|
|
/* flush anything pending */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr != kNuErrAborted) {
|
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 recompress all files: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Cancelled out of sub-flush/compress");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
sizeInMemory = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* handle errors that threw us out of the while loop */
|
|
|
|
if (!result) {
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pEntry != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
CString dispStr;
|
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
|
|
|
dispStr.Format(L"Failed while recompressing '%ls': %ls.",
|
|
|
|
pEntry->GetDisplayName(), (LPCWSTR) errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* flush anything pending */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr != kNuErrAborted) {
|
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 recompress all files: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Cancelled out of flush/compress");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
} else {
|
|
|
|
retVal = true;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
/* abort anything that didn't get flushed */
|
|
|
|
NuAbort(fpArchive);
|
|
|
|
/* reload to pick up changes */
|
|
|
|
(void) InternalReload(pMsgWnd);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
fProgressAsRecompress = false;
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::RecompressThread(NufxEntry* pEntry, int threadKind,
|
2014-11-04 00:26:53 +00:00
|
|
|
const RecompressOptionsDialog* pRecompOpts, long* pSizeInMemory,
|
|
|
|
CString* pErrMsg)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuThread thread;
|
|
|
|
NuThreadID threadID;
|
|
|
|
NuError nerr;
|
2014-11-18 05:13:13 +00:00
|
|
|
NuDataSource* pSource = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
CString subErrMsg;
|
|
|
|
bool retVal = false;
|
2014-11-18 05:13:13 +00:00
|
|
|
char* buf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
long len = 0;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Recompressing %ld '%ls'", pEntry->GetRecordIdx(),
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetDisplayName());
|
|
|
|
|
|
|
|
/* get a copy of the thread header */
|
|
|
|
pEntry->FindThreadInfo(threadKind, &thread, pErrMsg);
|
|
|
|
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"Unable to locate thread for %ls (type %d)",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetDisplayName(), threadKind);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
threadID = NuGetThreadID(&thread);
|
|
|
|
|
|
|
|
/* if it's already in the target format, skip it */
|
|
|
|
if (thread.thThreadFormat == pRecompOpts->fCompressionType) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Skipping (fmt=%d) '%ls'",
|
2014-11-04 00:26:53 +00:00
|
|
|
pRecompOpts->fCompressionType, pEntry->GetDisplayName());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* extract the thread */
|
|
|
|
int result;
|
|
|
|
result = pEntry->ExtractThreadToBuffer(threadKind, &buf, &len, &subErrMsg);
|
|
|
|
if (result == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Cancelled during extract!");
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(buf == NULL);
|
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
|
|
|
pErrMsg->Format(L"Failed while extracting '%ls': %ls",
|
|
|
|
pEntry->GetDisplayName(), (LPCWSTR) subErrMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
*pSizeInMemory += len;
|
|
|
|
|
|
|
|
/* create a data source for it */
|
|
|
|
nerr = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
2014-11-21 02:10:18 +00:00
|
|
|
0, (const uint8_t*) buf, 0, len, ArrayDeleteHandler,
|
2014-11-04 00:26:53 +00:00
|
|
|
&pSource);
|
|
|
|
if (nerr != kNuErrNone) {
|
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"Unable to create NufxLib data source (len=%d).",
|
2014-11-04 00:26:53 +00:00
|
|
|
len);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
buf = NULL; // data source owns it now
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* delete the existing thread */
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("+++ DELETE threadIdx=%d", thread.threadIdx);
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuDeleteThread(fpArchive, thread.threadIdx);
|
|
|
|
if (nerr != kNuErrNone) {
|
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"Unable to delete thread %d: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetRecordIdx(), NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mark the new thread for addition */
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("+++ ADD threadID=0x%08lx", threadID);
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuAddThread(fpArchive, pEntry->GetRecordIdx(), threadID,
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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"Unable to add thread type %d: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
threadID, NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource = NULL; // now owned by nufxlib
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* at this point, we just wait for the flush in the outer loop */
|
|
|
|
retVal = true;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
NuFreeDataSource(pSource);
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive -- transfer files to another archive
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
GenericArchive::XferStatus NufxArchive::XferSelection(CWnd* pMsgWnd,
|
|
|
|
SelectionSet* pSelSet, ActionProgressDialog* pActionProgress,
|
|
|
|
const XferFileOptions* pXferOpts)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* We get one entry in the selection set per record.
|
|
|
|
*
|
|
|
|
* I think this now throws kXferCancelled whenever it's supposed to. Not
|
|
|
|
* 100% sure, but it looks good.
|
|
|
|
*/
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("NufxArchive XferSelection!");
|
2014-11-04 00:26:53 +00:00
|
|
|
XferStatus retval = kXferFailed;
|
2014-11-18 05:13:13 +00:00
|
|
|
unsigned char* dataBuf = NULL;
|
|
|
|
unsigned char* rsrcBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg, dispMsg;
|
|
|
|
|
|
|
|
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;
|
|
|
|
NufxEntry* pEntry = (NufxEntry*) pSelEntry->GetEntry();
|
|
|
|
FileDetails fileDetails;
|
|
|
|
CString errMsg;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(dataBuf == NULL);
|
|
|
|
ASSERT(rsrcBuf == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* in case we start handling CRC errors better */
|
|
|
|
if (pEntry->GetDamaged()) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" XFER skipping damaged entry '%ls'",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetDisplayName());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" XFER converting '%ls'", pEntry->GetDisplayName());
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
fileDetails.storageName = pEntry->GetDisplayName();
|
|
|
|
fileDetails.fileType = pEntry->GetFileType();
|
|
|
|
fileDetails.fileSysFmt = DiskImg::kFormatUnknown;
|
|
|
|
fileDetails.fileSysInfo = PathProposal::kDefaultStoredFssep;
|
|
|
|
fileDetails.access = pEntry->GetAccess();
|
|
|
|
fileDetails.extraType = pEntry->GetAuxType();
|
|
|
|
fileDetails.storageType = kNuStorageSeedling;
|
|
|
|
|
|
|
|
time_t when;
|
2014-11-18 05:13:13 +00:00
|
|
|
when = time(NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
UNIXTimeToDateTime(&when, &fileDetails.archiveWhen);
|
|
|
|
when = pEntry->GetModWhen();
|
|
|
|
UNIXTimeToDateTime(&when, &fileDetails.modWhen);
|
|
|
|
when = pEntry->GetCreateWhen();
|
|
|
|
UNIXTimeToDateTime(&when, &fileDetails.createWhen);
|
|
|
|
|
|
|
|
pActionProgress->SetArcName(fileDetails.storageName);
|
|
|
|
if (pActionProgress->SetProgress(0) == IDCANCEL) {
|
|
|
|
retval = kXferCancelled;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handle all relevant threads in this record. We assume it's either
|
|
|
|
* a data/rsrc pair or a disk image.
|
|
|
|
*/
|
|
|
|
if (pEntry->GetHasDataFork()) {
|
|
|
|
/*
|
|
|
|
* Found a data thread.
|
|
|
|
*/
|
|
|
|
int result;
|
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, &errMsg);
|
|
|
|
if (result == IDCANCEL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Cancelled during data extract!");
|
2014-11-04 00:26:53 +00:00
|
|
|
retval = kXferCancelled;
|
|
|
|
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
|
|
|
dispMsg.Format(L"Failed while extracting '%ls': %ls.",
|
|
|
|
pEntry->GetDisplayName(), (LPCWSTR) errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, dispMsg, 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);
|
|
|
|
|
|
|
|
} else if (pEntry->GetHasDiskImage()) {
|
|
|
|
/*
|
|
|
|
* No data thread found. Look for a disk image.
|
|
|
|
*/
|
|
|
|
int result;
|
2014-11-18 05:13:13 +00:00
|
|
|
dataBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
dataLen = 0;
|
|
|
|
result = pEntry->ExtractThreadToBuffer(GenericEntry::kDiskImageThread,
|
|
|
|
(char**) &dataBuf, &dataLen, &errMsg);
|
|
|
|
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
|
|
|
dispMsg.Format(L"Failed while extracting '%ls': %ls.",
|
|
|
|
pEntry->GetDisplayName(), (LPCWSTR) errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, dispMsg, 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if there's a resource fork in here (either by itself or
|
|
|
|
* with a data fork).
|
|
|
|
*/
|
|
|
|
if (pEntry->GetHasRsrcFork()) {
|
|
|
|
int result;
|
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, &errMsg);
|
|
|
|
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
|
|
|
dispMsg.Format(L"Failed while extracting '%ls': %ls.",
|
|
|
|
pEntry->GetDisplayName(), (LPCWSTR) errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, dispMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
fileDetails.storageType = kNuStorageExtended;
|
|
|
|
} else {
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(rsrcBuf == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dataLen < 0 && rsrcLen < 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" XFER: WARNING: nothing worth transferring in '%ls'",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetDisplayName());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
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.",
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = kXferOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
if (retval != kXferOK)
|
|
|
|
pXferOpts->fTarget->XferAbort(pMsgWnd);
|
|
|
|
else
|
|
|
|
pXferOpts->fTarget->XferFinish(pMsgWnd);
|
|
|
|
delete[] dataBuf;
|
|
|
|
delete[] rsrcBuf;
|
|
|
|
return retval;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxArchive::XferPrepare(const XferFileOptions* pXferOpts)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* We set the "allow duplicates" flag because DOS 3.3 volumes can have
|
|
|
|
* files with duplicate names.
|
|
|
|
*/
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" NufxArchive::XferPrepare");
|
2014-11-04 00:26:53 +00:00
|
|
|
(void) NuSetValue(fpArchive, kNuValueAllowDuplicates, true);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString NufxArchive::XferFile(FileDetails* pDetails, unsigned char** pDataBuf,
|
2014-11-04 00:26:53 +00:00
|
|
|
long dataLen, unsigned char** pRsrcBuf, long rsrcLen)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
const int kFileTypeTXT = 0x04;
|
2014-11-18 05:13:13 +00:00
|
|
|
NuDataSource* pSource = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" NufxArchive::XferFile '%ls'", (LPCWSTR) pDetails->storageName);
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGI(" dataBuf=0x%p dataLen=%ld rsrcBuf=0x%p rsrcLen=%ld",
|
2014-11-04 00:26:53 +00:00
|
|
|
*pDataBuf, dataLen, *pRsrcBuf, rsrcLen);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pDataBuf != NULL);
|
|
|
|
ASSERT(pRsrcBuf != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* NuFX doesn't explicitly store directories */
|
|
|
|
if (pDetails->entryKind == FileDetails::kFileKindDirectory) {
|
|
|
|
delete[] *pDataBuf;
|
|
|
|
delete[] *pRsrcBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
*pDataBuf = *pRsrcBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(dataLen >= 0 || rsrcLen >= 0);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(*pDataBuf != NULL || *pRsrcBuf != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* add the record; we have "allow duplicates" enabled for clashes */
|
|
|
|
NuRecordIdx recordIdx;
|
|
|
|
NuFileDetails nuFileDetails;
|
|
|
|
nuFileDetails = *pDetails;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Odd bit of trivia: NufxLib refuses to accept an fssep of '\0'. It
|
|
|
|
* really wants to have one. Which is annoying, since files coming
|
|
|
|
* from DOS or Pascal don't have one. We therefore need to supply
|
|
|
|
* one, so we provide 0xff on the theory that nobody in their right
|
|
|
|
* mind would have it in an Apple II filename.
|
|
|
|
*
|
|
|
|
* Since we don't strip Pascal and ProDOS names down when we load
|
|
|
|
* the disks, it's possible the for 0xff to occur if the disk got
|
|
|
|
* damaged. For ProDOS we don't care, since it has an fssep, but
|
|
|
|
* Pascal could be at risk. DOS and RDOS are sanitized and so should
|
|
|
|
* be okay.
|
|
|
|
*
|
|
|
|
* One issue: we don't currently allow changing the fssep when renaming
|
|
|
|
* a file. We need to fix this, or else there's no way to rename a
|
|
|
|
* file into a subdirectory once it has been pasted in this way.
|
|
|
|
*/
|
|
|
|
if (NuGetSepFromSysInfo(nuFileDetails.fileSysInfo) == 0) {
|
|
|
|
nuFileDetails.fileSysInfo =
|
|
|
|
NuSetSepInSysInfo(nuFileDetails.fileSysInfo, kNufxNoFssep);
|
|
|
|
}
|
|
|
|
|
|
|
|
nerr = NuAddRecord(fpArchive, &nuFileDetails, &recordIdx);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr != kNuErrAborted) {
|
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 adding record: %hs", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
//ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
|
|
|
// else the add was cancelled
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dataLen >= 0) {
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(*pDataBuf != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* strip the high ASCII from DOS and RDOS text files */
|
|
|
|
if (pDetails->entryKind != FileDetails::kFileKindDiskImage &&
|
|
|
|
pDetails->fileType == kFileTypeTXT &&
|
|
|
|
DiskImg::UsesDOSFileStructure(pDetails->fileSysFmt))
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Stripping high ASCII from '%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) pDetails->storageName);
|
2014-11-04 00:26:53 +00:00
|
|
|
unsigned char* ucp = *pDataBuf;
|
|
|
|
long len = dataLen;
|
|
|
|
|
|
|
|
while (len--)
|
|
|
|
*ucp++ &= 0x7f;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* create a data source for the data fork; might be zero len */
|
|
|
|
nerr = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, 0,
|
|
|
|
*pDataBuf, 0, dataLen, ArrayDeleteHandler, &pSource);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
errMsg = "Unable to create NufxLib data source.";
|
|
|
|
//ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
*pDataBuf = NULL; /* owned by data source */
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* add the data fork, as a disk image if appropriate */
|
|
|
|
NuThreadID targetID;
|
|
|
|
if (pDetails->entryKind == FileDetails::kFileKindDiskImage)
|
|
|
|
targetID = kNuThreadIDDiskImage;
|
|
|
|
else
|
|
|
|
targetID = kNuThreadIDDataFork;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
nerr = NuAddThread(fpArchive, recordIdx, targetID, pSource, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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 adding thread: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
//ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource = NULL; /* NufxLib owns it now */
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* add the resource fork, if one was provided */
|
|
|
|
if (rsrcLen >= 0) {
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(*pRsrcBuf != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
nerr = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed, 0,
|
|
|
|
*pRsrcBuf, 0, rsrcLen, ArrayDeleteHandler, &pSource);
|
|
|
|
if (nerr != kNuErrNone) {
|
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"Unable to create NufxLib data source.";
|
2014-11-04 00:26:53 +00:00
|
|
|
//ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
*pRsrcBuf = NULL; /* owned by data source */
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* add the data fork */
|
|
|
|
nerr = NuAddThread(fpArchive, recordIdx, kNuThreadIDRsrcFork,
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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 adding thread: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
//ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource = NULL; /* NufxLib owns it now */
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
NuFreeDataSource(pSource);
|
|
|
|
return errMsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxArchive::XferAbort(CWnd* pMsgWnd)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* Since we don't do any interim flushes, we can just call NuAbort. If that
|
|
|
|
* weren't the case, we would need to delete all records and flush.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
CString errMsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" NufxArchive::XferAbort");
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuAbort(fpArchive);
|
|
|
|
if (nerr != kNuErrNone) {
|
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 aborting procedure: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void NufxArchive::XferFinish(CWnd* pMsgWnd)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
CString errMsg;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" NufxArchive::XferFinish");
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* actually do the work */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr != kNuErrAborted) {
|
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 add file: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(fpMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
goto bail;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
(void) InternalReload(fpMsgWnd);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* NufxArchive -- add/update/delete comments
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extract a comment from the archive, converting line terminators to CRLF.
|
|
|
|
*
|
|
|
|
* Returns "true" on success, "false" on failure.
|
|
|
|
*/
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::GetComment(CWnd* pMsgWnd, const GenericEntry* pGenericEntry,
|
2014-11-04 00:26:53 +00:00
|
|
|
CString* pStr)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NufxEntry* pEntry = (NufxEntry*) pGenericEntry;
|
|
|
|
CString errMsg;
|
|
|
|
const char* kNewEOL = "\r\n";
|
|
|
|
int result;
|
|
|
|
char* buf;
|
|
|
|
long len;
|
|
|
|
|
|
|
|
ASSERT(pGenericEntry->GetHasComment());
|
|
|
|
|
|
|
|
/* use standard extract function to pull comment out */
|
2014-11-18 05:13:13 +00:00
|
|
|
buf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
len = 0;
|
|
|
|
result = pEntry->ExtractThreadToBuffer(GenericEntry::kCommentThread,
|
|
|
|
&buf, &len, &errMsg);
|
|
|
|
if (result != IDOK) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Failed getting comment: %hs", buf);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(buf == NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* convert EOL and add '\0' */
|
|
|
|
CString convStr;
|
|
|
|
const char* ccp;
|
|
|
|
|
|
|
|
ccp = buf;
|
|
|
|
while (len-- && *ccp != '\0') {
|
|
|
|
if (len > 1 && *ccp == '\r' && *(ccp+1) == '\n') {
|
|
|
|
ccp++;
|
|
|
|
len--;
|
|
|
|
convStr += kNewEOL;
|
|
|
|
} else if (*ccp == '\r' || *ccp == '\n') {
|
|
|
|
convStr += kNewEOL;
|
|
|
|
} else {
|
|
|
|
convStr += *ccp;
|
|
|
|
}
|
|
|
|
ccp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pStr = convStr;
|
|
|
|
delete[] buf;
|
|
|
|
return true;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::SetComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry,
|
2014-11-04 00:26:53 +00:00
|
|
|
const CString& str)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* Set the comment. This requires either adding a new comment or updating
|
|
|
|
* an existing one. The latter is constrained by the maximum size of the
|
|
|
|
* comment buffer.
|
|
|
|
*
|
|
|
|
* We want to update in place whenever possible because it's faster (don't
|
|
|
|
* have to rewrite the entire archive), but that really only holds for new
|
|
|
|
* archives or if we foolishly set the kNuValueModifyOrig flag.
|
|
|
|
*
|
|
|
|
* Cleanest approach is to delete the existing thread and add a new one.
|
|
|
|
* If somebody complains we can try to be smarter about it.
|
|
|
|
*/
|
2014-11-18 05:13:13 +00:00
|
|
|
NuDataSource* pSource = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
NufxEntry* pEntry = (NufxEntry*) pGenericEntry;
|
|
|
|
NuError nerr;
|
|
|
|
bool retVal = false;
|
|
|
|
|
|
|
|
/* convert CRLF to CR */
|
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 newStr(str);
|
2014-11-04 00:26:53 +00:00
|
|
|
char* srcp;
|
|
|
|
char* dstp;
|
|
|
|
srcp = dstp = newStr.GetBuffer(0);
|
|
|
|
while (*srcp != '\0') {
|
|
|
|
if (*srcp == '\r' && *(srcp+1) == '\n') {
|
|
|
|
srcp++;
|
|
|
|
*dstp = '\r';
|
|
|
|
} else {
|
|
|
|
*dstp = *srcp;
|
|
|
|
}
|
|
|
|
srcp++;
|
|
|
|
dstp++;
|
|
|
|
}
|
|
|
|
*dstp = '\0';
|
|
|
|
newStr.ReleaseBuffer();
|
|
|
|
|
|
|
|
/* get the thread info */
|
|
|
|
CString errMsg;
|
|
|
|
NuThread thread;
|
|
|
|
NuThreadIdx threadIdx;
|
|
|
|
|
|
|
|
pEntry->FindThreadInfo(GenericEntry::kCommentThread, &thread, &errMsg);
|
|
|
|
threadIdx = thread.threadIdx;
|
|
|
|
if (errMsg.IsEmpty()) {
|
|
|
|
/* delete existing thread */
|
|
|
|
nerr = NuDeleteThread(fpArchive, threadIdx);
|
|
|
|
if (nerr != kNuErrNone) {
|
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 thread: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set a maximum pre-size value for the thread */
|
|
|
|
long maxLen;
|
|
|
|
maxLen = ((newStr.GetLength() + 99) / 100) * 100;
|
|
|
|
if (maxLen < 200)
|
|
|
|
maxLen = 200;
|
|
|
|
|
|
|
|
|
|
|
|
/* create a data source to write from */
|
|
|
|
nerr = NuCreateDataSourceForBuffer(kNuThreadFormatUncompressed,
|
2014-11-21 02:10:18 +00:00
|
|
|
maxLen, (const uint8_t*)(LPCSTR) newStr, 0,
|
2014-11-18 05:13:13 +00:00
|
|
|
newStr.GetLength(), NULL, &pSource);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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 NufxLib data source (len=%d, maxLen=%d).",
|
2014-11-04 00:26:53 +00:00
|
|
|
newStr.GetLength(), maxLen);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add the new thread */
|
|
|
|
nerr = NuAddThread(fpArchive, pEntry->GetRecordIdx(),
|
2014-11-18 05:13:13 +00:00
|
|
|
kNuThreadIDComment, pSource, NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (nerr != kNuErrNone) {
|
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 add comment thread: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
2014-11-18 05:13:13 +00:00
|
|
|
pSource = NULL; // nufxlib owns it now
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* flush changes */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
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 flush comment changes: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reload GenericArchive from NufxLib */
|
|
|
|
if (InternalReload(fpMsgWnd) == kNuErrNone)
|
|
|
|
retVal = true;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
NuFreeDataSource(pSource);
|
|
|
|
if (!retVal) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("FAILED: %ls", (LPCWSTR) errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
NuAbort(fpArchive);
|
|
|
|
}
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::DeleteComment(CWnd* pMsgWnd, GenericEntry* pGenericEntry)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString errMsg;
|
|
|
|
NuError nerr;
|
|
|
|
NufxEntry* pEntry = (NufxEntry*) pGenericEntry;
|
|
|
|
NuThread thread;
|
|
|
|
NuThreadIdx threadIdx;
|
|
|
|
bool retVal = false;
|
|
|
|
|
|
|
|
pEntry->FindThreadInfo(GenericEntry::kCommentThread, &thread, &errMsg);
|
|
|
|
if (!errMsg.IsEmpty())
|
|
|
|
goto bail;
|
|
|
|
threadIdx = thread.threadIdx;
|
|
|
|
|
|
|
|
nerr = NuDeleteThread(fpArchive, threadIdx);
|
|
|
|
if (nerr != kNuErrNone) {
|
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 thread: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* flush changes */
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
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 flush comment deletion: %hs.",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reload GenericArchive from NufxLib */
|
|
|
|
if (InternalReload(pMsgWnd) == kNuErrNone)
|
|
|
|
retVal = true;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
if (retVal != 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("FAILED: %ls", (LPCWSTR) errMsg);
|
2014-11-04 00:26:53 +00:00
|
|
|
NuAbort(fpArchive);
|
|
|
|
}
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool NufxArchive::SetProps(CWnd* pMsgWnd, GenericEntry* pEntry,
|
2014-11-04 00:26:53 +00:00
|
|
|
const FileProps* pProps)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-21 21:18:20 +00:00
|
|
|
/*
|
|
|
|
* Sets file properties via the NuSetRecordAttr call.
|
|
|
|
*
|
|
|
|
* Gets the existing properties, copies the fields from FileProps over, and
|
|
|
|
* sets them. [currently only supports file type, aux type, and access flags]
|
|
|
|
*
|
|
|
|
* Technically we should reload the GenericArchive from the NufxArchive,
|
|
|
|
* but the set of changes is pretty small, so we just make them here.
|
|
|
|
*/
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
NufxEntry* pNufxEntry = (NufxEntry*) pEntry;
|
|
|
|
const NuRecord* pRecord;
|
|
|
|
NuRecordAttr recordAttr;
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" SET fileType=0x%02x auxType=0x%04x access=0x%02x",
|
2014-11-04 00:26:53 +00:00
|
|
|
pProps->fileType, pProps->auxType, pProps->access);
|
|
|
|
|
|
|
|
nerr = NuGetRecord(fpArchive, pNufxEntry->GetRecordIdx(), &pRecord);
|
|
|
|
if (nerr != kNuErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("ERROR: couldn't find recordIdx %ld: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
pNufxEntry->GetRecordIdx(), NuStrError(nerr));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
NuRecordCopyAttr(&recordAttr, pRecord);
|
|
|
|
recordAttr.fileType = pProps->fileType;
|
|
|
|
recordAttr.extraType = pProps->auxType;
|
|
|
|
recordAttr.access = pProps->access;
|
|
|
|
|
|
|
|
nerr = NuSetRecordAttr(fpArchive, pNufxEntry->GetRecordIdx(), &recordAttr);
|
|
|
|
if (nerr != kNuErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("ERROR: couldn't set recordAttr %ld: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
pNufxEntry->GetRecordIdx(), NuStrError(nerr));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-01-04 19:29:51 +00:00
|
|
|
uint32_t statusFlags;
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = NuFlush(fpArchive, &statusFlags);
|
|
|
|
if (nerr != kNuErrNone) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("ERROR: NuFlush failed: %hs", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* see if it got converted to read-only status */
|
|
|
|
if (statusFlags & kNuFlushReadOnly)
|
|
|
|
fIsReadOnly = true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Props set");
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* do this in lieu of reloading GenericArchive */
|
|
|
|
pEntry->SetFileType(pProps->fileType);
|
|
|
|
pEntry->SetAuxType(pProps->auxType);
|
|
|
|
pEntry->SetAccess(pProps->access);
|
|
|
|
|
|
|
|
return true;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|