a966eb8b697aab420f65e938f0d924865ec25497
2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
4 Copyright (C) <ARembo@gmail.com> 2011
6 This file is part of the Doom2D:Rembo project.
8 Doom2D:Rembo is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as
10 published by the Free Software Foundation.
12 Doom2D:Rembo is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/> or
19 write to the Free Software Foundation, Inc.,
20 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 void mysplitpath(const char* path
, char* drv
, char* dir
, char* name
, char* ext
) {
32 const char* end
; /* end of processed string */
33 const char* p
; /* search pointer */
34 const char* s
; /* copy pointer */
36 /* extract drive name */
37 if (path
[0] && path
[1]==':') {
46 /* search for end of string or stream separator */
47 for(end
=path
; *end
&& *end
!=':'; )
50 /* search for begin of file extension */
51 for(p
=end
; p
>path
&& *--p
!='\\' && *p
!='/'; )
58 for(s
=end
; (*ext
=*s
++); )
61 /* search for end of directory name */
63 if (*--p
=='\\' || *p
=='/') {
83 size_t myfreadc (void *ptr
, size_t size
, size_t n
, FILE *f
) {
84 return fread(ptr
, size
, n
, f
);
87 void myfread (void *ptr
, size_t size
, size_t n
, FILE *f
) {
88 if (myfreadc(ptr
, size
, n
, f
) != n
) {
89 ERR_fatal("File reading error\n");
93 int8_t myfread8 (FILE *f
) {
99 int16_t myfread16 (FILE *f
) {
101 myfread(&x
, 2, 1, f
);
102 return short2host(x
);
105 int32_t myfread32 (FILE *f
) {
107 myfread(&x
, 4, 1, f
);
111 void myfwrite (void *ptr
, size_t size
, size_t n
, FILE *f
) {
112 assert(fwrite(ptr
, size
, n
, f
) == n
);
115 void myfwrite8 (int8_t x
, FILE *f
) {
116 myfwrite(&x
, 1, 1, f
);
119 void myfwrite16 (int16_t x
, FILE *f
) {
121 myfwrite(&x
, 2, 1, f
);
124 void myfwrite32 (int32_t x
, FILE *f
) {
126 myfwrite(&x
, 4, 1, f
);
129 void myrandomize (void) {
130 srand(SDL_GetTicks());
133 int fexists (char *filename
) {
135 if ((f
= fopen(filename
, "r")))