mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-18 09:32:40 -05:00
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
This commit is contained in:
parent
a2ad8537af
commit
d87b037efe
10 changed files with 50 additions and 65 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue