diff options
author | Jens Arnold <amiconn@rockbox.org> | 2007-02-01 23:08:15 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2007-02-01 23:08:15 +0000 |
commit | 67eb154146ea90cd25a383bcdd4a028704ef2218 (patch) | |
tree | 06b528a996b0ab59b4b3f2b950069c56046a7a10 /uisimulator | |
parent | 98dc093317b615b2aa8ffe8d140945d75764a813 (diff) | |
download | rockbox-67eb154146ea90cd25a383bcdd4a028704ef2218.tar.gz rockbox-67eb154146ea90cd25a383bcdd4a028704ef2218.zip |
Removed 'mode' parameter from creat(). It wasn't pure posix anyway, it was ignored on target and mixed into 'oflags' in the simulator. * Simplified io.c a bit by defining a dummy O_BINARY for OSes which don't have that.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12179 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/common/io.c | 27 | ||||
-rw-r--r-- | uisimulator/sdl/lcd-charcell.c | 4 |
2 files changed, 14 insertions, 17 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index ca64affa8c..ca597e0805 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c | |||
@@ -50,6 +50,12 @@ | |||
50 | #include "debug.h" | 50 | #include "debug.h" |
51 | #include "config.h" | 51 | #include "config.h" |
52 | 52 | ||
53 | /* Windows (and potentially other OSes) distinguish binary and text files. | ||
54 | * Define a dummy for the others. */ | ||
55 | #ifndef O_BINARY | ||
56 | #define O_BINARY 0 | ||
57 | #endif | ||
58 | |||
53 | #ifdef HAVE_DIRCACHE | 59 | #ifdef HAVE_DIRCACHE |
54 | void dircache_remove(const char *name); | 60 | void dircache_remove(const char *name); |
55 | void dircache_rename(const char *oldpath, const char *newpath); | 61 | void dircache_rename(const char *oldpath, const char *newpath); |
@@ -81,11 +87,8 @@ typedef struct mydir MYDIR; | |||
81 | #if 1 /* maybe this needs disabling for MSVC... */ | 87 | #if 1 /* maybe this needs disabling for MSVC... */ |
82 | static unsigned int rockbox2sim(int opt) | 88 | static unsigned int rockbox2sim(int opt) |
83 | { | 89 | { |
84 | #ifdef WIN32 | ||
85 | int newopt = O_BINARY; | 90 | int newopt = O_BINARY; |
86 | #else | 91 | |
87 | int newopt = 0; | ||
88 | #endif | ||
89 | if(opt & 1) | 92 | if(opt & 1) |
90 | newopt |= O_WRONLY; | 93 | newopt |= O_WRONLY; |
91 | if(opt & 2) | 94 | if(opt & 2) |
@@ -189,24 +192,22 @@ int sim_open(const char *name, int o) | |||
189 | 192 | ||
190 | } | 193 | } |
191 | 194 | ||
192 | int sim_creat(const char *name, mode_t mode) | 195 | int sim_creat(const char *name) |
193 | { | 196 | { |
194 | int opts = rockbox2sim(mode); | ||
195 | |||
196 | #ifndef __PCTOOL__ | 197 | #ifndef __PCTOOL__ |
197 | char buffer[256]; /* sufficiently big */ | 198 | char buffer[256]; /* sufficiently big */ |
198 | if(name[0] == '/') | 199 | if(name[0] == '/') |
199 | { | 200 | { |
200 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); | 201 | sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name); |
201 | 202 | ||
202 | debugf("We create the real file '%s'\n", buffer); | 203 | debugf("We create the real file '%s'\n", buffer); |
203 | return open(buffer, opts | O_CREAT | O_TRUNC, 0666); | 204 | return open(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666); |
204 | } | 205 | } |
205 | fprintf(stderr, "WARNING, bad file name lacks slash: %s\n", | 206 | fprintf(stderr, "WARNING, bad file name lacks slash: %s\n", |
206 | name); | 207 | name); |
207 | return -1; | 208 | return -1; |
208 | #else | 209 | #else |
209 | return open(name, opts | O_CREAT | O_TRUNC, 0666); | 210 | return open(name, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666); |
210 | #endif | 211 | #endif |
211 | } | 212 | } |
212 | 213 | ||
@@ -390,15 +391,11 @@ void *sim_codec_load_ram(char* codecptr, int size, | |||
390 | { | 391 | { |
391 | sprintf(path, TEMP_CODEC_FILE, codec_count); | 392 | sprintf(path, TEMP_CODEC_FILE, codec_count); |
392 | 393 | ||
393 | #ifdef WIN32 | ||
394 | fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU); | 394 | fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU); |
395 | #else | ||
396 | fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU); | ||
397 | #endif | ||
398 | if (fd >= 0) | 395 | if (fd >= 0) |
399 | break; /* Created a file ok */ | 396 | break; /* Created a file ok */ |
400 | } | 397 | } |
401 | if (fd < 0) | 398 | if (fd < 0) |
402 | { | 399 | { |
403 | DEBUGF("failed to open for write: %s\n", path); | 400 | DEBUGF("failed to open for write: %s\n", path); |
404 | return NULL; | 401 | return NULL; |
diff --git a/uisimulator/sdl/lcd-charcell.c b/uisimulator/sdl/lcd-charcell.c index 28ce0917c0..59ae39a248 100644 --- a/uisimulator/sdl/lcd-charcell.c +++ b/uisimulator/sdl/lcd-charcell.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "lcd-sdl.h" | 29 | #include "lcd-sdl.h" |
30 | 30 | ||
31 | /* extern functions, needed for screendump() */ | 31 | /* extern functions, needed for screendump() */ |
32 | extern int sim_creat(const char *name, mode_t mode); | 32 | extern int sim_creat(const char *name); |
33 | 33 | ||
34 | SDL_Surface* lcd_surface; | 34 | SDL_Surface* lcd_surface; |
35 | SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; | 35 | SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; |
@@ -185,7 +185,7 @@ void screen_dump(void) | |||
185 | IF_CNFN_NUM_(, NULL)); | 185 | IF_CNFN_NUM_(, NULL)); |
186 | DEBUGF("screen_dump\n"); | 186 | DEBUGF("screen_dump\n"); |
187 | 187 | ||
188 | fd = sim_creat(filename, O_WRONLY); | 188 | fd = sim_creat(filename); |
189 | if (fd < 0) | 189 | if (fd < 0) |
190 | return; | 190 | return; |
191 | 191 | ||