diff options
| author | Robert Kukla <roolku@rockbox.org> | 2007-11-21 21:28:27 +0000 |
|---|---|---|
| committer | Robert Kukla <roolku@rockbox.org> | 2007-11-21 21:28:27 +0000 |
| commit | d87b037efe7d001902c0cde992e1633ff9f70061 (patch) | |
| tree | ddea298e51d73443aad0d31fca7d59311444efab /apps/plugins | |
| parent | a2ad8537af659972b2e859c99c0ff75e374b73f9 (diff) | |
| download | rockbox-d87b037efe7d001902c0cde992e1633ff9f70061.zip rockbox-d87b037efe7d001902c0cde992e1633ff9f70061.tar.gz rockbox-d87b037efe7d001902c0cde992e1633ff9f70061.tar.bz2 rockbox-d87b037efe7d001902c0cde992e1633ff9f70061.tar.xz | |
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.h | 3 | ||||
| -rw-r--r-- | apps/plugins/shortcuts/shortcuts_append.c | 4 | ||||
| -rw-r--r-- | apps/plugins/shortcuts/shortcuts_common.c | 32 | ||||
| -rw-r--r-- | apps/plugins/shortcuts/shortcuts_view.c | 4 |
4 files changed, 4 insertions, 39 deletions
diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h index 6ccb320..34f200d 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); /* Checks whether the index is a valid one for the file. */ bool is_valid_index(sc_file_t *file, int entry_idx); -bool file_exists(char *filename); /* Does the specified file exist? */ -bool dir_exists(char *path); /* Does the specified dir exist? */ - #ifdef SC_DEBUG void print_file(sc_file_t *file); diff --git a/apps/plugins/shortcuts/shortcuts_append.c b/apps/plugins/shortcuts/shortcuts_append.c index bc28723..afd0392 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) * if it's a dir and then file (not vice versa) since * open() can also open a dir */ found = true; - if (dir_exists(parameter)) { + if (rb->dir_exists(parameter)) { its_a_dir = true; - } else if (file_exists(parameter)) { + } else if (rb->file_exists(parameter)) { its_a_dir = false; } else { found = false; diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c index 4a097f0..91e3084 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) } rb->fdprintf(fd, "\n"); } - - -bool file_exists(char *filename) -{ - int fd = rb->open(filename, O_RDONLY); - bool retval; - if (fd >= 0) { - rb->close(fd); - retval = true; - } else { - retval = false; - } - DEBUGF("Checked existence of the file '%s': %s\n", - filename, (retval ? "found" : "NOT FOUND")); - return retval; -} - - -bool dir_exists(char *path) -{ - DIR* d = rb->opendir(path); - bool retval; - if (d != NULL) { - rb->closedir(d); - retval = true; - } else { - retval = false; - } - DEBUGF("Checked existence of the dir '%s': %s\n", - path, (retval ? "found" : "NOT FOUND")); - return retval; -} diff --git a/apps/plugins/shortcuts/shortcuts_view.c b/apps/plugins/shortcuts/shortcuts_view.c index f61177f..4ef1bbc 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) char *what; if (is_dir) { what = "Directory"; - exists = dir_exists(file_or_dir); + exists = rb->dir_exists(file_or_dir); } else { what = "File"; - exists = file_exists(file_or_dir); + exists = rb->file_exists(file_or_dir); } if (!exists) { |