summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 @@
#define CODEC_ENC_MAGIC 0x52454E43 /* RENC */
/* increase this every time the api struct changes */
-#define CODEC_API_VERSION 10
+#define CODEC_API_VERSION 11
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define CODEC_MIN_API_VERSION 10
+#define CODEC_MIN_API_VERSION 11
/* codec return codes */
enum codec_status {
@@ -174,7 +174,7 @@ struct codec_api {
int (*close)(int fd);
ssize_t (*read)(int fd, void* buf, size_t count);
off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
- int (*PREFIX(creat))(const char *pathname, mode_t mode);
+ int (*PREFIX(creat))(const char *pathname);
ssize_t (*write)(int fd, const void* buf, size_t count);
int (*PREFIX(remove))(const char* pathname);
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)
int fd;
int oldmode = system_memory_guard(MEMGUARD_NONE);
- fd = creat("/internal_rom_0000-FFFF.bin", O_WRONLY);
+ fd = creat("/internal_rom_0000-FFFF.bin");
if(fd >= 0)
{
write(fd, (void *)0, 0x10000);
close(fd);
}
- fd = creat("/internal_rom_2000000-203FFFF.bin", O_WRONLY);
+ fd = creat("/internal_rom_2000000-203FFFF.bin");
if(fd >= 0)
{
write(fd, (void *)0x2000000, 0x40000);
@@ -1957,11 +1957,11 @@ static bool dbg_save_roms(void)
int oldmode = system_memory_guard(MEMGUARD_NONE);
#if defined(IRIVER_H100_SERIES)
- fd = creat("/internal_rom_000000-1FFFFF.bin", O_WRONLY);
+ fd = creat("/internal_rom_000000-1FFFFF.bin");
#elif defined(IRIVER_H300_SERIES)
- fd = creat("/internal_rom_000000-3FFFFF.bin", O_WRONLY);
+ fd = creat("/internal_rom_000000-3FFFFF.bin");
#elif defined(IAUDIO_X5)
- fd = creat("/internal_rom_000000-3FFFFF.bin", O_WRONLY);
+ fd = creat("/internal_rom_000000-3FFFFF.bin");
#endif
if(fd >= 0)
{
@@ -1971,7 +1971,7 @@ static bool dbg_save_roms(void)
system_memory_guard(oldmode);
#ifdef HAVE_EEPROM
- fd = creat("/internal_eeprom.bin", O_WRONLY);
+ fd = creat("/internal_eeprom.bin");
if (fd >= 0)
{
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)
/* allow user to modify filename */
while (true) {
if (!kbd_input(filename, sizeof filename)) {
- fd = creat(filename, O_WRONLY);
+ fd = creat(filename);
if (fd < 0)
gui_syncsplash(HZ, true, str(LANG_FAILED));
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)
IF_CNFN_NUM_(, NULL));
#endif
- fh = creat(filename, O_WRONLY);
+ fh = creat(filename);
if (fh < 0)
return;
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)
src_fd = open(src, O_RDONLY);
if (src_fd >= 0) {
- target_fd = creat(target, O_WRONLY);
+ target_fd = creat(target);
if (target_fd >= 0) {
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 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 41
+#define PLUGIN_API_VERSION 42
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */
-#define PLUGIN_MIN_API_VERSION 41
+#define PLUGIN_MIN_API_VERSION 42
/* plugin return codes */
enum plugin_status {
@@ -300,7 +300,7 @@ struct plugin_api {
int (*close)(int fd);
ssize_t (*read)(int fd, void* buf, size_t count);
off_t (*PREFIX(lseek))(int fd, off_t offset, int whence);
- int (*PREFIX(creat))(const char *pathname, mode_t mode);
+ int (*PREFIX(creat))(const char *pathname);
ssize_t (*write)(int fd, const void* buf, size_t count);
int (*PREFIX(remove))(const char* pathname);
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)
{
int fp,fq;
fp = rb->open("/.rockbox/.memo",O_RDONLY | O_CREAT);
- fq = rb->creat("/.rockbox/~temp", O_WRONLY);
+ fq = rb->creat("/.rockbox/~temp");
if ( (fq != -1) && (fp != -1) )
{
int i;
@@ -345,7 +345,7 @@ static bool save_memo(int changed, bool new_mod, struct shown *shown)
rb->write(fq,temp,1);
}
rb->close(fp);
- fp = rb->creat("/.rockbox/.memo", O_WRONLY);
+ fp = rb->creat("/.rockbox/.memo");
rb->lseek(fp, 0, SEEK_SET);
rb->lseek(fq, 0, SEEK_SET);
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)
rb->lcd_update();
}
- fd = rb->creat(default_filename, O_WRONLY); /* create the settings file */
+ fd = rb->creat(default_filename); /* create the settings file */
if(fd >= 0) /* file exists, save successful */
{
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)
rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename);
- fd = rb->creat(tmpfilename, O_WRONLY);
+ fd = rb->creat(tmpfilename);
if(fd < 0)
return 10 * fd - 1;
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 )
int fh;
int x,y;
if( bm->format != FORMAT_NATIVE ) return -1;
- fh = rb->PREFIX(creat)( filename, O_WRONLY );
+ fh = rb->creat( filename );
if( fh < 0 ) return -1;
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,
char buf[MAX_PATH];
cfg_rb->snprintf(buf, MAX_PATH, "/.rockbox/rocks/%s", filename);
- fd = cfg_rb->creat(buf, O_WRONLY);
+ fd = cfg_rb->creat(buf);
if(fd < 0)
return fd*10 - 1;
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)
if (fd==-1)
return false;
- fdw = rb->creat(resultfile, O_WRONLY);
+ fdw = rb->creat(resultfile);
if (fdw < 0) {
#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)
/* Create a temporary file */
rb->snprintf(tmpfilename, MAX_PATH+1, "%s.tmp", filename);
- fd = rb->creat(tmpfilename, O_WRONLY);
+ fd = rb->creat(tmpfilename);
if(fd < 0)
return 10 * fd - 1;
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)
rb->snprintf(text_buf, sizeof text_buf, "FS stress test: %dKB", (TEST_SIZE>>10));
log_lcd(text_buf, true);
- fd = rb->creat(TEST_FILE, 0);
+ fd = rb->creat(TEST_FILE);
if (fd < 0)
{
rb->splash(0, true, "Couldn't create testfile.");
@@ -193,7 +193,7 @@ static bool test_speed(void)
log_init();
log_lcd("Disk speed test", true);
- fd = rb->creat(TEST_FILE, 0);
+ fd = rb->creat(TEST_FILE);
if (fd < 0)
{
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)
return 10*orig_fd - 1;
}
- fd = rb->creat(tmpname, O_WRONLY);
+ fd = rb->creat(tmpname);
if(fd < 0) {
rb->close(orig_fd);
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
if (i < data->bookmarked_files_count)
{
/* it is in the list, write everything back in the correct order, and reload the file correctly */
- settings_fd = rb->creat(BOOKMARKS_FILE, O_WRONLY);
+ settings_fd = rb->creat(BOOKMARKS_FILE);
if (settings_fd >=0 )
{
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
}
else /* not in list, write the list to the file */
{
- settings_fd = rb->creat(BOOKMARKS_FILE, O_WRONLY);
+ settings_fd = rb->creat(BOOKMARKS_FILE);
if (settings_fd >=0 )
{
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
static void viewer_save_settings(void)/* same name as global, but not the same file.. */
{
int settings_fd;
- settings_fd = rb->creat(SETTINGS_FILE, O_WRONLY); /* create the settings file */
+ settings_fd = rb->creat(SETTINGS_FILE); /* create the settings file */
rb->write (settings_fd, &prefs, sizeof(struct preferences));
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) {
}
void save_settings(void) {
- int fp = rb->creat("/.rockbox/rocks/.vu_meter", O_WRONLY);
+ int fp = rb->creat("/.rockbox/rocks/.vu_meter");
if(fp >= 0) {
rb->write (fp, &settings, sizeof(struct saved_settings));
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)
extension [1] = extension [2];
extension [2] = 0;
- out_fd = rb->creat (filename, O_WRONLY);
+ out_fd = rb->creat (filename);
extension [2] = extension [1];
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)
int snsh;
snsh = rb->open(name, O_WRONLY);
if(snsh < 0) {
- snsh = rb->creat(name, O_WRONLY);
+ snsh = rb->creat(name);
if(snsh < 0) {
put_msg("Could not create snapshot file");
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)
int fd;
int i;
- fd = creat(filepreset, O_WRONLY);
+ fd = creat(filepreset);
if(fd >= 0)
{
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)
gui_textarea_update(&screens[i]);
#endif
}
- fd = creat(filename, O_WRONLY);
+ fd = creat(filename);
if (fd < 0)
return false;
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];
static int flush_cache(int fd);
-int creat(const char *pathname, mode_t mode)
+int creat(const char *pathname)
{
- (void)mode;
return open(pathname, O_WRONLY|O_CREAT|O_TRUNC);
}
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)
if (fnt_file >= 0) {
- glyph_file = creat(GLYPH_CACHE_FILE, O_WRONLY);
+ glyph_file = creat(GLYPH_CACHE_FILE);
if (glyph_file < 0) return;
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 @@
#ifdef SIMULATOR
#define open(x,y) sim_open(x,y)
-#define creat(x,y) sim_creat(x,y)
+#define creat(x) sim_creat(x)
#define remove(x) sim_remove(x)
#define rename(x,y) sim_rename(x,y)
#define filesize(x) sim_filesize(x)
@@ -59,7 +59,7 @@
typedef int (*open_func)(const char* pathname, int flags);
typedef ssize_t (*read_func)(int fd, void *buf, size_t count);
-typedef int (*creat_func)(const char *pathname, mode_t mode);
+typedef int (*creat_func)(const char *pathname);
typedef ssize_t (*write_func)(int fd, const void *buf, size_t count);
typedef void (*qsort_func)(void *base, size_t nmemb, size_t size,
int(*_compar)(const void *, const void *));
@@ -69,7 +69,7 @@ extern int close(int fd);
extern int fsync(int fd);
extern ssize_t read(int fd, void *buf, size_t count);
extern off_t lseek(int fildes, off_t offset, int whence);
-extern int creat(const char *pathname, mode_t mode);
+extern int creat(const char *pathname);
extern ssize_t write(int fd, const void *buf, size_t count);
extern int remove(const char* pathname);
extern 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 @@
#include "debug.h"
#include "config.h"
+/* Windows (and potentially other OSes) distinguish binary and text files.
+ * Define a dummy for the others. */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#ifdef HAVE_DIRCACHE
void dircache_remove(const char *name);
void dircache_rename(const char *oldpath, const char *newpath);
@@ -81,11 +87,8 @@ typedef struct mydir MYDIR;
#if 1 /* maybe this needs disabling for MSVC... */
static unsigned int rockbox2sim(int opt)
{
-#ifdef WIN32
int newopt = O_BINARY;
-#else
- int newopt = 0;
-#endif
+
if(opt & 1)
newopt |= O_WRONLY;
if(opt & 2)
@@ -189,24 +192,22 @@ int sim_open(const char *name, int o)
}
-int sim_creat(const char *name, mode_t mode)
+int sim_creat(const char *name)
{
- int opts = rockbox2sim(mode);
-
#ifndef __PCTOOL__
char buffer[256]; /* sufficiently big */
- if(name[0] == '/')
+ if(name[0] == '/')
{
sprintf(buffer, "%s%s", SIMULATOR_ARCHOS_ROOT, name);
debugf("We create the real file '%s'\n", buffer);
- return open(buffer, opts | O_CREAT | O_TRUNC, 0666);
+ return open(buffer, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666);
}
fprintf(stderr, "WARNING, bad file name lacks slash: %s\n",
name);
return -1;
#else
- return open(name, opts | O_CREAT | O_TRUNC, 0666);
+ return open(name, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC, 0666);
#endif
}
@@ -390,15 +391,11 @@ void *sim_codec_load_ram(char* codecptr, int size,
{
sprintf(path, TEMP_CODEC_FILE, codec_count);
- #ifdef WIN32
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU);
- #else
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
- #endif
if (fd >= 0)
break; /* Created a file ok */
}
- if (fd < 0)
+ if (fd < 0)
{
DEBUGF("failed to open for write: %s\n", path);
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 @@
#include "lcd-sdl.h"
/* extern functions, needed for screendump() */
-extern int sim_creat(const char *name, mode_t mode);
+extern int sim_creat(const char *name);
SDL_Surface* lcd_surface;
SDL_Color lcd_color_zero = {UI_LCD_BGCOLOR, 0};
@@ -185,7 +185,7 @@ void screen_dump(void)
IF_CNFN_NUM_(, NULL));
DEBUGF("screen_dump\n");
- fd = sim_creat(filename, O_WRONLY);
+ fd = sim_creat(filename);
if (fd < 0)
return;