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.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* AppleLink Compression Utility file support.
|
|
|
|
*
|
|
|
|
* This was adapted from the Binary II support, which has a mixed history,
|
|
|
|
* so this is a little scrambled in spots.
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ACUArchive.h"
|
2014-11-04 00:26:53 +00:00
|
|
|
#include "NufxArchive.h" // uses NuError
|
2007-03-27 17:47:10 +00:00
|
|
|
#include "Preferences.h"
|
|
|
|
#include "Main.h"
|
|
|
|
#include "Squeeze.h"
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
/*
|
2014-11-04 00:26:53 +00:00
|
|
|
+00 2b Number of items in archive
|
|
|
|
+02 2b 0100
|
|
|
|
+04 5b "fZink"
|
|
|
|
+09 11b 0136 0000 0000 0000 0000 dd
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
+14
|
|
|
|
|
|
|
|
+00 1b ?? 00
|
|
|
|
+01 1b Compression type, 00=none, 03=sq
|
|
|
|
+02 2b ?? 0000 0000 0000 0000
|
|
|
|
+04 2b ?? 0a74 961f 7d85 af2c 2775 <- 0000 for dir (checksum?)
|
|
|
|
+06 2b ?? 0000 0000 0000 0000
|
|
|
|
+08 2b ?? 0000 0000 0000 0000
|
|
|
|
+0a 2b Storage size (in 512-byte blocks)
|
|
|
|
+0c 6b ?? 000000 000000 000000 000000
|
|
|
|
+12 4b Length of file in this archive (compressed or uncompressed)
|
|
|
|
+16 2b ProDOS file permissions
|
|
|
|
+18 2b ProDOS file type
|
|
|
|
+1a 4b ProDOS aux type
|
|
|
|
+1e ?? 0000
|
|
|
|
+20 1b ProDOS storage type (usually 02, 0d for dirs)
|
|
|
|
+21 ?? 00
|
|
|
|
+22 ?? 0000 0000
|
|
|
|
+26 4b Uncompressed file len
|
|
|
|
+2a 2b ProDOS date (create?)
|
|
|
|
+2c 2b ProDOS time
|
|
|
|
+2e 2b ProDOS date (mod?)
|
|
|
|
+30 2b ProDOS time
|
|
|
|
+32 2b Filename len
|
|
|
|
+34 2b ?? ac4a 2d02 for dir <- header checksum?
|
|
|
|
+36 FL Filename
|
|
|
|
+xx data start (dir has no data)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* AcuEntry
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int AcuEntry::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;
|
|
|
|
ExpandBuffer expBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
char* dataBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
long len;
|
|
|
|
bool needAlloc = true;
|
|
|
|
int result = -1;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fpArchive != NULL);
|
|
|
|
ASSERT(fpArchive->fFp != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (*ppText != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
needAlloc = false;
|
|
|
|
|
|
|
|
if (which != kDataThread) {
|
|
|
|
*pErrMsg = "No such fork";
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = (long) GetUncompressedLen();
|
|
|
|
if (len == 0) {
|
|
|
|
if (needAlloc) {
|
|
|
|
*ppText = new char[1];
|
|
|
|
**ppText = '\0';
|
|
|
|
}
|
|
|
|
*pLength = 0;
|
|
|
|
result = IDOK;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_PROGRESS_BEGIN();
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
if (fseek(fpArchive->fFp, fOffset, SEEK_SET) < 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
|
|
|
pErrMsg->Format(L"Unable to seek to offset %ld: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
fOffset, strerror(errno));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetSqueezed()) {
|
|
|
|
nerr = UnSqueeze(fpArchive->fFp, (unsigned long) GetCompressedLen(),
|
|
|
|
&expBuf, false, 0);
|
|
|
|
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"File read failed: %hs", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
char* unsqBuf = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
long unsqLen = 0;
|
|
|
|
expBuf.SeizeBuffer(&unsqBuf, &unsqLen);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Unsqueezed %ld bytes to %d",
|
2014-11-04 00:26:53 +00:00
|
|
|
(unsigned long) GetCompressedLen(), unsqLen);
|
|
|
|
if (unsqLen == 0) {
|
|
|
|
// some bonehead squeezed a zero-length file
|
|
|
|
delete[] unsqBuf;
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(*ppText == NULL);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Handling zero-length squeezed file!");
|
2014-11-04 00:26:53 +00:00
|
|
|
if (needAlloc) {
|
|
|
|
*ppText = new char[1];
|
|
|
|
**ppText = '\0';
|
|
|
|
}
|
|
|
|
*pLength = 0;
|
|
|
|
} else {
|
|
|
|
if (needAlloc) {
|
|
|
|
/* just use the seized buffer */
|
|
|
|
*ppText = unsqBuf;
|
|
|
|
*pLength = unsqLen;
|
|
|
|
} else {
|
|
|
|
if (*pLength < unsqLen) {
|
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, unsqLen);
|
|
|
|
delete[] unsqBuf;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(*ppText, unsqBuf, unsqLen);
|
|
|
|
delete[] unsqBuf;
|
|
|
|
*pLength = unsqLen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (needAlloc) {
|
|
|
|
dataBuf = new char[len];
|
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", len);
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (*pLength < (long) len) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pErrMsg->Format(L"buf size %ld too short (%ld)",
|
2014-11-04 00:26:53 +00:00
|
|
|
*pLength, len);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
dataBuf = *ppText;
|
|
|
|
}
|
|
|
|
if (fread(dataBuf, len, 1, fpArchive->fFp) != 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
|
|
|
pErrMsg->Format(L"File read failed: %hs", strerror(errno));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (needAlloc)
|
|
|
|
*ppText = dataBuf;
|
|
|
|
*pLength = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int AcuEntry::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-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
long len;
|
|
|
|
int result = -1;
|
|
|
|
|
|
|
|
ASSERT(IDOK != -1 && IDCANCEL != -1);
|
|
|
|
if (which != kDataThread) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pErrMsg = L"No such fork";
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = (long) GetUncompressedLen();
|
|
|
|
if (len == 0) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Empty fork");
|
2014-11-04 00:26:53 +00:00
|
|
|
result = IDOK;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
if (fseek(fpArchive->fFp, fOffset, SEEK_SET) < 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
|
|
|
pErrMsg->Format(L"Unable to seek to offset %ld: %hs",
|
2014-11-04 00:26:53 +00:00
|
|
|
fOffset, strerror(errno));
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
SET_PROGRESS_BEGIN();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Generally speaking, anything in a BNY file is going to be small. The
|
|
|
|
* major exception is a BXY file, which could be huge. However, the
|
|
|
|
* SHK embedded in a BXY is never squeezed.
|
|
|
|
*
|
|
|
|
* To make life easy, we either unsqueeze the entire thing into a buffer
|
|
|
|
* and then write that, or we do a file-to-file copy of the specified
|
|
|
|
* number of bytes.
|
|
|
|
*/
|
|
|
|
if (GetSqueezed()) {
|
|
|
|
ExpandBuffer expBuf;
|
|
|
|
bool lastCR = false;
|
|
|
|
char* buf;
|
|
|
|
long uncLen;
|
|
|
|
|
|
|
|
nerr = UnSqueeze(fpArchive->fFp, (unsigned long) GetCompressedLen(),
|
|
|
|
&expBuf, false, 0);
|
|
|
|
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"File read failed: %hs", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
expBuf.SeizeBuffer(&buf, &uncLen);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Unsqueezed %ld bytes to %d", len, uncLen);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
// some bonehead squeezed a zero-length file
|
|
|
|
if (uncLen == 0) {
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(buf == NULL);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Handling zero-length squeezed file!");
|
2014-11-04 00:26:53 +00:00
|
|
|
result = IDOK;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
int err = GenericEntry::WriteConvert(outfp, buf, uncLen, &conv,
|
|
|
|
&convHA, &lastCR);
|
|
|
|
if (err != 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pErrMsg->Format(L"File write failed: %hs", strerror(err));
|
2014-11-04 00:26:53 +00:00
|
|
|
delete[] buf;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] buf;
|
|
|
|
} else {
|
|
|
|
nerr = CopyData(outfp, conv, convHA, pErrMsg);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (pErrMsg->IsEmpty()) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pErrMsg->Format(L"Failed while copying data: %hs\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
NuStrError(nerr));
|
|
|
|
}
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result = IDOK;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
SET_PROGRESS_END();
|
|
|
|
return result;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError AcuEntry::CopyData(FILE* outfp, ConvertEOL conv, ConvertHighASCII convHA,
|
2014-11-04 00:26:53 +00:00
|
|
|
CString* pMsg) const
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr = kNuErrNone;
|
|
|
|
const int kChunkSize = 8192;
|
|
|
|
char buf[kChunkSize];
|
|
|
|
bool lastCR = false;
|
|
|
|
long srcLen, dataRem;
|
|
|
|
|
|
|
|
srcLen = (long) GetUncompressedLen();
|
|
|
|
ASSERT(srcLen > 0); // empty files should've been caught earlier
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop until all data copied.
|
|
|
|
*/
|
|
|
|
dataRem = srcLen;
|
|
|
|
while (dataRem) {
|
|
|
|
int chunkLen;
|
|
|
|
|
|
|
|
if (dataRem > kChunkSize)
|
|
|
|
chunkLen = kChunkSize;
|
|
|
|
else
|
|
|
|
chunkLen = dataRem;
|
|
|
|
|
|
|
|
/* read a chunk from the source file */
|
|
|
|
nerr = fpArchive->AcuRead(buf, chunkLen);
|
|
|
|
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
|
|
|
pMsg->Format(L"File read failed: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write chunk to destination file */
|
|
|
|
int err = GenericEntry::WriteConvert(outfp, buf, chunkLen, &conv,
|
|
|
|
&convHA, &lastCR);
|
|
|
|
if (err != 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pMsg->Format(L"File write failed: %hs.", strerror(err));
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = kNuErrGeneric;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dataRem -= chunkLen;
|
|
|
|
SET_PROGRESS_UPDATE(ComputePercent(srcLen - dataRem, srcLen));
|
|
|
|
}
|
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
|
|
|
NuError AcuEntry::TestEntry(CWnd* pMsgWnd)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr = kNuErrNone;
|
|
|
|
CString errMsg;
|
|
|
|
long len;
|
|
|
|
int result = -1;
|
|
|
|
|
|
|
|
len = (long) GetUncompressedLen();
|
|
|
|
if (len == 0)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
if (fseek(fpArchive->fFp, fOffset, SEEK_SET) < 0) {
|
|
|
|
nerr = kNuErrGeneric;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to seek to offset %ld: %hs\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
fOffset, strerror(errno));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetSqueezed()) {
|
|
|
|
nerr = UnSqueeze(fpArchive->fFp, (unsigned long) GetCompressedLen(),
|
2014-11-18 05:13:13 +00:00
|
|
|
NULL, false, 0);
|
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"Unsqueeze failed: %hs.", NuStrError(nerr));
|
2014-11-04 00:26:53 +00:00
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
errno = 0;
|
|
|
|
if (fseek(fpArchive->fFp, fOffset + len, SEEK_SET) < 0) {
|
|
|
|
nerr = kNuErrGeneric;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to seek to offset %ld (file truncated?): %hs\n",
|
2014-11-04 00:26:53 +00:00
|
|
|
fOffset, strerror(errno));
|
|
|
|
ShowFailureMsg(pMsgWnd, errMsg, IDS_FAILED);
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SET_PROGRESS_UPDATE(100) == IDCANCEL)
|
|
|
|
nerr = kNuErrAborted;
|
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-04 00:26:53 +00:00
|
|
|
* AcuArchive
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
/*static*/ CString AcuArchive::AppInit(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
return "";
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
GenericArchive::OpenResult AcuArchive::Open(const WCHAR* filename,
|
|
|
|
bool readOnly, CString* pErrMsg)
|
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
|
|
|
fIsReadOnly = true; // ignore "readOnly"
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
errno = 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
|
|
|
fFp = _wfopen(filename, L"rb");
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fFp == NULL) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Unable to open %ls: %hs.", filename, strerror(errno));
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
|
|
|
CWaitCursor waitc;
|
|
|
|
int result;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
result = LoadContents();
|
|
|
|
if (result < 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"The file is not an ACU archive.");
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
} else if (result > 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
errMsg.Format(L"Failed while reading data from ACU archive.");
|
2014-11-04 00:26:53 +00:00
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
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 AcuArchive::New(const WCHAR* /*filename*/, const void* /*options*/)
|
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
|
|
|
return L"Sorry, AppleLink Compression Utility files can't be created.";
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
long AcuArchive::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 false;
|
|
|
|
break;
|
|
|
|
case kCapCanAddDisk:
|
|
|
|
return false;
|
|
|
|
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
|
|
|
int AcuArchive::LoadContents(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
int numEntries;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fFp != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
rewind(fFp);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/*
|
|
|
|
* Read the master header. In an ACU file this holds the number of
|
|
|
|
* files and a bunch of stuff that doesn't seem to change.
|
|
|
|
*/
|
|
|
|
if (ReadMasterHeader(&numEntries) != 0)
|
|
|
|
return -1;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
while (numEntries) {
|
|
|
|
AcuFileEntry fileEntry;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
nerr = ReadFileHeader(&fileEntry);
|
|
|
|
if (nerr != kNuErrNone)
|
|
|
|
return 1;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (CreateEntry(&fileEntry) != 0)
|
|
|
|
return 1;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* if file isn't empty, seek past it */
|
|
|
|
if (fileEntry.dataStorageLen) {
|
|
|
|
nerr = AcuSeek(fileEntry.dataStorageLen);
|
|
|
|
if (nerr != kNuErrNone)
|
|
|
|
return 1;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
numEntries--;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
CString AcuArchive::Reload(void)
|
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
|
|
|
|
|
|
|
|
DeleteEntries();
|
|
|
|
if (LoadContents() != 0) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
return L"Reload failed.";
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int AcuArchive::ReadMasterHeader(int* pNumEntries)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
AcuMasterHeader header;
|
|
|
|
unsigned char buf[kAcuMasterHeaderLen];
|
|
|
|
NuError nerr;
|
|
|
|
|
|
|
|
nerr = AcuRead(buf, kAcuMasterHeaderLen);
|
|
|
|
if (nerr != kNuErrNone)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
header.fileCount = buf[0x00] | buf[0x01] << 8;
|
|
|
|
header.unknown1 = buf[0x02] | buf[0x03] << 8;
|
|
|
|
memcpy(header.fZink, &buf[0x04], 5);
|
|
|
|
header.fZink[5] = '\0';
|
|
|
|
memcpy(header.unknown2, &buf[0x09], 11);
|
|
|
|
|
|
|
|
if (header.fileCount == 0 ||
|
|
|
|
header.unknown1 != 1 ||
|
|
|
|
strcmp((char*) header.fZink, "fZink") != 0)
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Not an ACU archive");
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Looks like an ACU archive with %d entries", header.fileCount);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
*pNumEntries = header.fileCount;
|
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError AcuArchive::ReadFileHeader(AcuFileEntry* pEntry)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError err = kNuErrNone;
|
|
|
|
unsigned char buf[kAcuEntryHeaderLen];
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pEntry != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
err = AcuRead(buf, kAcuEntryHeaderLen);
|
|
|
|
if (err != kNuErrNone)
|
|
|
|
goto bail;
|
|
|
|
|
|
|
|
// unknown at 00
|
|
|
|
pEntry->compressionType = buf[0x01];
|
|
|
|
// unknown at 02-03
|
|
|
|
pEntry->dataChecksum = buf[0x04] | buf[0x05] << 8; // not sure
|
|
|
|
// unknown at 06-09
|
|
|
|
pEntry->blockCount = buf[0x0a] | buf[0x0b] << 8;
|
|
|
|
// unknown at 0c-11
|
|
|
|
pEntry->dataStorageLen = buf[0x12] | buf [0x13] << 8 | buf[0x14] << 16 |
|
|
|
|
buf[0x15] << 24;
|
|
|
|
pEntry->access = buf[0x16] | buf[0x17] << 8;
|
|
|
|
pEntry->fileType = buf[0x18] | buf[0x19] << 8;
|
|
|
|
pEntry->auxType = buf[0x1a] | buf[0x1b] << 8;
|
|
|
|
// unknown at 1e-1f
|
|
|
|
pEntry->storageType = buf[0x20];
|
|
|
|
// unknown at 21-25
|
|
|
|
pEntry->dataEof = buf[0x26] | buf[0x27] << 8 | buf[0x28] << 16 |
|
|
|
|
buf[0x29] << 24;
|
|
|
|
pEntry->prodosModDate = buf[0x2a] | buf[0x2b] << 8;
|
|
|
|
pEntry->prodosModTime = buf[0x2c] | buf[0x2d] << 8;
|
|
|
|
AcuConvertDateTime(pEntry->prodosModDate, pEntry->prodosModTime,
|
|
|
|
&pEntry->modWhen);
|
|
|
|
pEntry->prodosCreateDate = buf[0x2e] | buf[0x2f] << 8;
|
|
|
|
pEntry->prodosCreateTime = buf[0x30] | buf[0x31] << 8;
|
|
|
|
AcuConvertDateTime(pEntry->prodosCreateDate, pEntry->prodosCreateTime,
|
|
|
|
&pEntry->createWhen);
|
|
|
|
pEntry->fileNameLen = buf[0x32] | buf[0x33] << 8;
|
|
|
|
pEntry->headerChecksum = buf[0x34] | buf[0x35] << 8; // not sure
|
|
|
|
|
|
|
|
/* read the filename */
|
|
|
|
if (pEntry->fileNameLen > kAcuMaxFileName) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("GLITCH: filename is too long (%d bytes)",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->fileNameLen);
|
|
|
|
err = kNuErrGeneric;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
if (!pEntry->fileNameLen) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("GLITCH: filename missing");
|
2014-11-04 00:26:53 +00:00
|
|
|
err = kNuErrGeneric;
|
|
|
|
goto bail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't know if this is possible or not */
|
|
|
|
if (pEntry->storageType == 5) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("HEY: EXTENDED FILE");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = AcuRead(pEntry->fileName, pEntry->fileNameLen);
|
|
|
|
if (err != kNuErrNone)
|
|
|
|
goto bail;
|
|
|
|
pEntry->fileName[pEntry->fileNameLen] = '\0';
|
|
|
|
|
|
|
|
//DumpFileHeader(pEntry);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
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 AcuArchive::DumpFileHeader(const AcuFileEntry* pEntry)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
time_t createWhen, modWhen;
|
|
|
|
CString createStr, modStr;
|
|
|
|
|
|
|
|
createWhen = NufxArchive::DateTimeToSeconds(&pEntry->createWhen);
|
|
|
|
modWhen = NufxArchive::DateTimeToSeconds(&pEntry->modWhen);
|
|
|
|
FormatDate(createWhen, &createStr);
|
|
|
|
FormatDate(modWhen, &modStr);
|
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" Header for file '%hs':", pEntry->fileName);
|
|
|
|
LOGI(" dataStorageLen=%d eof=%d blockCount=%d checksum=0x%04x",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->dataStorageLen, pEntry->dataEof, pEntry->blockCount,
|
|
|
|
pEntry->dataChecksum);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" fileType=0x%02x auxType=0x%04x storageType=0x%02x access=0x%04x",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->fileType, pEntry->auxType, pEntry->storageType, pEntry->access);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" created %ls, modified %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) createStr, (LPCWSTR) modStr);
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" fileNameLen=%d headerChecksum=0x%04x",
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->fileNameLen, pEntry->headerChecksum);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
int AcuArchive::CreateEntry(const AcuFileEntry* pEntry)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
const int kAcuFssep = '/';
|
|
|
|
NuError err = kNuErrNone;
|
|
|
|
AcuEntry* pNewEntry;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create the new entry.
|
|
|
|
*/
|
|
|
|
pNewEntry = new AcuEntry(this);
|
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 fileName(pEntry->fileName);
|
|
|
|
pNewEntry->SetPathName(fileName);
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewEntry->SetFssep(kAcuFssep);
|
|
|
|
pNewEntry->SetFileType(pEntry->fileType);
|
|
|
|
pNewEntry->SetAuxType(pEntry->auxType);
|
|
|
|
pNewEntry->SetAccess(pEntry->access);
|
|
|
|
pNewEntry->SetCreateWhen(NufxArchive::DateTimeToSeconds(&pEntry->createWhen));
|
|
|
|
pNewEntry->SetModWhen(NufxArchive::DateTimeToSeconds(&pEntry->modWhen));
|
|
|
|
|
|
|
|
/* always ProDOS? */
|
|
|
|
pNewEntry->SetSourceFS(DiskImg::kFormatProDOS);
|
|
|
|
|
|
|
|
pNewEntry->SetHasDataFork(true);
|
|
|
|
pNewEntry->SetHasRsrcFork(false); // ?
|
|
|
|
if (IsDir(pEntry)) {
|
|
|
|
pNewEntry->SetRecordKind(GenericEntry::kRecordKindDirectory);
|
|
|
|
} else {
|
|
|
|
pNewEntry->SetRecordKind(GenericEntry::kRecordKindFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
pNewEntry->SetCompressedLen(pEntry->dataStorageLen);
|
|
|
|
pNewEntry->SetDataForkLen(pEntry->dataEof);
|
|
|
|
|
|
|
|
if (pEntry->compressionType == kAcuCompNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"Uncompr");
|
2014-11-04 00:26:53 +00:00
|
|
|
} else if (pEntry->compressionType == kAcuCompSqueeze) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pNewEntry->SetFormatStr(L"Squeeze");
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewEntry->SetSqueezed(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
|
|
|
pNewEntry->SetFormatStr(L"(unknown)");
|
2014-11-04 00:26:53 +00:00
|
|
|
pNewEntry->SetSqueezed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
pNewEntry->SetOffset(ftell(fFp));
|
|
|
|
|
|
|
|
AddEntry(pNewEntry);
|
|
|
|
|
|
|
|
return err;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* ACU functions
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool AcuArchive::IsDir(const AcuFileEntry* pEntry)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
return (pEntry->storageType == 0x0d);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError AcuArchive::AcuRead(void* buf, size_t nbyte)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
size_t result;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(buf != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(nbyte > 0);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fFp != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
errno = 0;
|
|
|
|
result = fread(buf, 1, nbyte, fFp);
|
|
|
|
if (result != nbyte)
|
|
|
|
return errno ? (NuError)errno : kNuErrFileRead;
|
|
|
|
return kNuErrNone;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
NuError AcuArchive::AcuSeek(long offset)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fFp != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(offset > 0);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/*DBUG(("--- seeking forward %ld bytes\n", offset));*/
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (fseek(fFp, offset, SEEK_CUR) < 0)
|
|
|
|
return kNuErrFileSeek;
|
|
|
|
|
|
|
|
return kNuErrNone;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
void AcuArchive::AcuConvertDateTime(uint16_t prodosDate,
|
|
|
|
uint16_t prodosTime, NuDateTime* pWhen)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
pWhen->second = 0;
|
|
|
|
pWhen->minute = prodosTime & 0x3f;
|
|
|
|
pWhen->hour = (prodosTime >> 8) & 0x1f;
|
|
|
|
pWhen->day = (prodosDate & 0x1f) -1;
|
|
|
|
pWhen->month = ((prodosDate >> 5) & 0x0f) -1;
|
|
|
|
pWhen->year = (prodosDate >> 9) & 0x7f;
|
|
|
|
if (pWhen->year < 40)
|
|
|
|
pWhen->year += 100; /* P8 uses 0-39 for 2000-2039 */
|
|
|
|
pWhen->extra = 0;
|
|
|
|
pWhen->weekDay = 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* AcuArchive -- test files
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-21 21:18:20 +00:00
|
|
|
bool AcuArchive::TestSelection(CWnd* pMsgWnd, SelectionSet* pSelSet)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
NuError nerr;
|
|
|
|
AcuEntry* pEntry;
|
|
|
|
CString errMsg;
|
|
|
|
bool retVal = false;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(fFp != 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 = (AcuEntry*) pSelEntry->GetEntry();
|
|
|
|
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGI(" Testing '%ls' (offset=%ld)", pEntry->GetDisplayName(),
|
2014-11-04 00:26:53 +00:00
|
|
|
pEntry->GetOffset());
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
SET_PROGRESS_UPDATE2(0, pEntry->GetDisplayName(), NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
nerr = pEntry->TestEntry(pMsgWnd);
|
|
|
|
if (nerr != kNuErrNone) {
|
|
|
|
if (nerr == kNuErrAborted) {
|
|
|
|
CString title;
|
|
|
|
title.LoadString(IDS_MB_APP_NAME);
|
|
|
|
errMsg = "Cancelled.";
|
|
|
|
pMsgWnd->MessageBox(errMsg, title, MB_OK);
|
|
|
|
} else {
|
2014-11-19 22:54:24 +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
|
|
|
SET_PROGRESS_END();
|
|
|
|
return retVal;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|