misc/libphyslayer/physfscompat.c
author Wuzzy <Wuzzy2@mail.ru>
Tue, 21 Aug 2018 17:56:17 +0200
changeset 13675 d3a4cbba060e
parent 11046 47a8c19ecb60
permissions -rw-r--r--
Consistently rename "team chat" to "clan chat" (except chat command) Only change in strings, no functional change. "Team" and "clan" have defined meanings in HW, but "team chat" oddly broke this convention. This feature allows chat with your clan, not with your team, so is now called "clan chat". /team command unchanged to avoid disruption (for now).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9991
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     1
/*
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10108
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
9991
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     4
 *
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     8
 *
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    12
 * GNU General Public License for more details.
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    13
 *
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    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
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    17
 */
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    18
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    19
#include "physfscompat.h"
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    20
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    21
#ifdef HW_PHYSFS_COMPAT
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    22
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    23
PHYSFS_DECL int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat)
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    24
{
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    25
    PHYSFS_File * handle;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    26
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    27
    if (PHYSFS_exists(fname))
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    28
    {
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    29
        handle = PHYSFS_openRead(fname);
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    30
        if (handle)
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    31
        {
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    32
            stat->filesize = PHYSFS_fileLength(handle);
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    33
            PHYSFS_close(handle);
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    34
            handle = 0;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    35
        }
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    36
        else
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    37
            stat->filesize = -1;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    38
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    39
        stat->modtime = PHYSFS_getLastModTime(fname);
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    40
        stat->createtime = -1;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    41
        stat->accesstime = -1;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    42
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    43
        if (PHYSFS_isSymbolicLink(fname))
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    44
            stat->filetype = PHYSFS_FILETYPE_SYMLINK;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    45
        else if (PHYSFS_isDirectory(fname))
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    46
            stat->filetype = PHYSFS_FILETYPE_DIRECTORY;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    47
        else stat->filetype = PHYSFS_FILETYPE_REGULAR;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    48
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    49
        stat->readonly = 0; /* not supported */
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    50
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    51
        /* success */
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    52
        return 1;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    53
    }
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    54
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    55
    /* does not exist, can't stat */
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    56
    return 0;
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    57
}
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    58
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    59
PHYSFS_DECL PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer,
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    60
                                           PHYSFS_uint64 len)
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    61
{
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    62
    return PHYSFS_read(handle, buffer, 1, len);
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    63
}
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    64
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    65
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    66
PHYSFS_DECL PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle,
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    67
                                            const void *buffer,
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    68
                                            PHYSFS_uint64 len)
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    69
{
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    70
    return PHYSFS_write(handle, buffer, 1, len);
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    71
}
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    72
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents:
diff changeset
    73
#endif /* HW_PHYSFS_COMPAT */