summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-02-01 23:08:15 +0000
committerJens Arnold <amiconn@rockbox.org>2007-02-01 23:08:15 +0000
commit67eb154146ea90cd25a383bcdd4a028704ef2218 (patch)
tree06b528a996b0ab59b4b3f2b950069c56046a7a10
parent98dc093317b615b2aa8ffe8d140945d75764a813 (diff)
downloadrockbox-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
-rw-r--r--apps/codecs.h6
-rw-r--r--apps/debug_menu.c12
-rw-r--r--apps/eq_menu.c2
-rw-r--r--apps/misc.c2
-rw-r--r--apps/onplay.c2
-rw-r--r--apps/plugin.h6
-rw-r--r--apps/plugins/calendar.c4
-rw-r--r--apps/plugins/clock.c2
-rw-r--r--apps/plugins/iriverify.c2
-rw-r--r--apps/plugins/lib/bmp.c2
-rw-r--r--apps/plugins/lib/configfile.c2
-rw-r--r--apps/plugins/search.c2
-rw-r--r--apps/plugins/sort.c2
-rw-r--r--apps/plugins/test_disk.c4
-rw-r--r--apps/plugins/vbrfix.c2
-rw-r--r--apps/plugins/viewer.c6
-rw-r--r--apps/plugins/vu_meter.c2
-rw-r--r--apps/plugins/wav2wv.c2
-rw-r--r--apps/plugins/zxbox/snapshot.c2
-rw-r--r--apps/recorder/radio.c2
-rw-r--r--apps/tree.c2
-rw-r--r--firmware/common/file.c3
-rw-r--r--firmware/font.c2
-rw-r--r--firmware/include/file.h6
-rw-r--r--uisimulator/common/io.c27
-rw-r--r--uisimulator/sdl/lcd-charcell.c4
26 files changed, 53 insertions, 57 deletions
diff --git a/apps/codecs.h b/apps/codecs.h
index cef14c3971..730bacb6df 100644
--- a/apps/codecs.h
+++ b/apps/codecs.h
@@ -90,12 +90,12 @@
90#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */ 90#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
91 91
92/* increase this every time the api struct changes */ 92/* increase this every time the api struct changes */
93#define CODEC_API_VERSION 10 93#define CODEC_API_VERSION 11
94 94
95/* update this to latest version if a change to the api struct breaks 95/* update this to latest version if a change to the api struct breaks
96 backwards compatibility (and please take the opportunity to sort in any 96 backwards compatibility (and please take the opportunity to sort in any
97 new function which are "waiting" at the end of the function table) */ 97 new function which are "waiting" at the end of the function table) */
98#define CODEC_MIN_API_VERSION 10 98#define CODEC_MIN_API_VERSION 11
99 99
100/* codec return codes */ 100/* codec return codes */
101enum codec_status { 101enum codec_status {
@@ -174,7 +174,7 @@ struct codec_api {
174 int (*close)(int fd); 174 int (*close)(int fd);
175 ssize_t (*read)(int fd, void* buf, size_t count); 175 ssize_t (*read)(int fd, void* buf, size_t count);
176 off_t (*PREFIX(lseek))(int fd, off_t offset, int whence); 176 off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
177 int (*PREFIX(creat))(const char *pathname, mode_t mode); 177 int (*PREFIX(creat))(const char *pathname);
178 ssize_t (*write)(int fd, const void* buf, size_t count); 178 ssize_t (*write)(int fd, const void* buf, size_t count);
179 int (*PREFIX(remove))(const char* pathname); 179 int (*PREFIX(remove))(const char* pathname);
180 int (*PREFIX(rename))(const char* path, const char* newname); 180 int (*PREFIX(rename))(const char* path, const char* newname);
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 99c00fa1eb..1551b94439 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1933,14 +1933,14 @@ static bool dbg_save_roms(void)
1933 int fd; 1933 int fd;
1934 int oldmode = system_memory_guard(MEMGUARD_NONE); 1934 int oldmode = system_memory_guard(MEMGUARD_NONE);
1935 1935
1936 fd = creat("/internal_rom_0000-FFFF.bin", O_WRONLY); 1936 fd = creat("/internal_rom_0000-FFFF.bin");
1937 if(fd >= 0) 1937 if(fd >= 0)
1938 { 1938 {
1939 write(fd, (void *)0, 0x10000); 1939 write(fd, (void *)0, 0x10000);
1940 close(fd); 1940 close(fd);
1941 } 1941 }
1942 1942
1943 fd = creat("/internal_rom_2000000-203FFFF.bin", O_WRONLY); 1943 fd = creat("/internal_rom_2000000-203FFFF.bin");
1944 if(fd >= 0) 1944 if(fd >= 0)
1945 { 1945 {
1946 write(fd, (void *)0x2000000, 0x40000); 1946 write(fd, (void *)0x2000000, 0x40000);
@@ -1957,11 +1957,11 @@ static bool dbg_save_roms(void)
1957 int oldmode = system_memory_guard(MEMGUARD_NONE); 1957 int oldmode = system_memory_guard(MEMGUARD_NONE);
1958 1958
1959#if defined(IRIVER_H100_SERIES) 1959#if defined(IRIVER_H100_SERIES)
1960 fd = creat("/internal_rom_000000-1FFFFF.bin", O_WRONLY); 1960 fd = creat("/internal_rom_000000-1FFFFF.bin");
1961#elif defined(IRIVER_H300_SERIES) 1961#elif defined(IRIVER_H300_SERIES)
1962 fd = creat("/internal_rom_000000-3FFFFF.bin", O_WRONLY); 1962 fd = creat("/internal_rom_000000-3FFFFF.bin");
1963#elif defined(IAUDIO_X5) 1963#elif defined(IAUDIO_X5)
1964 fd = creat("/internal_rom_000000-3FFFFF.bin", O_WRONLY); 1964 fd = creat("/internal_rom_000000-3FFFFF.bin");
1965#endif 1965#endif
1966 if(fd >= 0) 1966 if(fd >= 0)
1967 { 1967 {
@@ -1971,7 +1971,7 @@ static bool dbg_save_roms(void)
1971 system_memory_guard(oldmode); 1971 system_memory_guard(oldmode);
1972 1972
1973#ifdef HAVE_EEPROM 1973#ifdef HAVE_EEPROM
1974 fd = creat("/internal_eeprom.bin", O_WRONLY); 1974 fd = creat("/internal_eeprom.bin");
1975 if (fd >= 0) 1975 if (fd >= 0)
1976 { 1976 {
1977 int old_irq_level; 1977 int old_irq_level;
diff --git a/apps/eq_menu.c b/apps/eq_menu.c
index 798b05d304..beaf385366 100644
--- a/apps/eq_menu.c
+++ b/apps/eq_menu.c
@@ -716,7 +716,7 @@ static bool eq_save_preset(void)
716 /* allow user to modify filename */ 716 /* allow user to modify filename */
717 while (true) { 717 while (true) {
718 if (!kbd_input(filename, sizeof filename)) { 718 if (!kbd_input(filename, sizeof filename)) {
719 fd = creat(filename, O_WRONLY); 719 fd = creat(filename);
720 if (fd < 0) 720 if (fd < 0)
721 gui_syncsplash(HZ, true, str(LANG_FAILED)); 721 gui_syncsplash(HZ, true, str(LANG_FAILED));
722 else 722 else
diff --git a/apps/misc.c b/apps/misc.c
index 09a7c2ebe6..8487da0d98 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -399,7 +399,7 @@ void screen_dump(void)
399 IF_CNFN_NUM_(, NULL)); 399 IF_CNFN_NUM_(, NULL));
400#endif 400#endif
401 401
402 fh = creat(filename, O_WRONLY); 402 fh = creat(filename);
403 if (fh < 0) 403 if (fh < 0)
404 return; 404 return;
405 405
diff --git a/apps/onplay.c b/apps/onplay.c
index 5e7d1e0fe2..b69999dd2c 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -638,7 +638,7 @@ static bool clipboard_pastefile(const char *src, const char *target, bool copy)
638 src_fd = open(src, O_RDONLY); 638 src_fd = open(src, O_RDONLY);
639 639
640 if (src_fd >= 0) { 640 if (src_fd >= 0) {
641 target_fd = creat(target, O_WRONLY); 641 target_fd = creat(target);
642 642
643 if (target_fd >= 0) { 643 if (target_fd >= 0) {
644 result = true; 644 result = true;
diff --git a/apps/plugin.h b/apps/plugin.h
index 70b5ebf354..ad09a71049 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -110,12 +110,12 @@
110#define PLUGIN_MAGIC 0x526F634B /* RocK */ 110#define PLUGIN_MAGIC 0x526F634B /* RocK */
111 111
112/* increase this every time the api struct changes */ 112/* increase this every time the api struct changes */
113#define PLUGIN_API_VERSION 41 113#define PLUGIN_API_VERSION 42
114 114
115/* update this to latest version if a change to the api struct breaks 115/* update this to latest version if a change to the api struct breaks
116 backwards compatibility (and please take the opportunity to sort in any 116 backwards compatibility (and please take the opportunity to sort in any
117 new function which are "waiting" at the end of the function table) */ 117 new function which are "waiting" at the end of the function table) */
118#define PLUGIN_MIN_API_VERSION 41 118#define PLUGIN_MIN_API_VERSION 42
119 119
120/* plugin return codes */ 120/* plugin return codes */
121enum plugin_status { 121enum plugin_status {
@@ -300,7 +300,7 @@ struct plugin_api {
300 int (*close)(int fd); 300 int (*close)(int fd);
301 ssize_t (*read)(int fd, void* buf, size_t count); 301 ssize_t (*read)(int fd, void* buf, size_t count);
302 off_t (*PREFIX(lseek))(int fd, off_t offset, int whence); 302 off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
303 int (*PREFIX(creat))(const char *pathname, mode_t mode); 303 int (*PREFIX(creat))(const char *pathname);
304 ssize_t (*write)(int fd, const void* buf, size_t count); 304 ssize_t (*write)(int fd, const void* buf, size_t count);
305 int (*PREFIX(remove))(const char* pathname); 305 int (*PREFIX(remove))(const char* pathname);
306 int (*PREFIX(rename))(const char* path, const char* newname); 306 int (*PREFIX(rename))(const char* path, const char* newname);
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index a57cadedd2..34af4746a9 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -316,7 +316,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
316{ 316{
317 int fp,fq; 317 int fp,fq;
318 fp = rb->open("/.rockbox/.memo",O_RDONLY | O_CREAT); 318 fp = rb->open("/.rockbox/.memo",O_RDONLY | O_CREAT);
319 fq = rb->creat("/.rockbox/~temp", O_WRONLY); 319 fq = rb->creat("/.rockbox/~temp");
320 if ( (fq != -1) && (fp != -1) ) 320 if ( (fq != -1) && (fp != -1) )
321 { 321 {
322 int i; 322 int i;
@@ -345,7 +345,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
345 rb->write(fq,temp,1); 345 rb->write(fq,temp,1);
346 } 346 }
347 rb->close(fp); 347 rb->close(fp);
348 fp = rb->creat("/.rockbox/.memo", O_WRONLY); 348 fp = rb->creat("/.rockbox/.memo");
349 rb->lseek(fp, 0, SEEK_SET); 349 rb->lseek(fp, 0, SEEK_SET);
350 rb->lseek(fq, 0, SEEK_SET); 350 rb->lseek(fq, 0, SEEK_SET);
351 for (i = 0; i < rb->filesize(fq); i++) 351 for (i = 0; i < rb->filesize(fq); i++)
diff --git a/apps/plugins/clock.c b/apps/plugins/clock.c
index 28cd223795..19c7dac4aa 100644
--- a/apps/plugins/clock.c
+++ b/apps/plugins/clock.c
@@ -903,7 +903,7 @@ void save_settings(bool interface)
903 rb->lcd_update(); 903 rb->lcd_update();
904 } 904 }
905 905
906 fd = rb->creat(default_filename, O_WRONLY); /* create the settings file */ 906 fd = rb->creat(default_filename); /* create the settings file */
907 907
908 if(fd >= 0) /* file exists, save successful */ 908 if(fd >= 0) /* file exists, save successful */
909 { 909 {
diff --git a/apps/plugins/iriverify.c b/apps/plugins/iriverify.c
index 47cb385f0f..555c9200e3 100644
--- a/apps/plugins/iriverify.c
+++ b/apps/plugins/iriverify.c
@@ -67,7 +67,7 @@ static int write_file(void)
67 67
68 rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename); 68 rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename);
69 69
70 fd = rb->creat(tmpfilename, O_WRONLY); 70 fd = rb->creat(tmpfilename);
71 if(fd < 0) 71 if(fd < 0)
72 return 10 * fd - 1; 72 return 10 * fd - 1;
73 73
diff --git a/apps/plugins/lib/bmp.c b/apps/plugins/lib/bmp.c
index 18968af7c1..dc8432f76a 100644
--- a/apps/plugins/lib/bmp.c
+++ b/apps/plugins/lib/bmp.c
@@ -56,7 +56,7 @@ int save_bmp_file( char* filename, struct bitmap *bm, struct plugin_api* rb )
56 int fh; 56 int fh;
57 int x,y; 57 int x,y;
58 if( bm->format != FORMAT_NATIVE ) return -1; 58 if( bm->format != FORMAT_NATIVE ) return -1;
59 fh = rb->PREFIX(creat)( filename, O_WRONLY ); 59 fh = rb->creat( filename );
60 if( fh < 0 ) return -1; 60 if( fh < 0 ) return -1;
61 61
62 rb->write( fh, header, sizeof( header ) ); 62 rb->write( fh, header, sizeof( header ) );
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c
index d5b60bcfbc..3ca38052e5 100644
--- a/apps/plugins/lib/configfile.c
+++ b/apps/plugins/lib/configfile.c
@@ -34,7 +34,7 @@ int configfile_save(const char *filename, struct configdata *cfg,
34 char buf[MAX_PATH]; 34 char buf[MAX_PATH];
35 35
36 cfg_rb->snprintf(buf, MAX_PATH, "/.rockbox/rocks/%s", filename); 36 cfg_rb->snprintf(buf, MAX_PATH, "/.rockbox/rocks/%s", filename);
37 fd = cfg_rb->creat(buf, O_WRONLY); 37 fd = cfg_rb->creat(buf);
38 if(fd < 0) 38 if(fd < 0)
39 return fd*10 - 1; 39 return fd*10 - 1;
40 40
diff --git a/apps/plugins/search.c b/apps/plugins/search.c
index c174abfd24..5a30ce6064 100644
--- a/apps/plugins/search.c
+++ b/apps/plugins/search.c
@@ -126,7 +126,7 @@ static bool search_init(char* file)
126 if (fd==-1) 126 if (fd==-1)
127 return false; 127 return false;
128 128
129 fdw = rb->creat(resultfile, O_WRONLY); 129 fdw = rb->creat(resultfile);
130 130
131 if (fdw < 0) { 131 if (fdw < 0) {
132#ifdef HAVE_LCD_BITMAP 132#ifdef HAVE_LCD_BITMAP
diff --git a/apps/plugins/sort.c b/apps/plugins/sort.c
index 77342f33e9..80ef22fa44 100644
--- a/apps/plugins/sort.c
+++ b/apps/plugins/sort.c
@@ -140,7 +140,7 @@ static int write_file(void)
140 140
141 /* Create a temporary file */ 141 /* Create a temporary file */
142 rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename); 142 rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename);
143 fd = rb->creat(tmpfilename, O_WRONLY); 143 fd = rb->creat(tmpfilename);
144 if(fd < 0) 144 if(fd < 0)
145 return 10 * fd - 1; 145 return 10 * fd - 1;
146 146
diff --git a/apps/plugins/test_disk.c b/apps/plugins/test_disk.c
index 3292cfa930..edc1dfbddb 100644
--- a/apps/plugins/test_disk.c
+++ b/apps/plugins/test_disk.c
@@ -102,7 +102,7 @@ static bool test_fs(void)
102 rb->snprintf(text_buf, sizeof text_buf, "FS stress test: %dKB", (TEST_SIZE>>10)); 102 rb->snprintf(text_buf, sizeof text_buf, "FS stress test: %dKB", (TEST_SIZE>>10));
103 log_lcd(text_buf, true); 103 log_lcd(text_buf, true);
104 104
105 fd = rb->creat(TEST_FILE, 0); 105 fd = rb->creat(TEST_FILE);
106 if (fd < 0) 106 if (fd < 0)
107 { 107 {
108 rb->splash(0, true, "Couldn't create testfile."); 108 rb->splash(0, true, "Couldn't create testfile.");
@@ -193,7 +193,7 @@ static bool test_speed(void)
193 log_init(); 193 log_init();
194 log_lcd("Disk speed test", true); 194 log_lcd("Disk speed test", true);
195 195
196 fd = rb->creat(TEST_FILE, 0); 196 fd = rb->creat(TEST_FILE);
197 if (fd < 0) 197 if (fd < 0)
198 { 198 {
199 rb->splash(0, true, "Couldn't create testfile."); 199 rb->splash(0, true, "Couldn't create testfile.");
diff --git a/apps/plugins/vbrfix.c b/apps/plugins/vbrfix.c
index d05419f19c..9bdaf493f9 100644
--- a/apps/plugins/vbrfix.c
+++ b/apps/plugins/vbrfix.c
@@ -50,7 +50,7 @@ static int insert_data_in_file(char *fname, int fpos, char *buf, int num_bytes)
50 return 10*orig_fd - 1; 50 return 10*orig_fd - 1;
51 } 51 }
52 52
53 fd = rb->creat(tmpname, O_WRONLY); 53 fd = rb->creat(tmpname);
54 if(fd < 0) { 54 if(fd < 0) {
55 rb->close(orig_fd); 55 rb->close(orig_fd);
56 return 10*fd - 2; 56 return 10*fd - 2;
diff --git a/apps/plugins/viewer.c b/apps/plugins/viewer.c
index a8ef5eb1e8..8590283c57 100644
--- a/apps/plugins/viewer.c
+++ b/apps/plugins/viewer.c
@@ -1074,7 +1074,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same
1074 if (i < data->bookmarked_files_count) 1074 if (i < data->bookmarked_files_count)
1075 { 1075 {
1076 /* it is in the list, write everything back in the correct order, and reload the file correctly */ 1076 /* it is in the list, write everything back in the correct order, and reload the file correctly */
1077 settings_fd = rb->creat(BOOKMARKS_FILE, O_WRONLY); 1077 settings_fd = rb->creat(BOOKMARKS_FILE);
1078 if (settings_fd >=0 ) 1078 if (settings_fd >=0 )
1079 { 1079 {
1080 if (data->bookmarked_files_count > MAX_BOOKMARKED_FILES) 1080 if (data->bookmarked_files_count > MAX_BOOKMARKED_FILES)
@@ -1092,7 +1092,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same
1092 } 1092 }
1093 else /* not in list, write the list to the file */ 1093 else /* not in list, write the list to the file */
1094 { 1094 {
1095 settings_fd = rb->creat(BOOKMARKS_FILE, O_WRONLY); 1095 settings_fd = rb->creat(BOOKMARKS_FILE);
1096 if (settings_fd >=0 ) 1096 if (settings_fd >=0 )
1097 { 1097 {
1098 if (++(data->bookmarked_files_count) > MAX_BOOKMARKED_FILES) 1098 if (++(data->bookmarked_files_count) > MAX_BOOKMARKED_FILES)
@@ -1120,7 +1120,7 @@ static void viewer_load_settings(void) /* same name as global, but not the same
1120static void viewer_save_settings(void)/* same name as global, but not the same file.. */ 1120static void viewer_save_settings(void)/* same name as global, but not the same file.. */
1121{ 1121{
1122 int settings_fd; 1122 int settings_fd;
1123 settings_fd = rb->creat(SETTINGS_FILE, O_WRONLY); /* create the settings file */ 1123 settings_fd = rb->creat(SETTINGS_FILE); /* create the settings file */
1124 1124
1125 rb->write (settings_fd, &prefs, sizeof(struct preferences)); 1125 rb->write (settings_fd, &prefs, sizeof(struct preferences));
1126 rb->close(settings_fd); 1126 rb->close(settings_fd);
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index cbfc0ee5b8..4a68088270 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -335,7 +335,7 @@ void load_settings(void) {
335} 335}
336 336
337void save_settings(void) { 337void save_settings(void) {
338 int fp = rb->creat("/.rockbox/rocks/.vu_meter", O_WRONLY); 338 int fp = rb->creat("/.rockbox/rocks/.vu_meter");
339 if(fp >= 0) { 339 if(fp >= 0) {
340 rb->write (fp, &settings, sizeof(struct saved_settings)); 340 rb->write (fp, &settings, sizeof(struct saved_settings));
341 rb->close(fp); 341 rb->close(fp);
diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c
index 5b71e7e759..2e2076c0ed 100644
--- a/apps/plugins/wav2wv.c
+++ b/apps/plugins/wav2wv.c
@@ -174,7 +174,7 @@ static int wav2wv (char *filename)
174 extension [1] = extension [2]; 174 extension [1] = extension [2];
175 extension [2] = 0; 175 extension [2] = 0;
176 176
177 out_fd = rb->creat (filename, O_WRONLY); 177 out_fd = rb->creat (filename);
178 178
179 extension [2] = extension [1]; 179 extension [2] = extension [1];
180 extension [1] = save_a; 180 extension [1] = save_a;
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c
index c67b7a8f39..d89e533d9e 100644
--- a/apps/plugins/zxbox/snapshot.c
+++ b/apps/plugins/zxbox/snapshot.c
@@ -586,7 +586,7 @@ static void save_snapshot_file_type(char *name, int type)
586 int snsh; 586 int snsh;
587 snsh = rb->open(name, O_WRONLY); 587 snsh = rb->open(name, O_WRONLY);
588 if(snsh < 0) { 588 if(snsh < 0) {
589 snsh = rb->creat(name, O_WRONLY); 589 snsh = rb->creat(name);
590 if(snsh < 0) { 590 if(snsh < 0) {
591 put_msg("Could not create snapshot file"); 591 put_msg("Could not create snapshot file");
592 return; 592 return;
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 45ddd3e0ad..22ae7b0696 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -972,7 +972,7 @@ static void radio_save_presets(void)
972 int fd; 972 int fd;
973 int i; 973 int i;
974 974
975 fd = creat(filepreset, O_WRONLY); 975 fd = creat(filepreset);
976 if(fd >= 0) 976 if(fd >= 0)
977 { 977 {
978 for(i = 0;i < num_presets;i++) 978 for(i = 0;i < num_presets;i++)
diff --git a/apps/tree.c b/apps/tree.c
index 7869696514..8d70eb8bd4 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -1226,7 +1226,7 @@ bool create_playlist(void)
1226 gui_textarea_update(&screens[i]); 1226 gui_textarea_update(&screens[i]);
1227#endif 1227#endif
1228 } 1228 }
1229 fd = creat(filename, O_WRONLY); 1229 fd = creat(filename);
1230 if (fd < 0) 1230 if (fd < 0)
1231 return false; 1231 return false;
1232 1232
diff --git a/firmware/common/file.c b/firmware/common/file.c
index e24b44ce1f..830a7eef8a 100644
--- a/firmware/common/file.c
+++ b/firmware/common/file.c
@@ -52,9 +52,8 @@ static struct filedesc openfiles[MAX_OPEN_FILES];
52 52
53static int flush_cache(int fd); 53static int flush_cache(int fd);
54 54
55int creat(const char *pathname, mode_t mode) 55int creat(const char *pathname)
56{ 56{
57 (void)mode;
58 return open(pathname, O_WRONLY|O_CREAT|O_TRUNC); 57 return open(pathname, O_WRONLY|O_CREAT|O_TRUNC);
59} 58}
60 59
diff --git a/firmware/font.c b/firmware/font.c
index 40f99b330d..6b1f51a24e 100644
--- a/firmware/font.c
+++ b/firmware/font.c
@@ -522,7 +522,7 @@ void glyph_cache_save(void)
522 522
523 if (fnt_file >= 0) { 523 if (fnt_file >= 0) {
524 524
525 glyph_file = creat(GLYPH_CACHE_FILE, O_WRONLY); 525 glyph_file = creat(GLYPH_CACHE_FILE);
526 526
527 if (glyph_file < 0) return; 527 if (glyph_file < 0) return;
528 528
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 3db6507290..7b4b99aa79 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -48,7 +48,7 @@
48 48
49#ifdef SIMULATOR 49#ifdef SIMULATOR
50#define open(x,y) sim_open(x,y) 50#define open(x,y) sim_open(x,y)
51#define creat(x,y) sim_creat(x,y) 51#define creat(x) sim_creat(x)
52#define remove(x) sim_remove(x) 52#define remove(x) sim_remove(x)
53#define rename(x,y) sim_rename(x,y) 53#define rename(x,y) sim_rename(x,y)
54#define filesize(x) sim_filesize(x) 54#define filesize(x) sim_filesize(x)
@@ -59,7 +59,7 @@
59 59
60typedef int (*open_func)(const char* pathname, int flags); 60typedef int (*open_func)(const char* pathname, int flags);
61typedef ssize_t (*read_func)(int fd, void *buf, size_t count); 61typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
62typedef int (*creat_func)(const char *pathname, mode_t mode); 62typedef int (*creat_func)(const char *pathname);
63typedef ssize_t (*write_func)(int fd, const void *buf, size_t count); 63typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
64typedef void (*qsort_func)(void *base, size_t nmemb, size_t size, 64typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
65 int(*_compar)(const void *, const void *)); 65 int(*_compar)(const void *, const void *));
@@ -69,7 +69,7 @@ extern int close(int fd);
69extern int fsync(int fd); 69extern int fsync(int fd);
70extern ssize_t read(int fd, void *buf, size_t count); 70extern ssize_t read(int fd, void *buf, size_t count);
71extern off_t lseek(int fildes, off_t offset, int whence); 71extern off_t lseek(int fildes, off_t offset, int whence);
72extern int creat(const char *pathname, mode_t mode); 72extern int creat(const char *pathname);
73extern ssize_t write(int fd, const void *buf, size_t count); 73extern ssize_t write(int fd, const void *buf, size_t count);
74extern int remove(const char* pathname); 74extern int remove(const char* pathname);
75extern int rename(const char* path, const char* newname); 75extern int rename(const char* path, const char* newname);
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
54void dircache_remove(const char *name); 60void dircache_remove(const char *name);
55void dircache_rename(const char *oldpath, const char *newpath); 61void 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... */
82static unsigned int rockbox2sim(int opt) 88static 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
192int sim_creat(const char *name, mode_t mode) 195int 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() */
32extern int sim_creat(const char *name, mode_t mode); 32extern int sim_creat(const char *name);
33 33
34SDL_Surface* lcd_surface; 34SDL_Surface* lcd_surface;
35SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0}; 35SDL_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