Input browse & batch buttons start browsing at the current input location

MacLib no longer opens the file for writing when decoding
This commit is contained in:
chudov
2008-10-19 11:20:48 +00:00
parent b00e54f20e
commit f6138ce9cc
13 changed files with 170 additions and 435 deletions

View File

@@ -11,7 +11,7 @@ CAPEInfo:
/*****************************************************************************************
Construction
*****************************************************************************************/
CAPEInfo::CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag)
CAPEInfo::CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag, bool fReadOnly)
{
*pErrorCode = ERROR_SUCCESS;
CloseFile();
@@ -19,7 +19,7 @@ CAPEInfo::CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag)
// open the file
m_spIO.Assign(new IO_CLASS_NAME);
if (m_spIO->Open(pFilename) != 0)
if (m_spIO->Open(pFilename, fReadOnly) != 0)
{
CloseFile();
*pErrorCode = ERROR_INVALID_INPUT_FILE;

View File

@@ -77,7 +77,7 @@ class CAPEInfo
public:
// construction and destruction
CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag = NULL);
CAPEInfo(int * pErrorCode, const wchar_t * pFilename, CAPETag * pTag = NULL, bool fReadOnly = 0);
CAPEInfo(int * pErrorCode, CIO * pIO, CAPETag * pTag = NULL);
virtual ~CAPEInfo();

View File

@@ -75,7 +75,7 @@ IAPEDecompress * __stdcall CreateIAPEDecompress(const str_utf16 * pFilename, int
else if ((wcsicmp(pExtension, L".mac") == 0) || (wcsicmp(pExtension, L".ape") == 0))
{
// plain .ape file
pAPEInfo = new CAPEInfo(&nErrorCode, pFilename);
pAPEInfo = new CAPEInfo(&nErrorCode, pFilename, NULL, 1);
}
// fail if we couldn't get the file information

View File

@@ -49,10 +49,10 @@
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;UNICODE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\Debug/MACLib.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@@ -139,7 +139,6 @@
/>
<Tool
Name="VCPreLinkEventTool"
Description=""
CommandLine=""
/>
<Tool
@@ -198,7 +197,6 @@
RuntimeLibrary="2"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="all.h"
PrecompiledHeaderFile=".\Release/MACLib.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
@@ -277,7 +275,6 @@
RuntimeLibrary="2"
UsePrecompiledHeader="0"
PrecompiledHeaderThrough="all.h"
PrecompiledHeaderFile=".\x64\Release/MACLib.pch"
AssemblerListingLocation=".\x64\Release/"
ObjectFile=".\x64\Release/"
ProgramDataBaseFileName=".\x64\Release/"
@@ -296,7 +293,6 @@
/>
<Tool
Name="VCPreLinkEventTool"
Description=""
CommandLine=""
/>
<Tool

View File

@@ -23,7 +23,7 @@ public:
virtual ~CIO() { };
// open / close
virtual int Open(const wchar_t * pName) = 0;
virtual int Open(const wchar_t * pName, int fReadonly = 0) = 0;
virtual int Close() = 0;
// read / write

View File

@@ -18,7 +18,7 @@ CWinFileIO::~CWinFileIO()
Close();
}
int CWinFileIO::Open(const wchar_t * pName)
int CWinFileIO::Open(const wchar_t * pName, int fReadonly)
{
Close();
@@ -28,7 +28,9 @@ int CWinFileIO::Open(const wchar_t * pName)
CSmartPtr<char> spName(GetANSIFromUTF16(pName), TRUE);
#endif
m_hFile = ::CreateFile(spName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
m_hFile = INVALID_HANDLE_VALUE;
if (!fReadonly)
m_hFile = ::CreateFile(spName, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (m_hFile == INVALID_HANDLE_VALUE)
{
m_hFile = ::CreateFile(spName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

View File

@@ -14,7 +14,7 @@ public:
~CWinFileIO();
// open / close
int Open(const wchar_t * pName);
int Open(const wchar_t * pName, int fReadonly = 0);
int Close();
// read / write