author | Wuzzy <almikes@aol.com> |
Fri, 22 Sep 2017 17:12:16 +0200 | |
changeset 12485 | 72a2ea747677 |
parent 11046 | 47a8c19ecb60 |
permissions | -rw-r--r-- |
9991 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
9991 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9991
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
9991 | 17 |
*/ |
18 |
||
19 |
#include "physfscompat.h" |
|
20 |
||
21 |
#ifdef HW_PHYSFS_COMPAT |
|
22 |
||
23 |
PHYSFS_DECL int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat) |
|
24 |
{ |
|
25 |
PHYSFS_File * handle; |
|
26 |
||
27 |
if (PHYSFS_exists(fname)) |
|
28 |
{ |
|
29 |
handle = PHYSFS_openRead(fname); |
|
30 |
if (handle) |
|
31 |
{ |
|
32 |
stat->filesize = PHYSFS_fileLength(handle); |
|
33 |
PHYSFS_close(handle); |
|
34 |
handle = 0; |
|
35 |
} |
|
36 |
else |
|
37 |
stat->filesize = -1; |
|
38 |
||
39 |
stat->modtime = PHYSFS_getLastModTime(fname); |
|
40 |
stat->createtime = -1; |
|
41 |
stat->accesstime = -1; |
|
42 |
||
43 |
if (PHYSFS_isSymbolicLink(fname)) |
|
44 |
stat->filetype = PHYSFS_FILETYPE_SYMLINK; |
|
45 |
else if (PHYSFS_isDirectory(fname)) |
|
46 |
stat->filetype = PHYSFS_FILETYPE_DIRECTORY; |
|
47 |
else stat->filetype = PHYSFS_FILETYPE_REGULAR; |
|
48 |
||
49 |
stat->readonly = 0; /* not supported */ |
|
50 |
||
51 |
/* success */ |
|
52 |
return 1; |
|
53 |
} |
|
54 |
||
55 |
/* does not exist, can't stat */ |
|
56 |
return 0; |
|
57 |
} |
|
58 |
||
59 |
PHYSFS_DECL PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer, |
|
60 |
PHYSFS_uint64 len) |
|
61 |
{ |
|
62 |
return PHYSFS_read(handle, buffer, 1, len); |
|
63 |
} |
|
64 |
||
65 |
||
66 |
PHYSFS_DECL PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle, |
|
67 |
const void *buffer, |
|
68 |
PHYSFS_uint64 len) |
|
69 |
{ |
|
70 |
return PHYSFS_write(handle, buffer, 1, len); |
|
71 |
} |
|
72 |
||
73 |
#endif /* HW_PHYSFS_COMPAT */ |