diff options
| author | Nils Wallménius <nils@rockbox.org> | 2008-04-16 19:51:43 +0000 |
|---|---|---|
| committer | Nils Wallménius <nils@rockbox.org> | 2008-04-16 19:51:43 +0000 |
| commit | a01996436d09eca8ae114e67005d2cac73cae7b3 (patch) | |
| tree | 013d6787d3c03265049536677e817572c4285119 /apps/tree.c | |
| parent | d65930f9720b0d51313b0e76251e56d2ffa144dd (diff) | |
| download | rockbox-a01996436d09eca8ae114e67005d2cac73cae7b3.zip rockbox-a01996436d09eca8ae114e67005d2cac73cae7b3.tar.gz rockbox-a01996436d09eca8ae114e67005d2cac73cae7b3.tar.bz2 rockbox-a01996436d09eca8ae114e67005d2cac73cae7b3.tar.xz | |
Use file_exists and dir_exists functions where appropriate, fix one wrong file descriptor check and one possible dir descriptor leak
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17147 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tree.c')
| -rw-r--r-- | apps/tree.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/apps/tree.c b/apps/tree.c index c6e0c48..275eb6a 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -269,8 +269,7 @@ static int tree_voice_cb(int selected_item, void * data) bool check_rockboxdir(void) { - DIR *dir = opendir(ROCKBOX_DIR); - if(!dir) + if(!dir_exists(ROCKBOX_DIR)) { /* No need to localise this message. If .rockbox is missing, it wouldn't work anyway */ int i; @@ -282,7 +281,6 @@ bool check_rockboxdir(void) gui_syncsplash(HZ*2, "Installation incomplete"); return false; } - closedir(dir); return true; } @@ -1086,10 +1084,8 @@ bool bookmark_play(char *resume_file, int index, int offset, int seed, /* Playlist playback */ char* slash; /* check that the file exists */ - int fd = open(resume_file, O_RDONLY); - if(fd<0) + if(!file_exists(resume_file)) return false; - close(fd); slash = strrchr(resume_file,'/'); if (slash) @@ -1171,7 +1167,6 @@ static void say_filetype(int attr) static int ft_play_dirname(char* name) { - int fd; char dirname_mp3_filename[MAX_PATH+1]; #if CONFIG_CODEC != SWCODEC @@ -1185,15 +1180,12 @@ static int ft_play_dirname(char* name) DEBUGF("Checking for %s\n", dirname_mp3_filename); - fd = open(dirname_mp3_filename, O_RDONLY); - if (fd < 0) + if (!file_exists(dirname_mp3_filename)) { DEBUGF("Failed to find: %s\n", dirname_mp3_filename); return -1; } - close(fd); - DEBUGF("Found: %s\n", dirname_mp3_filename); talk_file(dirname_mp3_filename, false); |