mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-20 10:32:42 -05:00
add some consistancy to the path #defines
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11114 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f5452c0bde
commit
7ae8e44c95
8 changed files with 230 additions and 21 deletions
|
|
@ -228,7 +228,7 @@ struct codec_api ci = {
|
|||
void codec_get_full_path(char *path, const char *codec_fn)
|
||||
{
|
||||
/* Create full codec path */
|
||||
snprintf(path, MAX_PATH-1, ROCKBOX_DIR CODECS_DIR "/%s", codec_fn);
|
||||
snprintf(path, MAX_PATH-1, CODECS_DIR "/%s", codec_fn);
|
||||
}
|
||||
|
||||
int codec_load_ram(char* codecptr, int size, void* ptr2, int bufwrap,
|
||||
|
|
|
|||
167
apps/fileutils.c
Normal file
167
apps/fileutils.c
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 Jonathan Gordon
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "playlist.h"
|
||||
#include "filetree.h"
|
||||
#include "dir.h"
|
||||
#include "tree.h"
|
||||
#include "lang.h"
|
||||
#include "fileutils.h"
|
||||
#include "settings.h"
|
||||
#include "gui/splash.h"
|
||||
#include "action.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define MAX_DEPTH 32
|
||||
|
||||
/**
|
||||
RETURNS: DIRWALKER_RETURN_SUCCESS if it successfully went through the directory tree
|
||||
DIRWALKER_RETURN_ERROR if it stopped for an error
|
||||
DIRWALKER_RETURN_FORCED if it was told to stop by one of the callbacks, or user aborted
|
||||
**/
|
||||
int dirwalker(const char *start_dir, bool recurse, bool is_forward,
|
||||
int (*folder_callback)(const char* dir, void *param),void* folder_param,
|
||||
int (*file_callback)(const char* folder,const char* file,
|
||||
const int file_attr,void *param),void* file_param)
|
||||
{
|
||||
char folder[MAX_PATH+1];
|
||||
int current_file_stack[MAX_DEPTH];
|
||||
int stack_top = 0;
|
||||
|
||||
int result = DIRWALKER_RETURN_SUCCESS;
|
||||
int num_files = 0;
|
||||
int i;
|
||||
char *s;
|
||||
struct entry *files;
|
||||
struct tree_context* tc = tree_get_context();
|
||||
int dirfilter = *(tc->dirfilter);
|
||||
int sort_dir = global_settings.sort_dir;
|
||||
|
||||
/* sort in another direction if previous dir is requested */
|
||||
if(!is_forward){
|
||||
int reverse_sort_dir[5] = {4,2,1,4,0};
|
||||
global_settings.sort_dir = reverse_sort_dir[sort_dir];
|
||||
}
|
||||
|
||||
/* use the tree browser dircache to load files */
|
||||
*(tc->dirfilter) = SHOW_ALL;
|
||||
|
||||
/* setup stuff */
|
||||
strcpy(folder, start_dir);
|
||||
current_file_stack[0] = -1;
|
||||
|
||||
while (!result && (stack_top>=0) )
|
||||
{
|
||||
if (ft_load(tc, folder) < 0)
|
||||
{
|
||||
gui_syncsplash(HZ*2, true,"%s %s",folder,
|
||||
str(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR));
|
||||
result = DIRWALKER_RETURN_ERROR;
|
||||
}
|
||||
|
||||
files = (struct entry*) tc->dircache;
|
||||
num_files = tc->filesindir;
|
||||
|
||||
i = current_file_stack[stack_top--]+1;
|
||||
while ( i<num_files )
|
||||
{
|
||||
/* user abort */
|
||||
if (action_userabort(TIMEOUT_NOBLOCK))
|
||||
{
|
||||
result = DIRWALKER_RETURN_FORCED;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((files[i].attr & ATTR_DIRECTORY) && recurse)
|
||||
{
|
||||
bool enter_dir = true;
|
||||
strcat(folder,"/");
|
||||
strcat(folder,files[i].name);
|
||||
if (folder_callback)
|
||||
{
|
||||
switch (folder_callback(folder,folder_param))
|
||||
{
|
||||
case DIRWALKER_ERROR:
|
||||
result = DIRWALKER_RETURN_ERROR;
|
||||
enter_dir = false;
|
||||
break;
|
||||
case DIRWALKER_OK:
|
||||
enter_dir = true;
|
||||
break;
|
||||
case DIRWALKER_IGNORE:
|
||||
enter_dir = false;
|
||||
break;
|
||||
case DIRWALKER_QUIT:
|
||||
result = DIRWALKER_RETURN_FORCED;
|
||||
enter_dir = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enter_dir)
|
||||
{
|
||||
current_file_stack[++stack_top] = i;
|
||||
|
||||
if(ft_load(tc, folder) < 0)
|
||||
{
|
||||
gui_syncsplash(HZ*2, true,"%s %s",folder,
|
||||
str(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR));
|
||||
result = DIRWALKER_RETURN_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
files = (struct entry*) tc->dircache;
|
||||
num_files = tc->filesindir;
|
||||
i=0;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = strrchr(folder,'/');
|
||||
if (s) *s ='\0';
|
||||
}
|
||||
}
|
||||
else if (((files[i].attr & ATTR_DIRECTORY) == 0) && file_callback)
|
||||
{
|
||||
int ret = file_callback(folder,files[i].name,
|
||||
files[i].attr,file_param);
|
||||
if (ret == DIRWALKER_ERROR)
|
||||
result = DIRWALKER_RETURN_ERROR;
|
||||
else if (ret == DIRWALKER_LEAVEDIR)
|
||||
break; /* break out of inner while() */
|
||||
else if (ret == DIRWALKER_QUIT)
|
||||
result = DIRWALKER_RETURN_FORCED;
|
||||
}
|
||||
i++;
|
||||
} /* while ( i<num_files ) */
|
||||
s = strrchr(folder,'/');
|
||||
if (s) *s ='\0';
|
||||
} /* while (!result && (stack_top>=0) ) */
|
||||
|
||||
/* we've overwritten the dircache so tree browser
|
||||
will need to be reloaded */
|
||||
reload_directory();
|
||||
/* restore dirfilter */
|
||||
*(tc->dirfilter) = dirfilter;
|
||||
global_settings.sort_dir = sort_dir;
|
||||
|
||||
return result;
|
||||
}
|
||||
42
apps/fileutils.h
Normal file
42
apps/fileutils.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006 Jonathan Gordon
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _FILEUTILS_H_
|
||||
#define _FILEUTILS_H_
|
||||
|
||||
enum {
|
||||
DIRWALKER_ERROR = -1,
|
||||
DIRWALKER_OK = 0,
|
||||
DIRWALKER_IGNORE, /* only valid from folder callback */
|
||||
DIRWALKER_LEAVEDIR, /* only valid from file callback */
|
||||
DIRWALKER_QUIT
|
||||
};
|
||||
|
||||
enum {
|
||||
DIRWALKER_RETURN_ERROR = -1,
|
||||
DIRWALKER_RETURN_SUCCESS,
|
||||
DIRWALKER_RETURN_FORCED
|
||||
};
|
||||
|
||||
int dirwalker(const char *start_dir, bool recurse, bool is_forward,
|
||||
int (*folder_callback)(const char* dir, void *param),void* folder_param,
|
||||
int (*file_callback)(const char* folder,const char* file,
|
||||
const int file_attr,void *param),void* file_param);
|
||||
|
||||
#endif /* _FILEUTILS_H_ */
|
||||
|
|
@ -827,7 +827,7 @@ static bool browse_fonts( char *dst, int dst_size )
|
|||
#define fontname_buf buffer.text.fontname_buf
|
||||
|
||||
rb->snprintf( old_font, MAX_PATH,
|
||||
ROCKBOX_DIR FONT_DIR "/%s.fnt",
|
||||
FONT_DIR "/%s.fnt",
|
||||
rb->global_settings->font_file );
|
||||
|
||||
while( 1 )
|
||||
|
|
@ -850,7 +850,7 @@ static bool browse_fonts( char *dst, int dst_size )
|
|||
{
|
||||
b_need_redraw = 0;
|
||||
|
||||
d = rb->PREFIX(opendir)( ROCKBOX_DIR FONT_DIR "/" );
|
||||
d = rb->PREFIX(opendir)( FONT_DIR "/" );
|
||||
if( !d )
|
||||
{
|
||||
return false;
|
||||
|
|
@ -880,7 +880,7 @@ static bool browse_fonts( char *dst, int dst_size )
|
|||
|| rb->strcmp( de->d_name + rb->strlen( de->d_name ) - 4,
|
||||
".fnt" ) )
|
||||
continue;
|
||||
rb->snprintf( bbuf, MAX_PATH, ROCKBOX_DIR FONT_DIR "/%s",
|
||||
rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s",
|
||||
de->d_name );
|
||||
rb->font_load( bbuf );
|
||||
rb->font_getstringsize( de->d_name, &fw, &fh, FONT_UI );
|
||||
|
|
@ -915,7 +915,7 @@ static bool browse_fonts( char *dst, int dst_size )
|
|||
&& !rb->strcmp( de->d_name + rb->strlen( de->d_name ) - 4,
|
||||
".fnt" ) )
|
||||
{
|
||||
rb->snprintf( bbuf, MAX_PATH, ROCKBOX_DIR FONT_DIR "/%s",
|
||||
rb->snprintf( bbuf, MAX_PATH, FONT_DIR "/%s",
|
||||
de->d_name );
|
||||
rb->font_load( bbuf );
|
||||
rb->font_getstringsize( de->d_name, NULL, &fh, FONT_UI );
|
||||
|
|
@ -1463,7 +1463,7 @@ static void draw_text( int x, int y )
|
|||
{
|
||||
buffer.text.text[0] = '\0';
|
||||
rb->snprintf( buffer.text.old_font, MAX_PATH,
|
||||
ROCKBOX_DIR FONT_DIR "/%s.fnt",
|
||||
FONT_DIR "/%s.fnt",
|
||||
rb->global_settings->font_file );
|
||||
while( 1 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1210,7 +1210,7 @@ void settings_apply(void)
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
if ( global_settings.font_file[0] &&
|
||||
global_settings.font_file[0] != 0xff ) {
|
||||
snprintf(buf, sizeof buf, ROCKBOX_DIR FONT_DIR "/%s.fnt",
|
||||
snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
|
||||
global_settings.font_file);
|
||||
font_load(buf);
|
||||
}
|
||||
|
|
@ -1238,7 +1238,7 @@ void settings_apply(void)
|
|||
|
||||
if ( global_settings.lang_file[0] &&
|
||||
global_settings.lang_file[0] != 0xff ) {
|
||||
snprintf(buf, sizeof buf, ROCKBOX_DIR LANG_DIR "/%s.lng",
|
||||
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
|
||||
global_settings.lang_file);
|
||||
lang_load(buf);
|
||||
talk_init(); /* use voice of same language */
|
||||
|
|
@ -1742,12 +1742,12 @@ bool settings_save_config(void)
|
|||
#endif
|
||||
|
||||
if (global_settings.lang_file[0] != 0)
|
||||
fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR,
|
||||
fdprintf(fd, "lang: %s/%s.lng\r\n", LANG_DIR,
|
||||
global_settings.lang_file);
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if (global_settings.font_file[0] != 0)
|
||||
fdprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR,
|
||||
fdprintf(fd, "font: %s/%s.fnt\r\n", FONT_DIR,
|
||||
global_settings.font_file);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -35,15 +35,15 @@
|
|||
|
||||
#define ROCKBOX_DIR "/.rockbox"
|
||||
#define ROCKBOX_DIR_LEN 9
|
||||
#define FONT_DIR "/fonts"
|
||||
#define LANG_DIR "/langs"
|
||||
#define FONT_DIR ROCKBOX_DIR "/fonts"
|
||||
#define LANG_DIR ROCKBOX_DIR "/langs"
|
||||
#define WPS_DIR ROCKBOX_DIR "/wps"
|
||||
#define THEME_DIR ROCKBOX_DIR "/themes"
|
||||
#define PLUGIN_DIR ROCKBOX_DIR "/rocks"
|
||||
#define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
|
||||
#define REC_BASE_DIR "/recordings"
|
||||
#define EQS_DIR ROCKBOX_DIR "/eqs"
|
||||
#define CODECS_DIR "/codecs"
|
||||
#define CODECS_DIR ROCKBOX_DIR"/codecs"
|
||||
|
||||
#define MAX_FILENAME 20
|
||||
|
||||
|
|
|
|||
|
|
@ -1257,7 +1257,7 @@ static bool custom_cfg_browse(void)
|
|||
|
||||
static bool language_browse(void)
|
||||
{
|
||||
return rockbox_browse(ROCKBOX_DIR LANG_DIR, SHOW_LNG);
|
||||
return rockbox_browse(LANG_DIR, SHOW_LNG);
|
||||
}
|
||||
|
||||
static bool voice_menus(void)
|
||||
|
|
@ -1327,7 +1327,7 @@ static bool voice_menu(void)
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
static bool font_browse(void)
|
||||
{
|
||||
return rockbox_browse(ROCKBOX_DIR FONT_DIR, SHOW_FONT);
|
||||
return rockbox_browse(FONT_DIR, SHOW_FONT);
|
||||
}
|
||||
|
||||
static bool scroll_bar(void)
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ static int open_voicefile(void)
|
|||
p_lang = (char *)global_settings.lang_file;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), ROCKBOX_DIR LANG_DIR "/%s.voice", p_lang);
|
||||
snprintf(buf, sizeof(buf), LANG_DIR "/%s.voice", p_lang);
|
||||
|
||||
return open(buf, O_RDONLY);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue