9991
|
1 |
/*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (c) 2004-2014 Andrey Korotaev <unC0Rr@gmail.com>
|
|
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
|
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
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 */
|