diff options
author | Thomas Martitz <kugel@rockbox.org> | 2014-02-11 15:27:23 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-02-23 20:23:52 +0100 |
commit | 0f928f87850153a38c7e6cfafd283ce4f52a0666 (patch) | |
tree | 55bbb19b5a17cd6e30a29bb3c2446a6e4c02738a /uisimulator/common | |
parent | cbc57af0f3192093177d90861df72c4074566cf8 (diff) | |
download | rockbox-0f928f87850153a38c7e6cfafd283ce4f52a0666.tar.gz 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/common')
-rw-r--r-- | uisimulator/common/io.c | 82 |
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); | |||
155 | void dircache_rename(const char *oldname, const char *newname); | 155 | void dircache_rename(const char *oldname, const char *newname); |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | #ifndef APPLICATION | ||
158 | 159 | ||
159 | #define SIMULATOR_DEFAULT_ROOT "simdisk" | 160 | #define SIMULATOR_DEFAULT_ROOT "simdisk" |
160 | extern const char *sim_root_dir; | 161 | extern const char *sim_root_dir; |
@@ -210,6 +211,8 @@ static unsigned int rockbox2sim(int opt) | |||
210 | #endif | 211 | #endif |
211 | } | 212 | } |
212 | 213 | ||
214 | #endif /* APPLICATION */ | ||
215 | |||
213 | /** Simulator I/O engine routines **/ | 216 | /** Simulator I/O engine routines **/ |
214 | #define IO_YIELD_THRESHOLD 512 | 217 | #define IO_YIELD_THRESHOLD 512 |
215 | 218 | ||
@@ -282,6 +285,43 @@ static ssize_t io_trigger_and_wait(enum io_dir cmd) | |||
282 | return result; | 285 | return result; |
283 | } | 286 | } |
284 | 287 | ||
288 | |||
289 | ssize_t sim_read(int fd, void *buf, size_t count) | ||
290 | { | ||
291 | ssize_t result; | ||
292 | |||
293 | mutex_lock(&io.sim_mutex); | ||
294 | |||
295 | /* Setup parameters */ | ||
296 | io.fd = fd; | ||
297 | io.buf = buf; | ||
298 | io.count = count; | ||
299 | |||
300 | result = io_trigger_and_wait(IO_READ); | ||
301 | |||
302 | mutex_unlock(&io.sim_mutex); | ||
303 | |||
304 | return result; | ||
305 | } | ||
306 | |||
307 | |||
308 | ssize_t sim_write(int fd, const void *buf, size_t count) | ||
309 | { | ||
310 | ssize_t result; | ||
311 | |||
312 | mutex_lock(&io.sim_mutex); | ||
313 | |||
314 | io.fd = fd; | ||
315 | io.buf = (void*)buf; | ||
316 | io.count = count; | ||
317 | |||
318 | result = io_trigger_and_wait(IO_WRITE); | ||
319 | |||
320 | mutex_unlock(&io.sim_mutex); | ||
321 | |||
322 | return result; | ||
323 | } | ||
324 | |||
285 | #if !defined(APPLICATION) | 325 | #if !defined(APPLICATION) |
286 | static const char *get_sim_pathname(const char *name) | 326 | static const char *get_sim_pathname(const char *name) |
287 | { | 327 | { |
@@ -296,9 +336,6 @@ static const char *get_sim_pathname(const char *name) | |||
296 | fprintf(stderr, "WARNING, bad file name lacks slash: %s\n", name); | 336 | fprintf(stderr, "WARNING, bad file name lacks slash: %s\n", name); |
297 | return name; | 337 | return name; |
298 | } | 338 | } |
299 | #else | ||
300 | #define get_sim_pathname(name) name | ||
301 | #endif | ||
302 | 339 | ||
303 | MYDIR *sim_opendir(const char *name) | 340 | MYDIR *sim_opendir(const char *name) |
304 | { | 341 | { |
@@ -446,41 +483,6 @@ int sim_creat(const char *name, mode_t mode) | |||
446 | return ret; | 483 | return ret; |
447 | } | 484 | } |
448 | 485 | ||
449 | ssize_t sim_read(int fd, void *buf, size_t count) | ||
450 | { | ||
451 | ssize_t result; | ||
452 | |||
453 | mutex_lock(&io.sim_mutex); | ||
454 | |||
455 | /* Setup parameters */ | ||
456 | io.fd = fd; | ||
457 | io.buf = buf; | ||
458 | io.count = count; | ||
459 | |||
460 | result = io_trigger_and_wait(IO_READ); | ||
461 | |||
462 | mutex_unlock(&io.sim_mutex); | ||
463 | |||
464 | return result; | ||
465 | } | ||
466 | |||
467 | ssize_t sim_write(int fd, const void *buf, size_t count) | ||
468 | { | ||
469 | ssize_t result; | ||
470 | |||
471 | mutex_lock(&io.sim_mutex); | ||
472 | |||
473 | io.fd = fd; | ||
474 | io.buf = (void*)buf; | ||
475 | io.count = count; | ||
476 | |||
477 | result = io_trigger_and_wait(IO_WRITE); | ||
478 | |||
479 | mutex_unlock(&io.sim_mutex); | ||
480 | |||
481 | return result; | ||
482 | } | ||
483 | |||
484 | int sim_mkdir(const char *name) | 486 | int sim_mkdir(const char *name) |
485 | { | 487 | { |
486 | return MKDIR(get_sim_pathname(name), 0777); | 488 | return MKDIR(get_sim_pathname(name), 0777); |
@@ -520,6 +522,10 @@ long sim_lseek(int fildes, long offset, int whence) | |||
520 | return lseek(fildes, offset, whence); | 522 | return lseek(fildes, offset, whence); |
521 | } | 523 | } |
522 | 524 | ||
525 | #else | ||
526 | #define get_sim_pathname(x) x | ||
527 | #endif | ||
528 | |||
523 | long filesize(int fd) | 529 | long filesize(int fd) |
524 | { | 530 | { |
525 | #ifdef WIN32 | 531 | #ifdef WIN32 |