Mercurial > sdl-ios-xcode
annotate src/file/SDL_rwops.c @ 4454:be387681d876
Fixed Eric's changes to allow building from the command line.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 09 May 2010 10:00:33 -0700 |
parents | 947201caa46e |
children | e8916fe9cfc8 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1269
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1269
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1269
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1269
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1269
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1269
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
36
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* This file provides a general interface for SDL to read and write | |
25 data sources. It can easily be extended to files, memory, etc. | |
26 */ | |
27 | |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
28 #include "SDL_endian.h" |
0 | 29 #include "SDL_rwops.h" |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
30 |
4447
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
31 #ifdef __APPLE__ |
4454
be387681d876
Fixed Eric's changes to allow building from the command line.
Sam Lantinga <slouken@libsdl.org>
parents:
4447
diff
changeset
|
32 #include "cocoa/SDL_rwopsbundlesupport.h" |
4447
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
33 #endif /* __APPLE__ */ |
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
34 |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
35 #ifdef __NDS__ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
36 /* include libfat headers for fatInitDefault(). */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
37 #include <fat.h> |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
38 #endif /* __NDS__ */ |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
39 |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
40 #ifdef __WIN32__ |
0 | 41 |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
42 /* Functions to read/write Win32 API file pointers */ |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
43 /* Will not use it on WinCE because stdio is buffered, it means |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
44 faster, and all stdio functions anyway are embedded in coredll.dll - |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
45 the main wince dll*/ |
0 | 46 |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
47 #define WINDOWS_LEAN_AND_MEAN |
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
48 #include <windows.h> |
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
49 |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
50 #ifndef INVALID_SET_FILE_POINTER |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
51 #define INVALID_SET_FILE_POINTER 0xFFFFFFFF |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
52 #endif |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
53 |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
54 #define READAHEAD_BUFFER_SIZE 1024 |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
55 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
56 static int SDLCALL |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
57 win32_file_open(SDL_RWops * context, const char *filename, const char *mode) |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
58 { |
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
59 #ifndef _WIN32_WCE |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
60 UINT old_error_mode; |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
61 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
62 HANDLE h; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
63 DWORD r_right, w_right; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
64 DWORD must_exist, truncate; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
65 int a_mode; |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
66 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
67 if (!context) |
2164
d083a2e4433d
Merged memory leak fix from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
2161
diff
changeset
|
68 return -1; /* failed (invalid call) */ |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
69 |
2173 | 70 context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ |
2165
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
71 context->hidden.win32io.buffer.data = NULL; |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
72 context->hidden.win32io.buffer.size = 0; |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
73 context->hidden.win32io.buffer.left = 0; |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
74 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
75 /* "r" = reading, file must exist */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
76 /* "w" = writing, truncate existing, file may not exist */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
77 /* "r+"= reading or writing, file must exist */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
78 /* "a" = writing, append file may not exist */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
79 /* "a+"= append + read, file may not exist */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
80 /* "w+" = read, write, truncate. file may not exist */ |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
81 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
82 must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
83 truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
84 r_right = (SDL_strchr(mode, '+') != NULL |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
85 || must_exist) ? GENERIC_READ : 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
86 a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
87 w_right = (a_mode || SDL_strchr(mode, '+') |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
88 || truncate) ? GENERIC_WRITE : 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
89 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
90 if (!r_right && !w_right) /* inconsistent mode */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
91 return -1; /* failed (invalid call) */ |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
92 |
2173 | 93 context->hidden.win32io.buffer.data = |
94 (char *) SDL_malloc(READAHEAD_BUFFER_SIZE); | |
2165
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
95 if (!context->hidden.win32io.buffer.data) { |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
96 SDL_OutOfMemory(); |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
97 return -1; |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
98 } |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
99 #ifdef _WIN32_WCE |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
100 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
101 size_t size = SDL_strlen(filename) + 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
102 wchar_t *filenameW = SDL_stack_alloc(wchar_t, size); |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
103 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
104 if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) == |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
105 0) { |
2165
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
106 SDL_stack_free(filenameW); |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
107 SDL_free(context->hidden.win32io.buffer.data); |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
108 context->hidden.win32io.buffer.data = NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
109 SDL_SetError("Unable to convert filename to Unicode"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
110 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
111 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
112 h = CreateFile(filenameW, (w_right | r_right), |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
113 (w_right) ? 0 : FILE_SHARE_READ, NULL, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
114 (must_exist | truncate | a_mode), |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
115 FILE_ATTRIBUTE_NORMAL, NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
116 SDL_stack_free(filenameW); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
117 } |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
118 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
119 /* Do not open a dialog box if failure */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
120 old_error_mode = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
121 SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
122 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
123 h = CreateFile(filename, (w_right | r_right), |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
124 (w_right) ? 0 : FILE_SHARE_READ, NULL, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
125 (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
126 NULL); |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
127 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
128 /* restore old behaviour */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
129 SetErrorMode(old_error_mode); |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
130 #endif /* _WIN32_WCE */ |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
131 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
132 if (h == INVALID_HANDLE_VALUE) { |
2165
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
133 SDL_free(context->hidden.win32io.buffer.data); |
c2ffcc627701
Merged r3201:3204 from branches/SDL-1.2: win32 rwops tweaks.
Ryan C. Gordon <icculus@icculus.org>
parents:
2164
diff
changeset
|
134 context->hidden.win32io.buffer.data = NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
135 SDL_SetError("Couldn't open %s", filename); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
136 return -2; /* failed (CreateFile) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
137 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
138 context->hidden.win32io.h = h; |
2161
e635db5b45ef
Oh yeah, they're boolean values...
Sam Lantinga <slouken@libsdl.org>
parents:
2160
diff
changeset
|
139 context->hidden.win32io.append = a_mode ? SDL_TRUE : SDL_FALSE; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
140 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
141 return 0; /* ok */ |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
142 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
143 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
144 static long SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
145 win32_file_seek(SDL_RWops * context, long offset, int whence) |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
146 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
147 DWORD win32whence; |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
148 long file_pos; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
149 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
150 if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
151 SDL_SetError("win32_file_seek: invalid context/file not opened"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
152 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
153 } |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
154 |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
155 /* FIXME: We may be able to satisfy the seek within buffered data */ |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
156 if (whence == RW_SEEK_CUR && context->hidden.win32io.buffer.left) { |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
157 offset -= (long)context->hidden.win32io.buffer.left; |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
158 } |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
159 context->hidden.win32io.buffer.left = 0; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
160 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
161 switch (whence) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
162 case RW_SEEK_SET: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
163 win32whence = FILE_BEGIN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
164 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
165 case RW_SEEK_CUR: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
166 win32whence = FILE_CURRENT; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
167 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
168 case RW_SEEK_END: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
169 win32whence = FILE_END; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
170 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
171 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
172 SDL_SetError("win32_file_seek: Unknown value for 'whence'"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
173 return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
174 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
175 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
176 file_pos = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
177 SetFilePointer(context->hidden.win32io.h, offset, NULL, win32whence); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
178 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
179 if (file_pos != INVALID_SET_FILE_POINTER) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
180 return file_pos; /* success */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
181 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
182 SDL_Error(SDL_EFSEEK); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
183 return -1; /* error */ |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
184 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
185 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
186 static size_t SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
187 win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
188 { |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
189 size_t total_need; |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
190 size_t total_read = 0; |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
191 size_t read_ahead; |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
192 DWORD byte_read; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
193 |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
194 total_need = size * maxnum; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
195 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
196 if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
197 || !total_need) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
198 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
199 |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
200 if (context->hidden.win32io.buffer.left > 0) { |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
201 void *data = (char *) context->hidden.win32io.buffer.data + |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
202 context->hidden.win32io.buffer.size - |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
203 context->hidden.win32io.buffer.left; |
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2179
diff
changeset
|
204 read_ahead = |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
205 SDL_min(total_need, context->hidden.win32io.buffer.left); |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
206 SDL_memcpy(ptr, data, read_ahead); |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
207 context->hidden.win32io.buffer.left -= read_ahead; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
208 |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
209 if (read_ahead == total_need) { |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
210 return maxnum; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
211 } |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
212 ptr = (char *) ptr + read_ahead; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
213 total_need -= read_ahead; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
214 total_read += read_ahead; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
215 } |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
216 |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
217 if (total_need < READAHEAD_BUFFER_SIZE) { |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
218 if (!ReadFile |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
219 (context->hidden.win32io.h, context->hidden.win32io.buffer.data, |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
220 READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
221 SDL_Error(SDL_EFREAD); |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
222 return 0; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
223 } |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
224 read_ahead = SDL_min(total_need, (int) byte_read); |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
225 SDL_memcpy(ptr, context->hidden.win32io.buffer.data, read_ahead); |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
226 context->hidden.win32io.buffer.size = byte_read; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
227 context->hidden.win32io.buffer.left = byte_read - read_ahead; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
228 total_read += read_ahead; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
229 } else { |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
230 if (!ReadFile |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
231 (context->hidden.win32io.h, ptr, (DWORD)total_need, &byte_read, NULL)) { |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
232 SDL_Error(SDL_EFREAD); |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
233 return 0; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
234 } |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
235 total_read += byte_read; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
236 } |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
237 return (total_read / size); |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
238 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
239 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
240 static size_t SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
241 win32_file_write(SDL_RWops * context, const void *ptr, size_t size, |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
242 size_t num) |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
243 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
244 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
245 size_t total_bytes; |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
246 DWORD byte_written; |
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
247 size_t nwritten; |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
248 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
249 total_bytes = size * num; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
250 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
251 if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
252 || total_bytes <= 0 || !size) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
253 return 0; |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
254 |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
255 if (context->hidden.win32io.buffer.left) { |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
256 SetFilePointer(context->hidden.win32io.h, |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
257 -(LONG)context->hidden.win32io.buffer.left, NULL, |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
258 FILE_CURRENT); |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
259 context->hidden.win32io.buffer.left = 0; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
260 } |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
261 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
262 /* if in append mode, we must go to the EOF before write */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
263 if (context->hidden.win32io.append) { |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
264 if (SetFilePointer(context->hidden.win32io.h, 0L, NULL, FILE_END) == |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
265 INVALID_SET_FILE_POINTER) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
266 SDL_Error(SDL_EFWRITE); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
267 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
268 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
269 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
270 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
271 if (!WriteFile |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
272 (context->hidden.win32io.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
273 SDL_Error(SDL_EFWRITE); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
274 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
275 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
276 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
277 nwritten = byte_written / size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
278 return nwritten; |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
279 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
280 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
281 static int SDLCALL |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
282 win32_file_close(SDL_RWops * context) |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
283 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
284 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
285 if (context) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
286 if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
287 CloseHandle(context->hidden.win32io.h); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
288 context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* to be sure */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
289 } |
2159
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
290 if (context->hidden.win32io.buffer.data) { |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
291 SDL_free(context->hidden.win32io.buffer.data); |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
292 context->hidden.win32io.buffer.data = NULL; |
dd4753e47ed4
Merged read-ahead support for Win32 file I/O from SDL 1.2 revision 3183
Sam Lantinga <slouken@libsdl.org>
parents:
1978
diff
changeset
|
293 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
294 SDL_FreeRW(context); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
295 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
296 return (0); |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
297 } |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
298 #endif /* __WIN32__ */ |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
299 |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
300 #ifdef HAVE_STDIO_H |
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
301 |
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
302 /* Functions to read/write stdio file pointers */ |
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
303 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
304 static long SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
305 stdio_seek(SDL_RWops * context, long offset, int whence) |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
306 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
307 if (fseek(context->hidden.stdio.fp, offset, whence) == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
308 return (ftell(context->hidden.stdio.fp)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
309 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
310 SDL_Error(SDL_EFSEEK); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
311 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
312 } |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
313 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
314 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
315 static size_t SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
316 stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
317 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
318 size_t nread; |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
319 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
320 nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
321 if (nread == 0 && ferror(context->hidden.stdio.fp)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
322 SDL_Error(SDL_EFREAD); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
323 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
324 return (nread); |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
325 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
326 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
327 static size_t SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
328 stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
329 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
330 size_t nwrote; |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
331 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
332 nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
333 if (nwrote == 0 && ferror(context->hidden.stdio.fp)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
334 SDL_Error(SDL_EFWRITE); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
335 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
336 return (nwrote); |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
337 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
338 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
339 static int SDLCALL |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
340 stdio_close(SDL_RWops * context) |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
341 { |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
342 int status = 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
343 if (context) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
344 if (context->hidden.stdio.autoclose) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
345 /* WARNING: Check the return value here! */ |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
346 if (fclose(context->hidden.stdio.fp) != 0) { |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
347 SDL_Error(SDL_EFWRITE); |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
348 status = -1; |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
349 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
350 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
351 SDL_FreeRW(context); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
352 } |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
353 return status; |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
354 } |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
355 #endif /* !HAVE_STDIO_H */ |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
356 |
0 | 357 /* Functions to read/write memory pointers */ |
358 | |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
359 static long SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
360 mem_seek(SDL_RWops * context, long offset, int whence) |
0 | 361 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
362 Uint8 *newpos; |
0 | 363 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
364 switch (whence) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
365 case RW_SEEK_SET: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
366 newpos = context->hidden.mem.base + offset; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
367 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
368 case RW_SEEK_CUR: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
369 newpos = context->hidden.mem.here + offset; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
370 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
371 case RW_SEEK_END: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
372 newpos = context->hidden.mem.stop + offset; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
373 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
374 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
375 SDL_SetError("Unknown value for 'whence'"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
376 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
377 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
378 if (newpos < context->hidden.mem.base) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
379 newpos = context->hidden.mem.base; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
380 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
381 if (newpos > context->hidden.mem.stop) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
382 newpos = context->hidden.mem.stop; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
383 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
384 context->hidden.mem.here = newpos; |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
385 return (long)(context->hidden.mem.here - context->hidden.mem.base); |
0 | 386 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
387 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
388 static size_t SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
389 mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) |
0 | 390 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
391 size_t total_bytes; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
392 size_t mem_available; |
1078
e2ef6b7001fd
Patch from Antonio SJ Musumeci:
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
393 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
394 total_bytes = (maxnum * size); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
395 if ((maxnum <= 0) || (size <= 0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
396 || ((total_bytes / maxnum) != (size_t) size)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
397 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
398 } |
0 | 399 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
400 mem_available = (context->hidden.mem.stop - context->hidden.mem.here); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
401 if (total_bytes > mem_available) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
402 total_bytes = mem_available; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
403 } |
1078
e2ef6b7001fd
Patch from Antonio SJ Musumeci:
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
404 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
405 SDL_memcpy(ptr, context->hidden.mem.here, total_bytes); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
406 context->hidden.mem.here += total_bytes; |
1078
e2ef6b7001fd
Patch from Antonio SJ Musumeci:
Ryan C. Gordon <icculus@icculus.org>
parents:
769
diff
changeset
|
407 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
408 return (total_bytes / size); |
0 | 409 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
410 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
411 static size_t SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
412 mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) |
0 | 413 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
414 if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
415 num = (context->hidden.mem.stop - context->hidden.mem.here) / size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
416 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
417 SDL_memcpy(context->hidden.mem.here, ptr, num * size); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
418 context->hidden.mem.here += num * size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
419 return (num); |
0 | 420 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
421 |
2160
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
422 static size_t SDLCALL |
00adbaed3910
Updated to use size_t instead of int for amounts of data.
Sam Lantinga <slouken@libsdl.org>
parents:
2159
diff
changeset
|
423 mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num) |
764
974c0fb74bf8
Added function to create RWops from const memory: SDL_RWFromConstMem()
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
424 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
425 SDL_SetError("Can't write to read-only memory"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
426 return (-1); |
764
974c0fb74bf8
Added function to create RWops from const memory: SDL_RWFromConstMem()
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
427 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
428 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
429 static int SDLCALL |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
430 mem_close(SDL_RWops * context) |
0 | 431 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
432 if (context) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
433 SDL_FreeRW(context); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
434 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
435 return (0); |
0 | 436 } |
437 | |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
438 |
0 | 439 /* Functions to create SDL_RWops structures from various data sources */ |
440 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
441 SDL_RWops * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
442 SDL_RWFromFile(const char *file, const char *mode) |
0 | 443 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
444 SDL_RWops *rwops = NULL; |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
445 #ifdef HAVE_STDIO_H |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
446 FILE *fp = NULL; |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
447 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
448 if (!file || !*file || !mode || !*mode) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
449 SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
450 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
451 } |
1465
8dfa9a6d69a5
Updated WinCE support by Dmitry (with some tweaks)
Sam Lantinga <slouken@libsdl.org>
parents:
1456
diff
changeset
|
452 #if defined(__WIN32__) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
453 rwops = SDL_AllocRW(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
454 if (!rwops) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
455 return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ |
2164
d083a2e4433d
Merged memory leak fix from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
2161
diff
changeset
|
456 if (win32_file_open(rwops, file, mode) < 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
457 SDL_FreeRW(rwops); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
458 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
459 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
460 rwops->seek = win32_file_seek; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
461 rwops->read = win32_file_read; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
462 rwops->write = win32_file_write; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
463 rwops->close = win32_file_close; |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
464 |
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
465 #elif HAVE_STDIO_H |
4447
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
466 #ifdef __APPLE__ |
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
467 fp = SDL_OpenFPFromBundleOrFallback(file, mode); |
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
468 #else |
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
469 fp = fopen(file, mode); |
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
470 #endif |
947201caa46e
Added automated test to Xcode project plus needed changes to SDL_RWFromFile to be OS X bundle aware.
Eric Wing <ewing . public |-at-| gmail . com>
parents:
3697
diff
changeset
|
471 if (fp == NULL) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
472 SDL_SetError("Couldn't open %s", file); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
473 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
474 rwops = SDL_RWFromFP(fp, 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
475 } |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
476 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
477 SDL_SetError("SDL not compiled with stdio support"); |
1446
47bf1767c4ca
Date: Mon, 27 Feb 2006 02:17:29 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
478 #endif /* !HAVE_STDIO_H */ |
1447
515df0086eb7
Prefer the raw Win32 API over stdio for file RWops
Sam Lantinga <slouken@libsdl.org>
parents:
1446
diff
changeset
|
479 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
480 return (rwops); |
0 | 481 } |
482 | |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
483 #ifdef HAVE_STDIO_H |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
484 SDL_RWops * |
2161
e635db5b45ef
Oh yeah, they're boolean values...
Sam Lantinga <slouken@libsdl.org>
parents:
2160
diff
changeset
|
485 SDL_RWFromFP(FILE * fp, SDL_bool autoclose) |
0 | 486 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
487 SDL_RWops *rwops = NULL; |
0 | 488 |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
489 #if 0 |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
490 /*#ifdef __NDS__*/ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
491 /* set it up so we can use stdio file function */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
492 fatInitDefault(); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
493 printf("called fatInitDefault()"); |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
494 #endif /* __NDS__ */ |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2185
diff
changeset
|
495 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
496 rwops = SDL_AllocRW(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
497 if (rwops != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
498 rwops->seek = stdio_seek; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
499 rwops->read = stdio_read; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
500 rwops->write = stdio_write; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
501 rwops->close = stdio_close; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
502 rwops->hidden.stdio.fp = fp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
503 rwops->hidden.stdio.autoclose = autoclose; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
504 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
505 return (rwops); |
0 | 506 } |
3564
d264d99576c1
Add a dummy function if SDL doesn't have STDIO support
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
507 #else |
d264d99576c1
Add a dummy function if SDL doesn't have STDIO support
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
508 SDL_RWops * |
d264d99576c1
Add a dummy function if SDL doesn't have STDIO support
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
509 SDL_RWFromFP(void * fp, SDL_bool autoclose) |
d264d99576c1
Add a dummy function if SDL doesn't have STDIO support
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
510 { |
d264d99576c1
Add a dummy function if SDL doesn't have STDIO support
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
511 SDL_SetError("SDL not compiled with stdio support"); |
d264d99576c1
Add a dummy function if SDL doesn't have STDIO support
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
512 return NULL; |
d264d99576c1
Add a dummy function if SDL doesn't have STDIO support
Sam Lantinga <slouken@libsdl.org>
parents:
3253
diff
changeset
|
513 } |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
514 #endif /* HAVE_STDIO_H */ |
0 | 515 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
516 SDL_RWops * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
517 SDL_RWFromMem(void *mem, int size) |
0 | 518 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
519 SDL_RWops *rwops; |
0 | 520 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
521 rwops = SDL_AllocRW(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
522 if (rwops != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
523 rwops->seek = mem_seek; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
524 rwops->read = mem_read; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
525 rwops->write = mem_write; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
526 rwops->close = mem_close; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
527 rwops->hidden.mem.base = (Uint8 *) mem; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
528 rwops->hidden.mem.here = rwops->hidden.mem.base; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
529 rwops->hidden.mem.stop = rwops->hidden.mem.base + size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
530 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
531 return (rwops); |
0 | 532 } |
533 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
534 SDL_RWops * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
535 SDL_RWFromConstMem(const void *mem, int size) |
764
974c0fb74bf8
Added function to create RWops from const memory: SDL_RWFromConstMem()
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
536 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
537 SDL_RWops *rwops; |
764
974c0fb74bf8
Added function to create RWops from const memory: SDL_RWFromConstMem()
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
538 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
539 rwops = SDL_AllocRW(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
540 if (rwops != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
541 rwops->seek = mem_seek; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
542 rwops->read = mem_read; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
543 rwops->write = mem_writeconst; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
544 rwops->close = mem_close; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
545 rwops->hidden.mem.base = (Uint8 *) mem; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
546 rwops->hidden.mem.here = rwops->hidden.mem.base; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
547 rwops->hidden.mem.stop = rwops->hidden.mem.base + size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
548 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
549 return (rwops); |
764
974c0fb74bf8
Added function to create RWops from const memory: SDL_RWFromConstMem()
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
550 } |
974c0fb74bf8
Added function to create RWops from const memory: SDL_RWFromConstMem()
Sam Lantinga <slouken@libsdl.org>
parents:
543
diff
changeset
|
551 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
552 SDL_RWops * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
553 SDL_AllocRW(void) |
0 | 554 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
555 SDL_RWops *area; |
0 | 556 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
557 area = (SDL_RWops *) SDL_malloc(sizeof *area); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
558 if (area == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
559 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
560 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
561 return (area); |
0 | 562 } |
563 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
564 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
565 SDL_FreeRW(SDL_RWops * area) |
0 | 566 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
567 SDL_free(area); |
0 | 568 } |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
569 |
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
570 /* Functions for dynamically reading and writing endian-specific values */ |
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
571 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
572 Uint16 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
573 SDL_ReadLE16(SDL_RWops * src) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
574 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
575 Uint16 value; |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
576 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
577 SDL_RWread(src, &value, (sizeof value), 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
578 return (SDL_SwapLE16(value)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
579 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
580 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
581 Uint16 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
582 SDL_ReadBE16(SDL_RWops * src) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
583 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
584 Uint16 value; |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
585 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
586 SDL_RWread(src, &value, (sizeof value), 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
587 return (SDL_SwapBE16(value)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
588 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
589 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
590 Uint32 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
591 SDL_ReadLE32(SDL_RWops * src) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
592 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
593 Uint32 value; |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
594 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
595 SDL_RWread(src, &value, (sizeof value), 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
596 return (SDL_SwapLE32(value)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
597 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
598 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
599 Uint32 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
600 SDL_ReadBE32(SDL_RWops * src) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
601 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
602 Uint32 value; |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
603 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
604 SDL_RWread(src, &value, (sizeof value), 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
605 return (SDL_SwapBE32(value)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
606 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
607 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
608 Uint64 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
609 SDL_ReadLE64(SDL_RWops * src) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
610 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
611 Uint64 value; |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
612 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
613 SDL_RWread(src, &value, (sizeof value), 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
614 return (SDL_SwapLE64(value)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
615 } |
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
616 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
617 Uint64 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
618 SDL_ReadBE64(SDL_RWops * src) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
619 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
620 Uint64 value; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
621 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
622 SDL_RWread(src, &value, (sizeof value), 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
623 return (SDL_SwapBE64(value)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
624 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
625 |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
626 size_t |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
627 SDL_WriteLE16(SDL_RWops * dst, Uint16 value) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
628 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
629 value = SDL_SwapLE16(value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
630 return (SDL_RWwrite(dst, &value, (sizeof value), 1)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
631 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
632 |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
633 size_t |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
634 SDL_WriteBE16(SDL_RWops * dst, Uint16 value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
635 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
636 value = SDL_SwapBE16(value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
637 return (SDL_RWwrite(dst, &value, (sizeof value), 1)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
638 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
639 |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
640 size_t |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
641 SDL_WriteLE32(SDL_RWops * dst, Uint32 value) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
642 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
643 value = SDL_SwapLE32(value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
644 return (SDL_RWwrite(dst, &value, (sizeof value), 1)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
645 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
646 |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
647 size_t |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
648 SDL_WriteBE32(SDL_RWops * dst, Uint32 value) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
649 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
650 value = SDL_SwapBE32(value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
651 return (SDL_RWwrite(dst, &value, (sizeof value), 1)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
652 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
653 |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
654 size_t |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
655 SDL_WriteLE64(SDL_RWops * dst, Uint64 value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
656 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
657 value = SDL_SwapLE64(value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
658 return (SDL_RWwrite(dst, &value, (sizeof value), 1)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
659 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
660 |
3253
5d7ef5970073
Fixed issues building 64-bit Windows binary
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
661 size_t |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
662 SDL_WriteBE64(SDL_RWops * dst, Uint64 value) |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
663 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
664 value = SDL_SwapBE64(value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
665 return (SDL_RWwrite(dst, &value, (sizeof value), 1)); |
1354
22f39393668a
Fixed build problem with SDL_string.c
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
666 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
667 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1769
diff
changeset
|
668 /* vi: set ts=4 sw=4 expandtab: */ |