Skip to content

Commit a53a8f4

Browse files
feliwirFighter19
andcommitted
[Compat] Fix Generals WWUtil compilation
Co-authored-by: Patrick Zacharias <[email protected]>
1 parent 43994b4 commit a53a8f4

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

Dependencies/Utility/Utility/intrin_compat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static inline uint32_t _lrotl(uint32_t value, int shift)
2929

3030
static inline uint64_t _rdtsc()
3131
{
32-
#if _WIN32
32+
#ifdef _WIN32
3333
return __rdtsc();
3434
#elif defined(__has_builtin) && __has_builtin(__builtin_readcyclecounter)
3535
return __builtin_readcyclecounter();

Generals/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

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

Lines changed: 15 additions & 4 deletions
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-
DWORD attributes = ::GetFileAttributes(filename);
123-
return ((attributes != 0xFFFFFFFF) && (attributes & FILE_ATTRIBUTE_READONLY));
122+
#ifdef _WIN32
123+
DWORD attributes = ::GetFileAttributes(filename);
124+
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+
#ifdef _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

223-
::DeleteFile(filename);
230+
#ifdef _WIN32
231+
::DeleteFile(filename);
232+
#else
233+
::remove(filename);
234+
#endif
224235
}
225236

226237

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ bool cMiscUtil::File_Is_Read_Only(LPCSTR filename)
119119
{
120120
WWASSERT(filename != NULL);
121121

122-
#if _WIN32
122+
#ifdef _WIN32
123123
DWORD attributes = ::GetFileAttributes(filename);
124124
return ((attributes != 0xFFFFFFFF) && (attributes & FILE_ATTRIBUTE_READONLY));
125125
#else
@@ -171,7 +171,7 @@ void cMiscUtil::Get_File_Id_String(LPCSTR filename, StringClass & str)
171171

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

174-
#if _WIN32
174+
#ifdef _WIN32
175175
//
176176
// Get size
177177
//
@@ -227,7 +227,7 @@ void cMiscUtil::Remove_File(LPCSTR filename)
227227
{
228228
WWASSERT(filename != NULL);
229229

230-
#if _WIN32
230+
#ifdef _WIN32
231231
::DeleteFile(filename);
232232
#else
233233
::remove(filename);

0 commit comments

Comments
 (0)