summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2014-02-11 15:27:23 +0100
committerThomas Martitz <kugel@rockbox.org>2014-02-23 20:23:52 +0100
commit0f928f87850153a38c7e6cfafd283ce4f52a0666 (patch)
tree55bbb19b5a17cd6e30a29bb3c2446a6e4c02738a /uisimulator
parentcbc57af0f3192093177d90861df72c4074566cf8 (diff)
downloadrockbox-0f928f87850153a38c7e6cfafd283ce4f52a0666.tar.gz
rockbox-0f928f87850153a38c7e6cfafd283ce4f52a0666.tar.bz2
rockbox-0f928f87850153a38c7e6cfafd283ce4f52a0666.zip
RaaA: Move directory related stuff from filesystem-unix.c into rbpaths.c.
Part of this change is to align sdlapp builds to other application targets in that the sim_* wrappers are not used anymore (except for sim_read/write). Path mangling is now done in rbpaths.c as well. Change-Id: I9726da73b50a83d9e1a1840288de16ec01ea029d
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/io.c82
1 files changed, 44 insertions, 38 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 690ef39f5f..9401f7d54a 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -155,6 +155,7 @@ void dircache_remove(const char *name);
void dircache_rename(const char *oldname, const char *newname);
#endif
+#ifndef APPLICATION
#define SIMULATOR_DEFAULT_ROOT "simdisk"
extern const char *sim_root_dir;
@@ -210,6 +211,8 @@ static unsigned int rockbox2sim(int opt)
#endif
}
+#endif /* APPLICATION */
+
/** Simulator I/O engine routines **/
#define IO_YIELD_THRESHOLD 512
@@ -282,6 +285,43 @@ static ssize_t io_trigger_and_wait(enum io_dir cmd)
return result;
}
+
+ssize_t sim_read(int fd, void *buf, size_t count)
+{
+ ssize_t result;
+
+ mutex_lock(&io.sim_mutex);
+
+ /* Setup parameters */
+ io.fd = fd;
+ io.buf = buf;
+ io.count = count;
+
+ result = io_trigger_and_wait(IO_READ);
+
+ mutex_unlock(&io.sim_mutex);
+
+ return result;
+}
+
+
+ssize_t sim_write(int fd, const void *buf, size_t count)
+{
+ ssize_t result;
+
+ mutex_lock(&io.sim_mutex);
+
+ io.fd = fd;
+ io.buf = (void*)buf;
+ io.count = count;
+
+ result = io_trigger_and_wait(IO_WRITE);
+
+ mutex_unlock(&io.sim_mutex);
+
+ return result;
+}
+
#if !defined(APPLICATION)
static const char *get_sim_pathname(const char *name)
{
@@ -296,9 +336,6 @@ static const char *get_sim_pathname(const char *name)
fprintf(stderr, "WARNING, bad file name lacks slash: %s\n", name);
return name;
}
-#else
-#define get_sim_pathname(name) name
-#endif
MYDIR *sim_opendir(const char *name)
{
@@ -446,41 +483,6 @@ int sim_creat(const char *name, mode_t mode)
return ret;
}
-ssize_t sim_read(int fd, void *buf, size_t count)
-{
- ssize_t result;
-
- mutex_lock(&io.sim_mutex);
-
- /* Setup parameters */
- io.fd = fd;
- io.buf = buf;
- io.count = count;
-
- result = io_trigger_and_wait(IO_READ);
-
- mutex_unlock(&io.sim_mutex);
-
- return result;
-}
-
-ssize_t sim_write(int fd, const void *buf, size_t count)
-{
- ssize_t result;
-
- mutex_lock(&io.sim_mutex);
-
- io.fd = fd;
- io.buf = (void*)buf;
- io.count = count;
-
- result = io_trigger_and_wait(IO_WRITE);
-
- mutex_unlock(&io.sim_mutex);
-
- return result;
-}
-
int sim_mkdir(const char *name)
{
return MKDIR(get_sim_pathname(name), 0777);
@@ -520,6 +522,10 @@ long sim_lseek(int fildes, long offset, int whence)
return lseek(fildes, offset, whence);
}
+#else
+#define get_sim_pathname(x) x
+#endif
+
long filesize(int fd)
{
#ifdef WIN32