summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-05-06 17:35:13 +0000
committerThomas Martitz <kugel@rockbox.org>2010-05-06 17:35:13 +0000
commit0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0 (patch)
treea21521e6e4b8fe0131c4d9e8bae6d8cc78125fe9 /uisimulator
parentc61e89c0eda126c2c1a4a3983520c35fe30db156 (diff)
downloadrockbox-0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0.tar.gz
rockbox-0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0.tar.bz2
rockbox-0a1d7c28b7e9da555d26d489cde2da26e2cc9ca0.zip
Make open() posix compliant api-wise. A few calls (those with O_CREAT) need the additional optional mode parameter so add it. Impact for the core is almost zero, as open() is a wrapper macro for the real open function which doesn't take the variable parameter.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25844 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/io.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index f794d5fbc3..937c710e06 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -106,7 +106,9 @@ extern int _wrmdir(const wchar_t*);
#define READDIR(a) (_wreaddir)(a)
#define CLOSEDIR(a) (_wclosedir)(a)
#define STAT(a,b) (_wstat)(UTF8_TO_OS(a),b)
-#define OPEN(a,b,c) (_wopen)(UTF8_TO_OS(a),b,c)
+/* empty variable parameter list doesn't work for variadic macros,
+ * so pretend the second parameter is variable too */
+#define OPEN(a,...) (_wopen)(UTF8_TO_OS(a), __VA_ARGS__)
#define CLOSE(a) (close)(a)
#define REMOVE(a) (_wremove)(UTF8_TO_OS(a))
#define RENAME(a,b) (_wrename)(UTF8_TO_OS(a),utf8_to_ucs2(b,convbuf2))
@@ -124,7 +126,9 @@ extern int _wrmdir(const wchar_t*);
#define READDIR(a) (readdir)(a)
#define CLOSEDIR(a) (closedir)(a)
#define STAT(a,b) (stat)(a,b)
-#define OPEN(a,b,c) (open)(a,b,c)
+/* empty variable parameter list doesn't work for variadic macros,
+ * so pretend the second parameter is variable too */
+#define OPEN(a, ...) (open)(a, __VA_ARGS__)
#define CLOSE(x) (close)(x)
#define REMOVE(a) (remove)(a)
#define RENAME(a,b) (rename)(a,b)
@@ -329,15 +333,23 @@ void sim_closedir(MYDIR *dir)
free(dir);
}
-int sim_open(const char *name, int o)
+int sim_open(const char *name, int o, ...)
{
int opts = rockbox2sim(o);
int ret;
-
if (num_openfiles >= MAX_OPEN_FILES)
return -2;
- ret = OPEN(get_sim_pathname(name), opts, 0666);
+ if (o & O_CREAT)
+ {
+ va_list ap;
+ va_start(ap, o);
+ ret = OPEN(get_sim_pathname(name), opts, va_arg(ap, mode_t));
+ va_end(ap);
+ }
+ else
+ ret = OPEN(get_sim_pathname(name), opts);
+
if (ret >= 0)
num_openfiles++;
return ret;