1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Thomas Martitz 2010-08-01 16:15:27 +00:00
parent 2e7d92fef7
commit 9c0b2479f7
41 changed files with 620 additions and 248 deletions

View file

@ -22,6 +22,7 @@
#include "dir.h"
#include "stdlib.h"
#include "string.h"
#include "debug.h"
#ifdef HAVE_MULTIVOLUME
/* returns on which volume this is, and copies the reduced name
@ -50,3 +51,39 @@ int strip_volume(const char* name, char* namecopy)
return volume;
}
#endif /* #ifdef HAVE_MULTIVOLUME */
#ifndef __PCTOOL__
/* Test file existence, using dircache of possible */
bool file_exists(const char *file)
{
int fd;
#ifdef DEBUG
if (!file || strlen(file) <= 0)
{
DEBUGF("%s(): Invalid parameter!\n");
return false;
}
#endif
#ifdef HAVE_DIRCACHE
if (dircache_is_enabled())
return (dircache_get_entry_ptr(file) != NULL);
#endif
fd = open(file, O_RDONLY);
if (fd < 0)
return false;
close(fd);
return true;
}
bool dir_exists(const char *path)
{
DIR* d = opendir(path);
if (!d)
return false;
closedir(d);
return true;
}
#endif /* __PCTOOL__ */