Skip to content

Commit da27179

Browse files
authored
Build wwutil on Linux (w3dhub#73)
1 parent 1ae1104 commit da27179

5 files changed

Lines changed: 20 additions & 88 deletions

File tree

Code/wwutil/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ set(WWUTIL_SRC
44
mathutil.h
55
miscutil.cpp
66
miscutil.h
7-
stackdump.cpp
7+
$<$<BOOL:${WIN32}>:stackdump-windows.cpp>
8+
$<$<BOOL:${LINUX}>:stackdump-linux.cpp>
89
stackdump.h
910
)
1011

Code/wwutil/miscutil.cpp

Lines changed: 7 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
#include "miscutil.h" // I WANNA BE FIRST!
2828

2929
#include <time.h>
30+
#include <cstdio>
3031

3132
#include "rawfile.h"
3233
#include "wwdebug.h"
33-
#include <windows.h>
3434
#include "ffactory.h"
3535

3636
//
3737
// cMiscUtil statics
3838
//
3939

4040
//---------------------------------------------------------------------------
41-
LPCSTR cMiscUtil::Get_Text_Time(void)
41+
const char * cMiscUtil::Get_Text_Time(void)
4242
{
4343
//
4444
// Returns a pointer to an internal statically allocated buffer...
@@ -71,7 +71,7 @@ void cMiscUtil::Seconds_To_Hms(float seconds, int & h, int & m, int & s)
7171
}
7272

7373
//-----------------------------------------------------------------------------
74-
bool cMiscUtil::Is_String_Same(LPCSTR str1, LPCSTR str2)
74+
bool cMiscUtil::Is_String_Same(const char * str1, const char * str2)
7575
{
7676
WWASSERT(str1 != NULL);
7777
WWASSERT(str2 != NULL);
@@ -80,7 +80,7 @@ bool cMiscUtil::Is_String_Same(LPCSTR str1, LPCSTR str2)
8080
}
8181

8282
//-----------------------------------------------------------------------------
83-
bool cMiscUtil::Is_String_Different(LPCSTR str1, LPCSTR str2)
83+
bool cMiscUtil::Is_String_Different(const char * str1, const char * str2)
8484
{
8585
WWASSERT(str1 != NULL);
8686
WWASSERT(str2 != NULL);
@@ -89,7 +89,7 @@ bool cMiscUtil::Is_String_Different(LPCSTR str1, LPCSTR str2)
8989
}
9090

9191
//-----------------------------------------------------------------------------
92-
bool cMiscUtil::File_Exists(LPCSTR filename)
92+
bool cMiscUtil::File_Exists(const char * filename)
9393
{
9494
#if 0
9595
WWASSERT(filename != NULL);
@@ -113,15 +113,6 @@ bool cMiscUtil::File_Exists(LPCSTR filename)
113113
#endif
114114
}
115115

116-
//-----------------------------------------------------------------------------
117-
bool cMiscUtil::File_Is_Read_Only(LPCSTR filename)
118-
{
119-
WWASSERT(filename != NULL);
120-
121-
DWORD attributes = ::GetFileAttributesA(filename);
122-
return ((attributes != 0xFFFFFFFF) && (attributes & FILE_ATTRIBUTE_READONLY));
123-
}
124-
125116
//-----------------------------------------------------------------------------
126117
bool cMiscUtil::Is_Alphabetic(char c)
127118
{
@@ -158,68 +149,11 @@ void cMiscUtil::Trim_Trailing_Whitespace(char * text)
158149
}
159150

160151
//-----------------------------------------------------------------------------
161-
void cMiscUtil::Get_File_Id_String(LPCSTR filename, StringClass & str)
162-
{
163-
WWASSERT(filename != NULL);
164-
165-
// WWDEBUG_SAY(("cMiscUtil::Get_File_Id_String for %s\n", filename));
166-
167-
//
168-
// Get size
169-
//
170-
RawFileClass file(filename);
171-
int filesize = file.Size();
172-
//WWASSERT(filesize > 0);
173-
if (filesize <= 0)
174-
{
175-
WWDEBUG_SAY(("Error: cMiscUtil::Get_File_Id_String for %s: filesize = %d\n",
176-
filename, filesize));
177-
DIE;
178-
}
179-
file.Close();
180-
181-
//
182-
// Note... this timedatestamp is not present for all file types...
183-
//
184-
IMAGE_FILE_HEADER header = {0};
185-
extern bool Get_Image_File_Header(LPCSTR filename, IMAGE_FILE_HEADER *file_header);
186-
/*
187-
bool success;
188-
success = Get_Image_File_Header(filename, &header);
189-
WWASSERT(success);
190-
*/
191-
Get_Image_File_Header(filename, &header);
192-
int time_date_stamp = header.TimeDateStamp;
193-
194-
char working_filename[500];
195-
strcpy(working_filename, filename);
196-
::strupr(working_filename);
197-
198-
//
199-
// Strip path off filename
200-
//
201-
char * p_start = &working_filename[strlen(working_filename)];
202-
int num_chars = 1;
203-
while (p_start > working_filename && *(p_start - 1) != '\\') {
204-
p_start--;
205-
num_chars++;
206-
}
207-
::memmove(working_filename, p_start, num_chars);
208-
209-
//
210-
// Put all this data into a string
211-
//
212-
str.Format("%s %d %d", working_filename, filesize, time_date_stamp);
213-
214-
//WWDEBUG_SAY(("File id string: %s\n", str));
215-
}
216-
217-
//-----------------------------------------------------------------------------
218-
void cMiscUtil::Remove_File(LPCSTR filename)
152+
void cMiscUtil::Remove_File(const char * filename)
219153
{
220154
WWASSERT(filename != NULL);
221155

222-
::DeleteFileA(filename);
156+
::remove(filename);
223157
}
224158

225159

Code/wwutil/miscutil.h

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,22 @@
3131
#ifndef MISCUTIL_H
3232
#define MISCUTIL_H
3333

34-
#ifndef ALWAYS_H
35-
#include "always.h"
36-
#endif
37-
38-
#include "bittype.h"
39-
#include "wwstring.h"
40-
4134
const float MISCUTIL_EPSILON = 0.0001f;
4235

4336
class cMiscUtil
4437
{
4538
public:
46-
static LPCSTR Get_Text_Time(void);
39+
static const char * Get_Text_Time(void);
4740
static void Seconds_To_Hms(float seconds, int & h, int & m, int & s);
48-
static bool Is_String_Same(LPCSTR str1, LPCSTR str2);
49-
static bool Is_String_Different(LPCSTR str1, LPCSTR str2);
50-
static void Get_File_Id_String(LPCSTR filename, StringClass & str);
51-
static bool File_Exists(LPCSTR filename);
52-
static bool File_Is_Read_Only(LPCSTR filename);
41+
static bool Is_String_Same(const char * str1, const char * str2);
42+
static bool Is_String_Different(const char * str1, const char * str2);
43+
static bool File_Exists(const char * filename);
5344
static bool Is_Alphabetic(char c);
5445
static bool Is_Numeric(char c);
5546
static bool Is_Alphanumeric(char c);
5647
static bool Is_Whitespace(char c);
5748
static void Trim_Trailing_Whitespace(char * text);
58-
static void Remove_File(LPCSTR filename);
49+
static void Remove_File(const char * filename);
5950

6051
private:
6152
};

Code/wwutil/stackdump-linux.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "stackdump.h"
2+
3+
void cStackDump::Print_Call_Stack(void)
4+
{
5+
// do nothing
6+
}

0 commit comments

Comments
 (0)