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// -----------------------------------------------------------------------------
126117bool 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
0 commit comments