summaryrefslogtreecommitdiff
path: root/uisimulator/common
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-08-01 16:15:27 +0000
committerThomas Martitz <kugel@rockbox.org>2010-08-01 16:15:27 +0000
commit9c0b2479f7025a84444adf08e3be8ced60dad013 (patch)
treef3d328dd73f46d599f0432cc43ae206798cbe4f6 /uisimulator/common
parent2e7d92fef707a2cd30820fd0053c539c3ac8e2b3 (diff)
downloadrockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.tar.gz
rockbox-9c0b2479f7025a84444adf08e3be8ced60dad013.zip
Rockbox as an application: add get_user_file_path().
For RaaA it evaluates user paths at runtime. For everything but codecs/plugins it will give the path under $HOME/.config/rockbox.org if write access is needed or if the file/folder in question exists there (otherwise it gives /usr/local/share/rockbox). This allows for installing themes under $HOME as well as having config.cfg and other important files there while installing the application (and default themes) under /usr/local. On the DAPs it's a no-op, returing /.rockbox directly. Not converted to use get_user_file_path() are plugins themselves, because RaaA doesn't build plugins yet. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27656 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common')
-rw-r--r--uisimulator/common/io.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index bdcc7e6ca1..260e880b62 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -40,9 +40,6 @@
40#include "dir-win32.h" 40#include "dir-win32.h"
41#endif 41#endif
42 42
43#define MAX_PATH 260
44#define MAX_OPEN_FILES 11
45
46#include <fcntl.h> 43#include <fcntl.h>
47#include <SDL.h> 44#include <SDL.h>
48#include <SDL_thread.h> 45#include <SDL_thread.h>
@@ -52,7 +49,12 @@
52#include "config.h" 49#include "config.h"
53#include "ata.h" /* for IF_MV2 et al. */ 50#include "ata.h" /* for IF_MV2 et al. */
54#include "thread-sdl.h" 51#include "thread-sdl.h"
52#include "rbpaths.h"
55 53
54/* keep this in sync with file.h! */
55#undef MAX_PATH /* this avoids problems when building simulator */
56#define MAX_PATH 260
57#define MAX_OPEN_FILES 11
56 58
57/* Windows (and potentially other OSes) distinguish binary and text files. 59/* Windows (and potentially other OSes) distinguish binary and text files.
58 * Define a dummy for the others. */ 60 * Define a dummy for the others. */
@@ -255,7 +257,7 @@ static ssize_t io_trigger_and_wait(int cmd)
255 return result; 257 return result;
256} 258}
257 259
258#ifndef __PCTOOL__ 260#if !defined(__PCTOOL__) && !defined(APPLICATION)
259static const char *get_sim_pathname(const char *name) 261static const char *get_sim_pathname(const char *name)
260{ 262{
261 static char buffer[MAX_PATH]; /* sufficiently big */ 263 static char buffer[MAX_PATH]; /* sufficiently big */
@@ -520,7 +522,6 @@ int sim_fsync(int fd)
520void *sim_codec_load_ram(char* codecptr, int size, void **pd) 522void *sim_codec_load_ram(char* codecptr, int size, void **pd)
521{ 523{
522 void *hdr; 524 void *hdr;
523 char name[MAX_PATH];
524 char path[MAX_PATH]; 525 char path[MAX_PATH];
525 int fd; 526 int fd;
526 int codec_count; 527 int codec_count;
@@ -536,8 +537,9 @@ void *sim_codec_load_ram(char* codecptr, int size, void **pd)
536 to find an unused filename */ 537 to find an unused filename */
537 for (codec_count = 0; codec_count < 10; codec_count++) 538 for (codec_count = 0; codec_count < 10; codec_count++)
538 { 539 {
539 snprintf(name, sizeof(name), "/_temp_codec%d.dll", codec_count); 540 char name[MAX_PATH];
540 snprintf(path, sizeof(path), "%s", get_sim_pathname(name)); 541 const char *_name = get_user_file_path(ROCKBOX_DIR, 0, name, sizeof(name));
542 snprintf(path, sizeof(path), "%s/_temp_codec%d.dll", get_sim_pathname(_name), codec_count);
541 fd = OPEN(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU); 543 fd = OPEN(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU);
542 if (fd >= 0) 544 if (fd >= 0)
543 break; /* Created a file ok */ 545 break; /* Created a file ok */