[CABMAN/CDMAKE]

check for _WIN32 instead of WIN32, fixes compilation with amd64 toolchain

svn path=/trunk/; revision=52475
This commit is contained in:
Timo Kreuzer 2011-06-26 22:17:01 +00:00
parent c83e44a670
commit b32da944f7
4 changed files with 76 additions and 76 deletions

View file

@ -18,7 +18,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#if !defined(WIN32) #if !defined(_WIN32)
# include <dirent.h> # include <dirent.h>
# include <sys/stat.h> # include <sys/stat.h>
# include <sys/types.h> # include <sys/types.h>
@ -27,7 +27,7 @@
#include "raw.h" #include "raw.h"
#include "mszip.h" #include "mszip.h"
#if defined(WIN32) #if defined(_WIN32)
#define GetSizeOfFile(handle) _GetSizeOfFile(handle) #define GetSizeOfFile(handle) _GetSizeOfFile(handle)
static LONG _GetSizeOfFile(FILEHANDLE handle) static LONG _GetSizeOfFile(FILEHANDLE handle)
{ {
@ -126,7 +126,7 @@ ULONG CCFDATAStorage::Create(const char* FileName)
{ {
ASSERT(!FileCreated); ASSERT(!FileCreated);
#if defined(WIN32) #if defined(_WIN32)
if (GetTempPath(MAX_PATH, FullName) == 0) if (GetTempPath(MAX_PATH, FullName) == 0)
return CAB_STATUS_CANNOT_CREATE; return CAB_STATUS_CANNOT_CREATE;
@ -147,7 +147,7 @@ ULONG CCFDATAStorage::Create(const char* FileName)
DPRINT(MID_TRACE, ("ERROR '%u'.\n", (UINT)GetLastError())); DPRINT(MID_TRACE, ("ERROR '%u'.\n", (UINT)GetLastError()));
return CAB_STATUS_CANNOT_CREATE; return CAB_STATUS_CANNOT_CREATE;
} }
#else /* !WIN32 */ #else /* !_WIN32 */
/*if (tmpnam(FullName) == NULL)*/ /*if (tmpnam(FullName) == NULL)*/
if ((FileHandle = tmpfile()) == NULL) if ((FileHandle = tmpfile()) == NULL)
return CAB_STATUS_CANNOT_CREATE; return CAB_STATUS_CANNOT_CREATE;
@ -190,12 +190,12 @@ ULONG CCFDATAStorage::Truncate()
* Status of operation * Status of operation
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
if( SetFilePointer(FileHandle, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER ) if( SetFilePointer(FileHandle, 0, NULL, FILE_BEGIN) == INVALID_SET_FILE_POINTER )
return CAB_STATUS_FAILURE; return CAB_STATUS_FAILURE;
if (!SetEndOfFile(FileHandle)) if (!SetEndOfFile(FileHandle))
return CAB_STATUS_FAILURE; return CAB_STATUS_FAILURE;
#else /* !WIN32 */ #else /* !_WIN32 */
fclose(FileHandle); fclose(FileHandle);
FileHandle = tmpfile(); FileHandle = tmpfile();
if (FileHandle == NULL) if (FileHandle == NULL)
@ -215,7 +215,7 @@ ULONG CCFDATAStorage::Position()
* Current position * Current position
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
return SetFilePointer(FileHandle, 0, NULL, FILE_CURRENT); return SetFilePointer(FileHandle, 0, NULL, FILE_CURRENT);
#else #else
return (ULONG)ftell(FileHandle); return (ULONG)ftell(FileHandle);
@ -232,7 +232,7 @@ ULONG CCFDATAStorage::Seek(LONG Position)
* Status of operation * Status of operation
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
if( SetFilePointer(FileHandle, if( SetFilePointer(FileHandle,
Position, Position,
NULL, NULL,
@ -260,7 +260,7 @@ ULONG CCFDATAStorage::ReadBlock(PCFDATA Data, void* Buffer, PULONG BytesRead)
* Status of operation * Status of operation
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
if (!ReadFile(FileHandle, Buffer, Data->CompSize, (LPDWORD)BytesRead, NULL)) if (!ReadFile(FileHandle, Buffer, Data->CompSize, (LPDWORD)BytesRead, NULL))
return CAB_STATUS_CANNOT_READ; return CAB_STATUS_CANNOT_READ;
#else #else
@ -284,7 +284,7 @@ ULONG CCFDATAStorage::WriteBlock(PCFDATA Data, void* Buffer, PULONG BytesWritten
* Status of operation * Status of operation
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, Buffer, Data->CompSize, (LPDWORD)BytesWritten, NULL)) if (!WriteFile(FileHandle, Buffer, Data->CompSize, (LPDWORD)BytesWritten, NULL))
return CAB_STATUS_CANNOT_WRITE; return CAB_STATUS_CANNOT_WRITE;
#else #else
@ -394,7 +394,7 @@ char* CCabinet::ConvertPath(char* Path, bool Allocate)
i = 0; i = 0;
while (Path[i] != 0) while (Path[i] != 0)
{ {
#if defined(WIN32) #if defined(_WIN32)
if (Path[i] == '/') if (Path[i] == '/')
newpath[i] = '\\'; newpath[i] = '\\';
else else
@ -632,7 +632,7 @@ bool CCabinet::SetCabinetReservedFile(char* FileName)
FILEHANDLE FileHandle; FILEHANDLE FileHandle;
ULONG BytesRead; ULONG BytesRead;
#if defined(WIN32) #if defined(_WIN32)
FileHandle = CreateFile(ConvertPath(FileName, true), // Open this file FileHandle = CreateFile(ConvertPath(FileName, true), // Open this file
GENERIC_READ, // Open for reading GENERIC_READ, // Open for reading
FILE_SHARE_READ, // Share for reading FILE_SHARE_READ, // Share for reading
@ -645,7 +645,7 @@ bool CCabinet::SetCabinetReservedFile(char* FileName)
DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n")); DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
return false; return false;
} }
#else /* !WIN32 */ #else /* !_WIN32 */
FileHandle = fopen(ConvertPath(FileName, true), "rb"); FileHandle = fopen(ConvertPath(FileName, true), "rb");
if (FileHandle == NULL) if (FileHandle == NULL)
{ {
@ -730,7 +730,7 @@ ULONG CCabinet::Open()
if (!OutputBuffer) if (!OutputBuffer)
return CAB_STATUS_NOMEMORY; return CAB_STATUS_NOMEMORY;
#if defined(WIN32) #if defined(_WIN32)
FileHandle = CreateFile(CabinetName, // Open this file FileHandle = CreateFile(CabinetName, // Open this file
GENERIC_READ, // Open for reading GENERIC_READ, // Open for reading
FILE_SHARE_READ, // Share for reading FILE_SHARE_READ, // Share for reading
@ -744,7 +744,7 @@ ULONG CCabinet::Open()
DPRINT(MID_TRACE, ("Cannot open file.\n")); DPRINT(MID_TRACE, ("Cannot open file.\n"));
return CAB_STATUS_CANNOT_OPEN; return CAB_STATUS_CANNOT_OPEN;
} }
#else /* !WIN32 */ #else /* !_WIN32 */
FileHandle = fopen(CabinetName, "rb"); FileHandle = fopen(CabinetName, "rb");
if (FileHandle == NULL) if (FileHandle == NULL)
{ {
@ -791,7 +791,7 @@ ULONG CCabinet::Open()
FolderReserved = (Size >> 16) & 0xFF; FolderReserved = (Size >> 16) & 0xFF;
DataReserved = (Size >> 24) & 0xFF; DataReserved = (Size >> 24) & 0xFF;
#if defined(WIN32) #if defined(_WIN32)
if (SetFilePointer(FileHandle, CabinetReserved, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER) if (SetFilePointer(FileHandle, CabinetReserved, NULL, FILE_CURRENT) == INVALID_SET_FILE_POINTER)
{ {
DPRINT(MIN_TRACE, ("SetFilePointer() failed, error code is %u.\n", (UINT)GetLastError())); DPRINT(MIN_TRACE, ("SetFilePointer() failed, error code is %u.\n", (UINT)GetLastError()));
@ -1027,7 +1027,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
CFDATA CFData; CFDATA CFData;
ULONG Status; ULONG Status;
bool Skip; bool Skip;
#if defined(WIN32) #if defined(_WIN32)
FILETIME FileTime; FILETIME FileTime;
#endif #endif
CHAR DestName[MAX_PATH]; CHAR DestName[MAX_PATH];
@ -1066,7 +1066,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
strcat(DestName, FileName); strcat(DestName, FileName);
/* Create destination file, fail if it already exists */ /* Create destination file, fail if it already exists */
#if defined(WIN32) #if defined(_WIN32)
DestFile = CreateFile(DestName, // Create this file DestFile = CreateFile(DestName, // Create this file
GENERIC_WRITE, // Open for writing GENERIC_WRITE, // Open for writing
0, // No sharing 0, // No sharing
@ -1099,7 +1099,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
return CAB_STATUS_CANNOT_CREATE; return CAB_STATUS_CANNOT_CREATE;
} }
} }
#else /* !WIN32 */ #else /* !_WIN32 */
DestFile = fopen(DestName, "rb"); DestFile = fopen(DestName, "rb");
if (DestFile != NULL) if (DestFile != NULL)
{ {
@ -1121,7 +1121,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
return CAB_STATUS_CANNOT_CREATE; return CAB_STATUS_CANNOT_CREATE;
} }
#endif #endif
#if defined(WIN32) #if defined(_WIN32)
if (!DosDateTimeToFileTime(File->File.FileDate, File->File.FileTime, &FileTime)) if (!DosDateTimeToFileTime(File->File.FileDate, File->File.FileTime, &FileTime))
{ {
CloseFile(DestFile); CloseFile(DestFile);
@ -1147,7 +1147,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
OnExtract(&File->File, FileName); OnExtract(&File->File, FileName);
/* Search to start of file */ /* Search to start of file */
#if defined(WIN32) #if defined(_WIN32)
Offset = SetFilePointer(FileHandle, Offset = SetFilePointer(FileHandle,
File->DataBlock->AbsoluteOffset, File->DataBlock->AbsoluteOffset,
NULL, NULL,
@ -1273,7 +1273,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
File->DataBlock = CurrentFolderNode->DataListHead; File->DataBlock = CurrentFolderNode->DataListHead;
/* Search to start of file */ /* Search to start of file */
#if defined(WIN32) #if defined(_WIN32)
if( SetFilePointer(FileHandle, if( SetFilePointer(FileHandle,
File->DataBlock->AbsoluteOffset, File->DataBlock->AbsoluteOffset,
NULL, NULL,
@ -1347,7 +1347,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
CFData.CompSize, CFData.UncompSize)); CFData.CompSize, CFData.UncompSize));
/* Go to next data block */ /* Go to next data block */
#if defined(WIN32) #if defined(_WIN32)
if( SetFilePointer(FileHandle, if( SetFilePointer(FileHandle,
CurrentDataNode->AbsoluteOffset + sizeof(CFDATA) + CurrentDataNode->AbsoluteOffset + sizeof(CFDATA) +
CurrentDataNode->Data.CompSize, CurrentDataNode->Data.CompSize,
@ -1386,7 +1386,7 @@ ULONG CCabinet::ExtractFile(char* FileName)
(UINT)BytesSkipped, (UINT)Skip, (UINT)BytesSkipped, (UINT)Skip,
(UINT)Size)); (UINT)Size));
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(DestFile, (void*)((PUCHAR)OutputBuffer + BytesSkipped), if (!WriteFile(DestFile, (void*)((PUCHAR)OutputBuffer + BytesSkipped),
BytesToWrite, (LPDWORD)&BytesWritten, NULL) || BytesToWrite, (LPDWORD)&BytesWritten, NULL) ||
(BytesToWrite != BytesWritten)) (BytesToWrite != BytesWritten))
@ -1625,7 +1625,7 @@ ULONG CCabinet::WriteFileToScratchStorage(PCFFILE_NODE FileNode)
if (!ContinueFile) if (!ContinueFile)
{ {
/* Try to open file */ /* Try to open file */
#if defined(WIN32) #if defined(_WIN32)
SourceFile = CreateFile( SourceFile = CreateFile(
FileNode->FileName, // Open this file FileNode->FileName, // Open this file
GENERIC_READ, // Open for reading GENERIC_READ, // Open for reading
@ -1639,7 +1639,7 @@ ULONG CCabinet::WriteFileToScratchStorage(PCFFILE_NODE FileNode)
DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName)); DPRINT(MID_TRACE, ("File not found (%s).\n", FileNode->FileName));
return CAB_STATUS_NOFILE; return CAB_STATUS_NOFILE;
} }
#else /* !WIN32 */ #else /* !_WIN32 */
SourceFile = fopen(FileNode->FileName, "rb"); SourceFile = fopen(FileNode->FileName, "rb");
if (SourceFile == NULL) if (SourceFile == NULL)
{ {
@ -1839,7 +1839,7 @@ ULONG CCabinet::CommitDisk(ULONG MoreDisks)
OnCabinetName(CurrentDiskNumber, CabinetName); OnCabinetName(CurrentDiskNumber, CabinetName);
/* Create file, fail if it already exists */ /* Create file, fail if it already exists */
#if defined(WIN32) #if defined(_WIN32)
FileHandle = CreateFile(CabinetName, // Create this file FileHandle = CreateFile(CabinetName, // Create this file
GENERIC_WRITE, // Open for writing GENERIC_WRITE, // Open for writing
0, // No sharing 0, // No sharing
@ -1874,7 +1874,7 @@ ULONG CCabinet::CommitDisk(ULONG MoreDisks)
return CAB_STATUS_CANNOT_CREATE; return CAB_STATUS_CANNOT_CREATE;
} }
} }
#else /* !WIN32 */ #else /* !_WIN32 */
FileHandle = fopen(CabinetName, "rb"); FileHandle = fopen(CabinetName, "rb");
if (FileHandle != NULL) if (FileHandle != NULL)
{ {
@ -2009,7 +2009,7 @@ ULONG CCabinet::AddFile(char* FileName)
ConvertPath(NewFileName, false); ConvertPath(NewFileName, false);
/* Try to open file */ /* Try to open file */
#if defined(WIN32) #if defined(_WIN32)
SrcFile = CreateFile( SrcFile = CreateFile(
NewFileName, // Open this file NewFileName, // Open this file
GENERIC_READ, // Open for reading GENERIC_READ, // Open for reading
@ -2024,7 +2024,7 @@ ULONG CCabinet::AddFile(char* FileName)
FreeMemory(NewFileName); FreeMemory(NewFileName);
return CAB_STATUS_CANNOT_OPEN; return CAB_STATUS_CANNOT_OPEN;
} }
#else /* !WIN32 */ #else /* !_WIN32 */
SrcFile = fopen(NewFileName, "rb"); SrcFile = fopen(NewFileName, "rb");
if (SrcFile == NULL) if (SrcFile == NULL)
{ {
@ -2085,7 +2085,7 @@ bool CCabinet::CreateSimpleCabinet()
PSEARCH_CRITERIA Criteria; PSEARCH_CRITERIA Criteria;
ULONG Status; ULONG Status;
#if defined(WIN32) #if defined(_WIN32)
HANDLE hFind; HANDLE hFind;
WIN32_FIND_DATA FindFileData; WIN32_FIND_DATA FindFileData;
#else #else
@ -2123,7 +2123,7 @@ bool CCabinet::CreateSimpleCabinet()
{ {
pszFile = Criteria->Search; pszFile = Criteria->Search;
#if defined(WIN32) #if defined(_WIN32)
szFilePath[0] = 0; szFilePath[0] = 0;
#else #else
// needed for opendir() // needed for opendir()
@ -2131,7 +2131,7 @@ bool CCabinet::CreateSimpleCabinet()
#endif #endif
} }
#if defined(WIN32) #if defined(_WIN32)
// Windows: Use the easy FindFirstFile/FindNextFile API for getting all files and checking them against the pattern // Windows: Use the easy FindFirstFile/FindNextFile API for getting all files and checking them against the pattern
hFind = FindFirstFile(Criteria->Search, &FindFileData); hFind = FindFirstFile(Criteria->Search, &FindFileData);
@ -2479,7 +2479,7 @@ ULONG CCabinet::ReadString(char* String, LONG MaxLength)
// + 1 to skip the terminating NULL character as well. // + 1 to skip the terminating NULL character as well.
Size = -(MaxLength - Size) + 1; Size = -(MaxLength - Size) + 1;
#if defined(WIN32) #if defined(_WIN32)
if( SetFilePointer(FileHandle, if( SetFilePointer(FileHandle,
(LONG)Size, (LONG)Size,
NULL, NULL,
@ -2515,7 +2515,7 @@ ULONG CCabinet::ReadFileTable()
(UINT)CABHeader.FileTableOffset)); (UINT)CABHeader.FileTableOffset));
/* Seek to file table */ /* Seek to file table */
#if defined(WIN32) #if defined(_WIN32)
if( SetFilePointer(FileHandle, if( SetFilePointer(FileHandle,
CABHeader.FileTableOffset, CABHeader.FileTableOffset,
NULL, NULL,
@ -2603,7 +2603,7 @@ ULONG CCabinet::ReadDataBlocks(PCFFOLDER_NODE FolderNode)
} }
/* Seek to data block */ /* Seek to data block */
#if defined(WIN32) #if defined(_WIN32)
if( SetFilePointer(FileHandle, if( SetFilePointer(FileHandle,
AbsoluteOffset, AbsoluteOffset,
NULL, NULL,
@ -3168,7 +3168,7 @@ ULONG CCabinet::WriteCabinetHeader(bool MoreDisks)
CABHeader.CabinetSize = DiskSize; CABHeader.CabinetSize = DiskSize;
/* Write header */ /* Write header */
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, &CABHeader, sizeof(CFHEADER), (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(FileHandle, &CABHeader, sizeof(CFHEADER), (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MIN_TRACE, ("Cannot write to file.\n")); DPRINT(MIN_TRACE, ("Cannot write to file.\n"));
@ -3191,7 +3191,7 @@ ULONG CCabinet::WriteCabinetHeader(bool MoreDisks)
ReservedSize = CabinetReservedFileSize & 0xffff; ReservedSize = CabinetReservedFileSize & 0xffff;
ReservedSize |= (0 << 16); /* Folder reserved area size */ ReservedSize |= (0 << 16); /* Folder reserved area size */
ReservedSize |= (0 << 24); /* Folder reserved area size */ ReservedSize |= (0 << 24); /* Folder reserved area size */
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, &ReservedSize, sizeof(ULONG), (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(FileHandle, &ReservedSize, sizeof(ULONG), (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MIN_TRACE, ("Cannot write to file.\n")); DPRINT(MIN_TRACE, ("Cannot write to file.\n"));
@ -3206,7 +3206,7 @@ ULONG CCabinet::WriteCabinetHeader(bool MoreDisks)
} }
#endif #endif
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, CabinetReservedFileBuffer, CabinetReservedFileSize, (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(FileHandle, CabinetReservedFileBuffer, CabinetReservedFileSize, (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MIN_TRACE, ("Cannot write to file.\n")); DPRINT(MIN_TRACE, ("Cannot write to file.\n"));
@ -3228,7 +3228,7 @@ ULONG CCabinet::WriteCabinetHeader(bool MoreDisks)
/* Write name of previous cabinet */ /* Write name of previous cabinet */
Size = (ULONG)strlen(CabinetPrev) + 1; Size = (ULONG)strlen(CabinetPrev) + 1;
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, CabinetPrev, Size, (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(FileHandle, CabinetPrev, Size, (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MIN_TRACE, ("Cannot write to file.\n")); DPRINT(MIN_TRACE, ("Cannot write to file.\n"));
@ -3247,7 +3247,7 @@ ULONG CCabinet::WriteCabinetHeader(bool MoreDisks)
/* Write label of previous disk */ /* Write label of previous disk */
Size = (ULONG)strlen(DiskPrev) + 1; Size = (ULONG)strlen(DiskPrev) + 1;
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, DiskPrev, Size, (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(FileHandle, DiskPrev, Size, (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MIN_TRACE, ("Cannot write to file.\n")); DPRINT(MIN_TRACE, ("Cannot write to file.\n"));
@ -3269,7 +3269,7 @@ ULONG CCabinet::WriteCabinetHeader(bool MoreDisks)
/* Write name of next cabinet */ /* Write name of next cabinet */
Size = (ULONG)strlen(CabinetNext) + 1; Size = (ULONG)strlen(CabinetNext) + 1;
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, CabinetNext, Size, (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(FileHandle, CabinetNext, Size, (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MIN_TRACE, ("Cannot write to file.\n")); DPRINT(MIN_TRACE, ("Cannot write to file.\n"));
@ -3288,7 +3288,7 @@ ULONG CCabinet::WriteCabinetHeader(bool MoreDisks)
/* Write label of next disk */ /* Write label of next disk */
Size = (ULONG)strlen(DiskNext) + 1; Size = (ULONG)strlen(DiskNext) + 1;
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, DiskNext, Size, (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(FileHandle, DiskNext, Size, (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MIN_TRACE, ("Cannot write to file.\n")); DPRINT(MIN_TRACE, ("Cannot write to file.\n"));
@ -3328,7 +3328,7 @@ ULONG CCabinet::WriteFolderEntries()
DPRINT(MAX_TRACE, ("Writing folder entry. CompressionType (0x%X) DataBlockCount (%d) DataOffset (0x%X).\n", DPRINT(MAX_TRACE, ("Writing folder entry. CompressionType (0x%X) DataBlockCount (%d) DataOffset (0x%X).\n",
FolderNode->Folder.CompressionType, FolderNode->Folder.DataBlockCount, (UINT)FolderNode->Folder.DataOffset)); FolderNode->Folder.CompressionType, FolderNode->Folder.DataBlockCount, (UINT)FolderNode->Folder.DataOffset));
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, if (!WriteFile(FileHandle,
&FolderNode->Folder, &FolderNode->Folder,
sizeof(CFFOLDER), sizeof(CFFOLDER),
@ -3390,7 +3390,7 @@ ULONG CCabinet::WriteFileEntries()
DPRINT(MAX_TRACE, ("Writing file entry. FileControlID (0x%X) FileOffset (0x%X) FileSize (%u) FileName (%s).\n", DPRINT(MAX_TRACE, ("Writing file entry. FileControlID (0x%X) FileOffset (0x%X) FileSize (%u) FileName (%s).\n",
File->File.FileControlID, (UINT)File->File.FileOffset, (UINT)File->File.FileSize, File->FileName)); File->File.FileControlID, (UINT)File->File.FileOffset, (UINT)File->File.FileSize, File->FileName));
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, if (!WriteFile(FileHandle,
&File->File, &File->File,
sizeof(CFFILE), sizeof(CFFILE),
@ -3406,7 +3406,7 @@ ULONG CCabinet::WriteFileEntries()
} }
#endif #endif
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, if (!WriteFile(FileHandle,
GetFileName(File->FileName), GetFileName(File->FileName),
(DWORD)strlen(GetFileName(File->FileName)) + 1, (DWORD)strlen(GetFileName(File->FileName)) + 1,
@ -3470,7 +3470,7 @@ ULONG CCabinet::CommitDataBlocks(PCFFOLDER_NODE FolderNode)
return Status; return Status;
} }
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, &DataNode->Data, if (!WriteFile(FileHandle, &DataNode->Data,
sizeof(CFDATA), (LPDWORD)&BytesWritten, NULL)) sizeof(CFDATA), (LPDWORD)&BytesWritten, NULL))
{ {
@ -3486,7 +3486,7 @@ ULONG CCabinet::CommitDataBlocks(PCFFOLDER_NODE FolderNode)
} }
#endif #endif
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(FileHandle, InputBuffer, if (!WriteFile(FileHandle, InputBuffer,
DataNode->Data.CompSize, (LPDWORD)&BytesWritten, NULL)) DataNode->Data.CompSize, (LPDWORD)&BytesWritten, NULL))
{ {
@ -3595,7 +3595,7 @@ ULONG CCabinet::WriteDataBlock()
return CAB_STATUS_SUCCESS; return CAB_STATUS_SUCCESS;
} }
#if !defined(WIN32) #if !defined(_WIN32)
void CCabinet::ConvertDateAndTime(time_t* Time, void CCabinet::ConvertDateAndTime(time_t* Time,
PUSHORT DosDate, PUSHORT DosDate,
@ -3626,7 +3626,7 @@ void CCabinet::ConvertDateAndTime(time_t* Time,
| (timedef->tm_hour << 11); | (timedef->tm_hour << 11);
} }
#endif // !WIN32 #endif // !_WIN32
ULONG CCabinet::GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File) ULONG CCabinet::GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File)
@ -3639,7 +3639,7 @@ ULONG CCabinet::GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File)
* Status of operation * Status of operation
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
FILETIME FileTime; FILETIME FileTime;
if (GetFileTime(FileHandle, NULL, NULL, &FileTime)) if (GetFileTime(FileHandle, NULL, NULL, &FileTime))
@ -3679,7 +3679,7 @@ ULONG CCabinet::GetAttributesOnFile(PCFFILE_NODE File)
* Status of operation * Status of operation
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
LONG Attributes; LONG Attributes;
Attributes = GetFileAttributes(File->FileName); Attributes = GetFileAttributes(File->FileName);
@ -3734,7 +3734,7 @@ ULONG CCabinet::SetAttributesOnFile(char* FileName, USHORT FileAttributes)
* Status of operation * Status of operation
*/ */
{ {
#if defined(WIN32) #if defined(_WIN32)
// 0x37 = READONLY | HIDDEN | SYSTEM | DIRECTORY | ARCHIVE // 0x37 = READONLY | HIDDEN | SYSTEM | DIRECTORY | ARCHIVE
// The IDs for these attributes are the same in the CAB file and under Windows // The IDs for these attributes are the same in the CAB file and under Windows
// If the file has any other attributes, strip them off by the logical AND. // If the file has any other attributes, strip them off by the logical AND.

View file

@ -7,7 +7,7 @@
#pragma once #pragma once
#if defined(WIN32) #if defined(_WIN32)
#include <windows.h> #include <windows.h>
#else #else
#include <errno.h> #include <errno.h>
@ -25,7 +25,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#if defined(WIN32) #if defined(_WIN32)
#define DIR_SEPARATOR_CHAR '\\' #define DIR_SEPARATOR_CHAR '\\'
#define DIR_SEPARATOR_STRING "\\" #define DIR_SEPARATOR_STRING "\\"
@ -431,7 +431,7 @@ private:
ULONG GetAttributesOnFile(PCFFILE_NODE File); ULONG GetAttributesOnFile(PCFFILE_NODE File);
ULONG SetAttributesOnFile(char* FileName, USHORT FileAttributes); ULONG SetAttributesOnFile(char* FileName, USHORT FileAttributes);
ULONG GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File); ULONG GetFileTimes(FILEHANDLE FileHandle, PCFFILE_NODE File);
#if !defined(WIN32) #if !defined(_WIN32)
void ConvertDateAndTime(time_t* Time, PUSHORT DosDate, PUSHORT DosTime); void ConvertDateAndTime(time_t* Time, PUSHORT DosDate, PUSHORT DosTime);
#endif #endif
#endif /* CAB_READ_ONLY */ #endif /* CAB_READ_ONLY */

View file

@ -18,7 +18,7 @@
#include "dfp.h" #include "dfp.h"
#if defined(WIN32) #if defined(_WIN32)
#define GetSizeOfFile(handle) _GetSizeOfFile(handle) #define GetSizeOfFile(handle) _GetSizeOfFile(handle)
static LONG _GetSizeOfFile(FILEHANDLE handle) static LONG _GetSizeOfFile(FILEHANDLE handle)
{ {
@ -126,7 +126,7 @@ void CDFParser::WriteInfLine(char* InfLine)
char buf[MAX_PATH]; char buf[MAX_PATH];
char eolbuf[2]; char eolbuf[2];
char* destpath; char* destpath;
#if defined(WIN32) #if defined(_WIN32)
ULONG BytesWritten; ULONG BytesWritten;
#endif #endif
@ -149,7 +149,7 @@ void CDFParser::WriteInfLine(char* InfLine)
strcpy(buf, InfFileName); strcpy(buf, InfFileName);
/* Create .inf file, overwrite if it already exists */ /* Create .inf file, overwrite if it already exists */
#if defined(WIN32) #if defined(_WIN32)
InfFileHandle = CreateFile(buf, // Create this file InfFileHandle = CreateFile(buf, // Create this file
GENERIC_WRITE, // Open for writing GENERIC_WRITE, // Open for writing
0, // No sharing 0, // No sharing
@ -162,7 +162,7 @@ void CDFParser::WriteInfLine(char* InfLine)
DPRINT(MID_TRACE, ("Error creating '%u'.\n", (UINT)GetLastError())); DPRINT(MID_TRACE, ("Error creating '%u'.\n", (UINT)GetLastError()));
return; return;
} }
#else /* !WIN32 */ #else /* !_WIN32 */
InfFileHandle = fopen(buf, "wb"); InfFileHandle = fopen(buf, "wb");
if (InfFileHandle == NULL) if (InfFileHandle == NULL)
{ {
@ -172,7 +172,7 @@ void CDFParser::WriteInfLine(char* InfLine)
#endif #endif
} }
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(InfFileHandle, InfLine, (DWORD)strlen(InfLine), (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(InfFileHandle, InfLine, (DWORD)strlen(InfLine), (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MID_TRACE, ("ERROR WRITING '%u'.\n", (UINT)GetLastError())); DPRINT(MID_TRACE, ("ERROR WRITING '%u'.\n", (UINT)GetLastError()));
@ -186,7 +186,7 @@ void CDFParser::WriteInfLine(char* InfLine)
eolbuf[0] = 0x0d; eolbuf[0] = 0x0d;
eolbuf[1] = 0x0a; eolbuf[1] = 0x0a;
#if defined(WIN32) #if defined(_WIN32)
if (!WriteFile(InfFileHandle, eolbuf, sizeof(eolbuf), (LPDWORD)&BytesWritten, NULL)) if (!WriteFile(InfFileHandle, eolbuf, sizeof(eolbuf), (LPDWORD)&BytesWritten, NULL))
{ {
DPRINT(MID_TRACE, ("ERROR WRITING '%u'.\n", (UINT)GetLastError())); DPRINT(MID_TRACE, ("ERROR WRITING '%u'.\n", (UINT)GetLastError()));
@ -215,7 +215,7 @@ ULONG CDFParser::Load(char* FileName)
return CAB_STATUS_SUCCESS; return CAB_STATUS_SUCCESS;
/* Create cabinet file, overwrite if it already exists */ /* Create cabinet file, overwrite if it already exists */
#if defined(WIN32) #if defined(_WIN32)
FileHandle = CreateFile(FileName, // Create this file FileHandle = CreateFile(FileName, // Create this file
GENERIC_READ, // Open for reading GENERIC_READ, // Open for reading
0, // No sharing 0, // No sharing
@ -225,7 +225,7 @@ ULONG CDFParser::Load(char* FileName)
NULL); // No attribute template NULL); // No attribute template
if (FileHandle == INVALID_HANDLE_VALUE) if (FileHandle == INVALID_HANDLE_VALUE)
return CAB_STATUS_CANNOT_OPEN; return CAB_STATUS_CANNOT_OPEN;
#else /* !WIN32 */ #else /* !_WIN32 */
FileHandle = fopen(FileName, "rb"); FileHandle = fopen(FileName, "rb");
if (FileHandle == NULL) if (FileHandle == NULL)
return CAB_STATUS_CANNOT_OPEN; return CAB_STATUS_CANNOT_OPEN;

View file

@ -33,7 +33,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef WIN32 #ifdef _WIN32
# include <io.h> # include <io.h>
# include <dos.h> # include <dos.h>
#else #else
@ -46,11 +46,11 @@
# include <sys/types.h> # include <sys/types.h>
# include <dirent.h> # include <dirent.h>
# include <unistd.h> # include <unistd.h>
#endif // WIN32 #endif // _WIN32
#include <ctype.h> #include <ctype.h>
#include <setjmp.h> #include <setjmp.h>
#include <time.h> #include <time.h>
#ifndef WIN32 #ifndef _WIN32
#ifndef MAX_PATH #ifndef MAX_PATH
#define MAX_PATH 260 #define MAX_PATH 260
#endif #endif
@ -529,9 +529,9 @@ static int check_for_punctuation(int c, const char *name)
return c; return c;
} }
#if WIN32 #if _WIN32
#define strcasecmp stricmp #define strcasecmp stricmp
#endif//WIN32 #endif//_WIN32
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
This function checks to see if there's a cdname conflict. This function checks to see if there's a cdname conflict.
@ -643,7 +643,7 @@ specified ffblk. It links it into the beginning of the directory list
for the specified parent and returns a pointer to the new record. for the specified parent and returns a pointer to the new record.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#if WIN32 #if _WIN32
/* Win32 version */ /* Win32 version */
PDIR_RECORD PDIR_RECORD
@ -764,7 +764,7 @@ and puts the appropriate directory records into the database in memory, with
the specified root. It calls itself recursively to scan all subdirectories. the specified root. It calls itself recursively to scan all subdirectories.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
#ifdef WIN32 #ifdef _WIN32
static void static void
make_directory_records (PDIR_RECORD d) make_directory_records (PDIR_RECORD d)