summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorRobert Kukla <roolku@rockbox.org>2007-11-21 21:28:27 +0000
committerRobert Kukla <roolku@rockbox.org>2007-11-21 21:28:27 +0000
commitd87b037efe7d001902c0cde992e1633ff9f70061 (patch)
treeddea298e51d73443aad0d31fca7d59311444efab /apps/plugins
parenta2ad8537af659972b2e859c99c0ff75e374b73f9 (diff)
downloadrockbox-d87b037efe7d001902c0cde992e1633ff9f70061.tar.gz
rockbox-d87b037efe7d001902c0cde992e1633ff9f70061.zip
consolidate the 3 file_exists() functions into one; use the version that explicitly uses dircache; give dir_exists() the same treatment for consistency
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15742 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/shortcuts/shortcuts.h3
-rw-r--r--apps/plugins/shortcuts/shortcuts_append.c4
-rw-r--r--apps/plugins/shortcuts/shortcuts_common.c32
-rw-r--r--apps/plugins/shortcuts/shortcuts_view.c4
4 files changed, 4 insertions, 39 deletions
diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h
index 6ccb320a36..34f200d193 100644
--- a/apps/plugins/shortcuts/shortcuts.h
+++ b/apps/plugins/shortcuts/shortcuts.h
@@ -79,9 +79,6 @@ bool remove_entry(sc_file_t *file, int entry_idx);
79/* Checks whether the index is a valid one for the file. */ 79/* Checks whether the index is a valid one for the file. */
80bool is_valid_index(sc_file_t *file, int entry_idx); 80bool is_valid_index(sc_file_t *file, int entry_idx);
81 81
82bool file_exists(char *filename); /* Does the specified file exist? */
83bool dir_exists(char *path); /* Does the specified dir exist? */
84
85 82
86#ifdef SC_DEBUG 83#ifdef SC_DEBUG
87void print_file(sc_file_t *file); 84void print_file(sc_file_t *file);
diff --git a/apps/plugins/shortcuts/shortcuts_append.c b/apps/plugins/shortcuts/shortcuts_append.c
index bc287234dd..afd03929ae 100644
--- a/apps/plugins/shortcuts/shortcuts_append.c
+++ b/apps/plugins/shortcuts/shortcuts_append.c
@@ -70,9 +70,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* void_parameter)
70 * if it's a dir and then file (not vice versa) since 70 * if it's a dir and then file (not vice versa) since
71 * open() can also open a dir */ 71 * open() can also open a dir */
72 found = true; 72 found = true;
73 if (dir_exists(parameter)) { 73 if (rb->dir_exists(parameter)) {
74 its_a_dir = true; 74 its_a_dir = true;
75 } else if (file_exists(parameter)) { 75 } else if (rb->file_exists(parameter)) {
76 its_a_dir = false; 76 its_a_dir = false;
77 } else { 77 } else {
78 found = false; 78 found = false;
diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c
index 4a097f0a0d..91e3084e10 100644
--- a/apps/plugins/shortcuts/shortcuts_common.c
+++ b/apps/plugins/shortcuts/shortcuts_common.c
@@ -360,35 +360,3 @@ void write_entry_to_file(int fd, sc_entry_t *entry)
360 } 360 }
361 rb->fdprintf(fd, "\n"); 361 rb->fdprintf(fd, "\n");
362} 362}
363
364
365bool file_exists(char *filename)
366{
367 int fd = rb->open(filename, O_RDONLY);
368 bool retval;
369 if (fd >= 0) {
370 rb->close(fd);
371 retval = true;
372 } else {
373 retval = false;
374 }
375 DEBUGF("Checked existence of the file '%s': %s\n",
376 filename, (retval ? "found" : "NOT FOUND"));
377 return retval;
378}
379
380
381bool dir_exists(char *path)
382{
383 DIR* d = rb->opendir(path);
384 bool retval;
385 if (d != NULL) {
386 rb->closedir(d);
387 retval = true;
388 } else {
389 retval = false;
390 }
391 DEBUGF("Checked existence of the dir '%s': %s\n",
392 path, (retval ? "found" : "NOT FOUND"));
393 return retval;
394}
diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c
index f61177f37a..4ef1bbc816 100644
--- a/apps/plugins/shortcuts/shortcuts_view.c
+++ b/apps/plugins/shortcuts/shortcuts_view.c
@@ -166,10 +166,10 @@ bool goto_entry(char *file_or_dir)
166 char *what; 166 char *what;
167 if (is_dir) { 167 if (is_dir) {
168 what = "Directory"; 168 what = "Directory";
169 exists = dir_exists(file_or_dir); 169 exists = rb->dir_exists(file_or_dir);
170 } else { 170 } else {
171 what = "File"; 171 what = "File";
172 exists = file_exists(file_or_dir); 172 exists = rb->file_exists(file_or_dir);
173 } 173 }
174 174
175 if (!exists) { 175 if (!exists) {