Skip to content

Commit 3bdd169

Browse files
committed
[Compat] Fix ZH WWUtil compilation
1 parent f70ae59 commit 3bdd169

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/mmsys.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@
4444
** This header just includes mmsystem.h with warning 4201 disabled
4545
*/
4646

47+
#ifdef _WIN32
4748
#pragma warning(disable:4201)
4849
#include <mmsystem.h>
4950
#pragma warning(default:4201)
51+
#endif
5052

5153
#endif // MMSYS_H

GeneralsMD/Code/Libraries/Source/WWVegas/Wwutil/miscutil.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,14 @@ bool cMiscUtil::File_Is_Read_Only(LPCSTR filename)
119119
{
120120
WWASSERT(filename != NULL);
121121

122+
#if _WIN32
122123
DWORD attributes = ::GetFileAttributes(filename);
123124
return ((attributes != 0xFFFFFFFF) && (attributes & FILE_ATTRIBUTE_READONLY));
125+
#else
126+
bool readable = access(filename, R_OK) == 0;
127+
bool writable = access(filename, W_OK) == 0;
128+
return (readable && !writable);
129+
#endif
124130
}
125131

126132
//-----------------------------------------------------------------------------
@@ -165,6 +171,7 @@ void cMiscUtil::Get_File_Id_String(LPCSTR filename, StringClass & str)
165171

166172
// WWDEBUG_SAY(("cMiscUtil::Get_File_Id_String for %s\n", filename));
167173

174+
#if _WIN32
168175
//
169176
// Get size
170177
//
@@ -211,7 +218,7 @@ void cMiscUtil::Get_File_Id_String(LPCSTR filename, StringClass & str)
211218
// Put all this data into a string
212219
//
213220
str.Format("%s %d %d", working_filename, filesize, time_date_stamp);
214-
221+
#endif
215222
//WWDEBUG_SAY(("File id string: %s\n", str));
216223
}
217224

@@ -220,7 +227,11 @@ void cMiscUtil::Remove_File(LPCSTR filename)
220227
{
221228
WWASSERT(filename != NULL);
222229

230+
#if _WIN32
223231
::DeleteFile(filename);
232+
#else
233+
::remove(filename);
234+
#endif
224235
}
225236

226237

0 commit comments

Comments
 (0)