Skip to content

Latest commit

 

History

History
622 lines (475 loc) · 15.5 KB

pocketpc.c

File metadata and controls

622 lines (475 loc) · 15.5 KB
 
Nov 22, 2002
Nov 22, 2002
1
/*
Mar 11, 2007
Mar 11, 2007
2
* PocketPC support routines for PhysicsFS.
Nov 22, 2002
Nov 22, 2002
3
*
Mar 11, 2007
Mar 11, 2007
4
* Please see the file LICENSE.txt in the source's root directory.
Nov 22, 2002
Nov 22, 2002
5
6
7
8
*
* This file written by Ryan C. Gordon.
*/
Mar 11, 2007
Mar 11, 2007
9
10
11
12
13
#define __PHYSICSFS_INTERNAL__
#include "physfs_platforms.h"
#ifdef PHYSFS_PLATFORM_POCKETPC
Nov 22, 2002
Nov 22, 2002
14
15
16
17
18
#include <stdio.h>
#include <windows.h>
#include "physfs_internal.h"
Jul 20, 2003
Jul 20, 2003
19
20
#define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
Nov 22, 2002
Nov 22, 2002
21
22
23
24
25
26
27
28
typedef struct
{
HANDLE handle;
int readonly;
} winCEfile;
const char *__PHYSFS_platformDirSeparator = "\\";
May 18, 2003
May 18, 2003
29
static char *userDir = NULL;
Nov 22, 2002
Nov 22, 2002
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Figure out what the last failing Win32 API call was, and
* generate a human-readable string for the error message.
*
* The return value is a static buffer that is overwritten with
* each call to this function.
*/
static const char *win32strerror(void)
{
static TCHAR msgbuf[255];
TCHAR *ptr = msgbuf;
FormatMessage(
Jul 20, 2003
Jul 20, 2003
44
45
46
47
48
49
50
51
52
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
msgbuf,
sizeof (msgbuf) / sizeof (TCHAR),
NULL
);
May 18, 2003
May 18, 2003
53
54
/* chop off newlines. */
Nov 22, 2002
Nov 22, 2002
55
56
57
58
59
60
61
62
63
64
65
66
for (ptr = msgbuf; *ptr; ptr++)
{
if ((*ptr == '\n') || (*ptr == '\r'))
{
*ptr = ' ';
break;
} /* if */
} /* for */
return((const char *) msgbuf);
} /* win32strerror */
Mar 9, 2007
Mar 9, 2007
67
68
69
70
71
72
73
74
75
#define UTF8_TO_UNICODE_STACK_MACRO(w_assignto, str) { \
if (str == NULL) \
w_assignto = NULL; \
else { \
const PHYSFS_uint64 len = (PHYSFS_uint64) ((strlen(str) * 4) + 1); \
w_assignto = (char *) alloca(len); \
PHYSFS_uc2fromutf8(str, (PHYSFS_uint16 *) w_assignto, len); \
} \
} \
Nov 22, 2002
Nov 22, 2002
76
77
May 18, 2003
May 18, 2003
78
79
80
81
82
static char *getExePath()
{
DWORD buflen;
int success = 0;
TCHAR *ptr = NULL;
Mar 14, 2005
Mar 14, 2005
83
TCHAR *retval = (TCHAR*) allocator.Malloc(sizeof (TCHAR) * (MAX_PATH + 1));
May 18, 2003
May 18, 2003
84
85
86
87
char *charretval;
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
retval[0] = _T('\0');
Mar 9, 2007
Mar 9, 2007
88
/* !!! FIXME: don't preallocate here? */
May 18, 2003
May 18, 2003
89
buflen = GetModuleFileName(NULL, retval, MAX_PATH + 1);
Mar 8, 2007
Mar 8, 2007
90
if (buflen <= 0)
May 18, 2003
May 18, 2003
91
__PHYSFS_setError(win32strerror());
Mar 8, 2007
Mar 8, 2007
92
else
Jul 20, 2003
Jul 20, 2003
93
{
Mar 8, 2007
Mar 8, 2007
94
95
96
97
98
99
100
101
102
103
retval[buflen] = '\0'; /* does API always null-terminate this? */
ptr = retval+buflen;
while( ptr != retval )
{
if( *ptr != _T('\\') )
*ptr-- = _T('\0');
else
break;
} /* while */
success = 1;
May 18, 2003
May 18, 2003
104
105
106
107
} /* else */
if (!success)
{
Mar 14, 2005
Mar 14, 2005
108
allocator.Free(retval);
May 18, 2003
May 18, 2003
109
110
111
return(NULL); /* physfs error message will be set, above. */
} /* if */
Mar 9, 2007
Mar 9, 2007
112
113
114
115
buflen = (buflen * 4) + 1;
charretval = (char *) allocator.Malloc(buflen);
if (charretval != NULL)
PHYSFS_utf8fromucs2((const PHYSFS_uint16 *) retval, charretval, buflen);
Mar 14, 2005
Mar 14, 2005
116
allocator.Free(retval);
May 18, 2003
May 18, 2003
117
118
119
return(charretval); /* w00t. */
} /* getExePath */
Mar 8, 2007
Mar 8, 2007
120
Nov 22, 2002
Nov 22, 2002
121
122
int __PHYSFS_platformInit(void)
{
May 18, 2003
May 18, 2003
123
124
userDir = getExePath();
BAIL_IF_MACRO(userDir == NULL, NULL, 0); /* failed? */
Nov 22, 2002
Nov 22, 2002
125
126
127
128
129
130
return(1); /* always succeed. */
} /* __PHYSFS_platformInit */
int __PHYSFS_platformDeinit(void)
{
Mar 14, 2005
Mar 14, 2005
131
allocator.Free(userDir);
Nov 22, 2002
Nov 22, 2002
132
133
134
135
return(1); /* always succeed. */
} /* __PHYSFS_platformDeinit */
Sep 29, 2004
Sep 29, 2004
136
void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
Nov 22, 2002
Nov 22, 2002
137
{
Sep 29, 2004
Sep 29, 2004
138
/* no-op on this platform. */
Nov 22, 2002
Nov 22, 2002
139
140
141
142
143
} /* __PHYSFS_platformDetectAvailableCDs */
char *__PHYSFS_platformCalcBaseDir(const char *argv0)
{
May 18, 2003
May 18, 2003
144
return(getExePath());
Nov 22, 2002
Nov 22, 2002
145
146
147
148
149
150
151
152
153
154
155
} /* __PHYSFS_platformCalcBaseDir */
char *__PHYSFS_platformGetUserName(void)
{
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
} /* __PHYSFS_platformGetUserName */
char *__PHYSFS_platformGetUserDir(void)
{
May 18, 2003
May 18, 2003
156
return userDir;
Nov 22, 2002
Nov 22, 2002
157
158
159
160
161
162
163
164
165
166
167
168
BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
} /* __PHYSFS_platformGetUserDir */
PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
{
return(1); /* single threaded. */
} /* __PHYSFS_platformGetThreadID */
int __PHYSFS_platformExists(const char *fname)
{
Mar 9, 2007
Mar 9, 2007
169
170
int retval = 0;
wchar_t *w_fname = NULL;
Nov 22, 2002
Nov 22, 2002
171
Mar 9, 2007
Mar 9, 2007
172
173
174
UTF8_TO_UNICODE_STACK_MACRO(w_fname, fname);
if (w_fname != NULL)
retval = (GetFileAttributes(w_fname) != INVALID_FILE_ATTRIBUTES);
Nov 22, 2002
Nov 22, 2002
175
May 18, 2003
May 18, 2003
176
return(retval);
Nov 22, 2002
Nov 22, 2002
177
178
179
180
181
182
183
184
185
186
187
} /* __PHYSFS_platformExists */
int __PHYSFS_platformIsSymLink(const char *fname)
{
BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
} /* __PHYSFS_platformIsSymlink */
int __PHYSFS_platformIsDirectory(const char *fname)
{
Mar 9, 2007
Mar 9, 2007
188
189
int retval = 0;
wchar_t *w_fname = NULL;
Nov 22, 2002
Nov 22, 2002
190
Mar 9, 2007
Mar 9, 2007
191
192
193
UTF8_TO_UNICODE_STACK_MACRO(w_fname, fname);
if (w_fname != NULL)
retval = ((GetFileAttributes(w_fname) & FILE_ATTRIBUTE_DIRECTORY) != 0);
Nov 22, 2002
Nov 22, 2002
194
May 18, 2003
May 18, 2003
195
return(retval);
Nov 22, 2002
Nov 22, 2002
196
197
198
199
200
201
202
203
} /* __PHYSFS_platformIsDirectory */
char *__PHYSFS_platformCvtToDependent(const char *prepend,
const char *dirName,
const char *append)
{
int len = ((prepend) ? strlen(prepend) : 0) +
Jul 20, 2003
Jul 20, 2003
204
205
((append) ? strlen(append) : 0) +
strlen(dirName) + 1;
Mar 14, 2005
Mar 14, 2005
206
char *retval = (char *) allocator.Malloc(len);
Nov 22, 2002
Nov 22, 2002
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
char *p;
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
if (prepend)
strcpy(retval, prepend);
else
retval[0] = '\0';
strcat(retval, dirName);
if (append)
strcat(retval, append);
for (p = strchr(retval, '/'); p != NULL; p = strchr(p + 1, '/'))
*p = '\\';
return(retval);
} /* __PHYSFS_platformCvtToDependent */
void __PHYSFS_platformTimeslice(void)
{
Sleep(10);
} /* __PHYSFS_platformTimeslice */
Mar 9, 2007
Mar 9, 2007
234
235
236
237
238
239
240
241
242
243
static int doEnumCallback(const wchar_t *w_fname)
{
const PHYSFS_uint64 len = (PHYSFS_uint64) ((wcslen(w_fname) * 4) + 1);
char *str = (char *) alloca(len);
PHYSFS_utf8fromucs2((const PHYSFS_uint16 *) w_fname, str, len);
callback(callbackdata, origdir, str);
return 1;
} /* doEnumCallback */
Sep 29, 2004
Sep 29, 2004
244
245
void __PHYSFS_platformEnumerateFiles(const char *dirname,
int omitSymLinks,
Sep 18, 2005
Sep 18, 2005
246
247
PHYSFS_EnumFilesCallback callback,
const char *origdir,
Sep 29, 2004
Sep 29, 2004
248
void *callbackdata)
Nov 22, 2002
Nov 22, 2002
249
250
251
252
{
HANDLE dir;
WIN32_FIND_DATA ent;
char *SearchPath;
May 18, 2003
May 18, 2003
253
wchar_t *w_SearchPath;
Nov 22, 2002
Nov 22, 2002
254
255
256
257
size_t len = strlen(dirname);
/* Allocate a new string for path, maybe '\\', "*", and NULL terminator */
SearchPath = (char *) alloca(len + 3);
Jul 20, 2003
Jul 20, 2003
258
BAIL_IF_MACRO(SearchPath == NULL, ERR_OUT_OF_MEMORY, NULL);
Nov 22, 2002
Nov 22, 2002
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/* Copy current dirname */
strcpy(SearchPath, dirname);
/* if there's no '\\' at the end of the path, stick one in there. */
if (SearchPath[len - 1] != '\\')
{
SearchPath[len++] = '\\';
SearchPath[len] = '\0';
} /* if */
/* Append the "*" to the end of the string */
strcat(SearchPath, "*");
Mar 9, 2007
Mar 9, 2007
273
UTF8_TO_UNICODE_STACK_MACRO(w_SearchPath, SearchPath);
Nov 22, 2002
Nov 22, 2002
274
275
dir = FindFirstFile(w_SearchPath, &ent);
Sep 29, 2004
Sep 29, 2004
276
277
if (dir == INVALID_HANDLE_VALUE)
return;
Nov 22, 2002
Nov 22, 2002
278
279
280
do
{
Mar 9, 2007
Mar 9, 2007
281
const char *str = NULL;
Sep 29, 2004
Sep 29, 2004
282
Nov 22, 2002
Nov 22, 2002
283
284
285
286
287
288
if (wcscmp(ent.cFileName, L".") == 0)
continue;
if (wcscmp(ent.cFileName, L"..") == 0)
continue;
Mar 9, 2007
Mar 9, 2007
289
if (!doEnumCallback(ent.cFileName))
Nov 22, 2002
Nov 22, 2002
290
291
292
293
294
295
296
297
298
break;
} while (FindNextFile(dir, &ent) != 0);
FindClose(dir);
} /* __PHYSFS_platformEnumerateFiles */
char *__PHYSFS_platformCurrentDir(void)
{
May 18, 2003
May 18, 2003
299
return("\\");
Nov 22, 2002
Nov 22, 2002
300
301
302
303
304
} /* __PHYSFS_platformCurrentDir */
char *__PHYSFS_platformRealPath(const char *path)
{
Mar 14, 2005
Mar 14, 2005
305
char *retval = (char *) allocator.Malloc(strlen(path) + 1);
May 18, 2003
May 18, 2003
306
307
strcpy(retval,path);
return(retval);
Nov 22, 2002
Nov 22, 2002
308
309
310
311
312
} /* __PHYSFS_platformRealPath */
int __PHYSFS_platformMkDir(const char *path)
{
Mar 9, 2007
Mar 9, 2007
313
314
315
wchar_t *w_path = NULL;
UTF8_TO_UNICODE_STACK_MACRO(w_path, path);
return ( (w_path != NULL) && (CreateDirectory(w_path, NULL)) );
Nov 22, 2002
Nov 22, 2002
316
317
318
319
320
321
322
} /* __PHYSFS_platformMkDir */
static void *doOpen(const char *fname, DWORD mode, DWORD creation, int rdonly)
{
HANDLE fileHandle;
winCEfile *retval;
Mar 9, 2007
Mar 9, 2007
323
324
325
wchar_t *w_fname = NULL;
UTF8_TO_UNICODE_STACK_MACRO(w_fname, fname);
Nov 22, 2002
Nov 22, 2002
326
327
328
329
330
331
fileHandle = CreateFile(w_fname, mode, FILE_SHARE_READ, NULL,
creation, FILE_ATTRIBUTE_NORMAL, NULL);
BAIL_IF_MACRO(fileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
Mar 14, 2005
Mar 14, 2005
332
retval = (winCEfile *) allocator.Malloc(sizeof (winCEfile));
May 18, 2003
May 18, 2003
333
334
if (retval == NULL)
{
Mar 8, 2007
Mar 8, 2007
335
336
CloseHandle(fileHandle);
BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
May 18, 2003
May 18, 2003
337
} /* if */
Nov 22, 2002
Nov 22, 2002
338
May 18, 2003
May 18, 2003
339
340
341
retval->readonly = rdonly;
retval->handle = fileHandle;
return(retval);
Nov 22, 2002
Nov 22, 2002
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
} /* doOpen */
void *__PHYSFS_platformOpenRead(const char *filename)
{
return(doOpen(filename, GENERIC_READ, OPEN_EXISTING, 1));
} /* __PHYSFS_platformOpenRead */
void *__PHYSFS_platformOpenWrite(const char *filename)
{
return(doOpen(filename, GENERIC_WRITE, CREATE_ALWAYS, 0));
} /* __PHYSFS_platformOpenWrite */
void *__PHYSFS_platformOpenAppend(const char *filename)
{
void *retval = doOpen(filename, GENERIC_WRITE, OPEN_ALWAYS, 0);
if (retval != NULL)
{
HANDLE h = ((winCEfile *) retval)->handle;
if (SetFilePointer(h, 0, NULL, FILE_END) == INVALID_SET_FILE_POINTER)
{
const char *err = win32strerror();
CloseHandle(h);
Mar 14, 2005
Mar 14, 2005
367
allocator.Free(retval);
Nov 22, 2002
Nov 22, 2002
368
369
370
371
372
373
374
375
376
377
378
379
BAIL_MACRO(err, NULL);
} /* if */
} /* if */
return(retval);
} /* __PHYSFS_platformOpenAppend */
PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
PHYSFS_uint32 size, PHYSFS_uint32 count)
{
Sep 26, 2004
Sep 26, 2004
380
HANDLE Handle = ((winCEfile *) opaque)->handle;
Nov 22, 2002
Nov 22, 2002
381
382
383
384
385
DWORD CountOfBytesRead;
PHYSFS_sint64 retval;
/* Read data from the file */
/*!!! - uint32 might be a greater # than DWORD */
Sep 26, 2004
Sep 26, 2004
386
if (!ReadFile(Handle, buffer, count * size, &CountOfBytesRead, NULL))
Nov 22, 2002
Nov 22, 2002
387
{
Sep 26, 2004
Sep 26, 2004
388
retval = -1;
Nov 22, 2002
Nov 22, 2002
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
} /* if */
else
{
/* Return the number of "objects" read. */
/* !!! - What if not the right amount of bytes was read to make an object? */
retval = CountOfBytesRead / size;
} /* else */
return(retval);
} /* __PHYSFS_platformRead */
PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
PHYSFS_uint32 size, PHYSFS_uint32 count)
{
Sep 26, 2004
Sep 26, 2004
405
HANDLE Handle = ((winCEfile *) opaque)->handle;
Nov 22, 2002
Nov 22, 2002
406
407
408
409
410
DWORD CountOfBytesWritten;
PHYSFS_sint64 retval;
/* Read data from the file */
/*!!! - uint32 might be a greater # than DWORD */
Sep 26, 2004
Sep 26, 2004
411
if (!WriteFile(Handle, buffer, count * size, &CountOfBytesWritten, NULL))
Nov 22, 2002
Nov 22, 2002
412
{
Sep 26, 2004
Sep 26, 2004
413
retval = -1;
Nov 22, 2002
Nov 22, 2002
414
415
416
417
418
419
420
421
} /* if */
else
{
/* Return the number of "objects" read. */
/*!!! - What if not the right number of bytes was written? */
retval = CountOfBytesWritten / size;
} /* else */
May 18, 2003
May 18, 2003
422
return(retval);
Nov 22, 2002
Nov 22, 2002
423
424
425
426
427
428
} /* __PHYSFS_platformWrite */
int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos)
{
Sep 26, 2004
Sep 26, 2004
429
HANDLE Handle = ((winCEfile *) opaque)->handle;
Nov 22, 2002
Nov 22, 2002
430
431
432
433
434
DWORD HighOrderPos;
DWORD rc;
/* Get the high order 32-bits of the position */
//HighOrderPos = HIGHORDER_UINT64(pos);
May 18, 2003
May 18, 2003
435
HighOrderPos = (unsigned long)(pos>>32);
Nov 22, 2002
Nov 22, 2002
436
437
438
/*!!! SetFilePointer needs a signed 64-bit value. */
/* Move pointer "pos" count from start of file */
Sep 26, 2004
Sep 26, 2004
439
rc = SetFilePointer(Handle, (unsigned long)(pos&0x00000000ffffffff),
Nov 22, 2002
Nov 22, 2002
440
441
442
&HighOrderPos, FILE_BEGIN);
if ((rc == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
May 18, 2003
May 18, 2003
443
{
Nov 22, 2002
Nov 22, 2002
444
BAIL_MACRO(win32strerror(), 0);
May 18, 2003
May 18, 2003
445
}
Nov 22, 2002
Nov 22, 2002
446
447
448
449
450
451
452
return(1); /* No error occured */
} /* __PHYSFS_platformSeek */
PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
{
Sep 26, 2004
Sep 26, 2004
453
HANDLE Handle = ((winCEfile *) opaque)->handle;
Nov 22, 2002
Nov 22, 2002
454
455
456
457
458
DWORD HighPos = 0;
DWORD LowPos;
PHYSFS_sint64 retval;
/* Get current position */
Sep 26, 2004
Sep 26, 2004
459
LowPos = SetFilePointer(Handle, 0, &HighPos, FILE_CURRENT);
Nov 22, 2002
Nov 22, 2002
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
if ((LowPos == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
{
BAIL_MACRO(win32strerror(), 0);
} /* if */
else
{
/* Combine the high/low order to create the 64-bit position value */
retval = (((PHYSFS_uint64) HighPos) << 32) | LowPos;
//assert(retval >= 0);
} /* else */
return(retval);
} /* __PHYSFS_platformTell */
PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
{
Sep 26, 2004
Sep 26, 2004
477
HANDLE Handle = ((winCEfile *) opaque)->handle;
Nov 22, 2002
Nov 22, 2002
478
479
480
481
DWORD SizeHigh;
DWORD SizeLow;
PHYSFS_sint64 retval;
Sep 26, 2004
Sep 26, 2004
482
SizeLow = GetFileSize(Handle, &SizeHigh);
Nov 22, 2002
Nov 22, 2002
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
if ((SizeLow == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
{
BAIL_MACRO(win32strerror(), -1);
} /* if */
else
{
/* Combine the high/low order to create the 64-bit position value */
retval = (((PHYSFS_uint64) SizeHigh) << 32) | SizeLow;
//assert(retval >= 0);
} /* else */
return(retval);
} /* __PHYSFS_platformFileLength */
int __PHYSFS_platformEOF(void *opaque)
{
PHYSFS_sint64 FilePosition;
int retval = 0;
/* Get the current position in the file */
if ((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
{
/* Non-zero if EOF is equal to the file length */
retval = FilePosition == __PHYSFS_platformFileLength(opaque);
} /* if */
return(retval);
} /* __PHYSFS_platformEOF */
int __PHYSFS_platformFlush(void *opaque)
{
winCEfile *fh = ((winCEfile *) opaque);
if (!fh->readonly)
BAIL_IF_MACRO(!FlushFileBuffers(fh->handle), win32strerror(), 0);
return(1);
} /* __PHYSFS_platformFlush */
int __PHYSFS_platformClose(void *opaque)
{
Sep 26, 2004
Sep 26, 2004
526
527
HANDLE Handle = ((winCEfile *) opaque)->handle;
BAIL_IF_MACRO(!CloseHandle(Handle), win32strerror(), 0);
Mar 14, 2005
Mar 14, 2005
528
allocator.Free(opaque);
Nov 22, 2002
Nov 22, 2002
529
530
531
532
533
534
return(1);
} /* __PHYSFS_platformClose */
int __PHYSFS_platformDelete(const char *path)
{
Mar 9, 2007
Mar 9, 2007
535
536
wchar_t *w_path = NULL;
UTF8_TO_UNICODE_STACK_MACRO(w_path, path);
Nov 22, 2002
Nov 22, 2002
537
538
539
540
/* If filename is a folder */
if (GetFileAttributes(w_path) == FILE_ATTRIBUTE_DIRECTORY)
{
Mar 9, 2007
Mar 9, 2007
541
int retval = !RemoveDirectory(w_path);
Nov 22, 2002
Nov 22, 2002
542
543
544
545
BAIL_IF_MACRO(retval, win32strerror(), 0);
} /* if */
else
{
Mar 9, 2007
Mar 9, 2007
546
int retval = !DeleteFile(w_path);
Nov 22, 2002
Nov 22, 2002
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
BAIL_IF_MACRO(retval, win32strerror(), 0);
} /* else */
return(1); /* if you got here, it worked. */
} /* __PHYSFS_platformDelete */
void *__PHYSFS_platformCreateMutex(void)
{
return((void *) CreateMutex(NULL, FALSE, NULL));
} /* __PHYSFS_platformCreateMutex */
void __PHYSFS_platformDestroyMutex(void *mutex)
{
CloseHandle((HANDLE) mutex);
} /* __PHYSFS_platformDestroyMutex */
int __PHYSFS_platformGrabMutex(void *mutex)
{
return(WaitForSingleObject((HANDLE) mutex, INFINITE) != WAIT_FAILED);
} /* __PHYSFS_platformGrabMutex */
void __PHYSFS_platformReleaseMutex(void *mutex)
{
ReleaseMutex((HANDLE) mutex);
} /* __PHYSFS_platformReleaseMutex */
PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
{
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
} /* __PHYSFS_platformGetLastModTime */
Mar 14, 2005
Mar 14, 2005
583
584
585
586
587
588
589
590
591
592
593
594
595
596
/* !!! FIXME: Don't use C runtime for allocators? */
int __PHYSFS_platformAllocatorInit(void)
{
return(1); /* always succeeds. */
} /* __PHYSFS_platformAllocatorInit */
void __PHYSFS_platformAllocatorDeinit(void)
{
/* no-op */
} /* __PHYSFS_platformAllocatorInit */
Sep 6, 2005
Sep 6, 2005
597
void *__PHYSFS_platformAllocatorMalloc(PHYSFS_uint64 s)
Mar 14, 2005
Mar 14, 2005
598
{
Jan 1, 2006
Jan 1, 2006
599
BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
Mar 14, 2005
Mar 14, 2005
600
#undef malloc
Sep 6, 2005
Sep 6, 2005
601
return(malloc((size_t) s));
Mar 14, 2005
Mar 14, 2005
602
603
604
} /* __PHYSFS_platformMalloc */
Sep 6, 2005
Sep 6, 2005
605
void *__PHYSFS_platformAllocatorRealloc(void *ptr, PHYSFS_uint64 s)
Mar 14, 2005
Mar 14, 2005
606
{
Jan 1, 2006
Jan 1, 2006
607
BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
Mar 14, 2005
Mar 14, 2005
608
#undef realloc
Sep 6, 2005
Sep 6, 2005
609
return(realloc(ptr, (size_t) s));
Mar 14, 2005
Mar 14, 2005
610
611
612
613
614
615
616
617
618
} /* __PHYSFS_platformRealloc */
void __PHYSFS_platformAllocatorFree(void *ptr)
{
#undef free
free(ptr);
} /* __PHYSFS_platformAllocatorFree */
Mar 11, 2007
Mar 11, 2007
619
620
#endif /* PHYSFS_PLATFORM_POCKETPC */
Feb 15, 2005
Feb 15, 2005
621
/* end of pocketpc.c ... */