diff options
Diffstat (limited to 'firmware/common/filefuncs.c')
-rw-r--r-- | firmware/common/filefuncs.c | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/firmware/common/filefuncs.c b/firmware/common/filefuncs.c deleted file mode 100644 index 16f8d88684..0000000000 --- a/firmware/common/filefuncs.c +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Björn Stenberg | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "config.h" | ||
22 | #include "dir.h" | ||
23 | #include "stdlib.h" | ||
24 | #include "string.h" | ||
25 | #include "debug.h" | ||
26 | #include "file.h" | ||
27 | #include "filefuncs.h" | ||
28 | #include "string-extra.h" | ||
29 | |||
30 | #ifndef __PCTOOL__ | ||
31 | #ifdef HAVE_MULTIVOLUME | ||
32 | |||
33 | /* returns on which volume this is, and copies the reduced name | ||
34 | (sortof a preprocessor for volume-decorated pathnames) */ | ||
35 | int strip_volume(const char* name, char* namecopy) | ||
36 | { | ||
37 | int volume = 0; | ||
38 | const char *temp = name; | ||
39 | |||
40 | while (*temp == '/') /* skip all leading slashes */ | ||
41 | ++temp; | ||
42 | |||
43 | if (*temp && !strncmp(temp, VOL_NAMES, VOL_ENUM_POS)) | ||
44 | { | ||
45 | temp += VOL_ENUM_POS; /* behind special name */ | ||
46 | volume = atoi(temp); /* number is following */ | ||
47 | temp = strchr(temp, '/'); /* search for slash behind */ | ||
48 | if (temp != NULL) | ||
49 | name = temp; /* use the part behind the volume */ | ||
50 | else | ||
51 | name = "/"; /* else this must be the root dir */ | ||
52 | } | ||
53 | |||
54 | strlcpy(namecopy, name, MAX_PATH); | ||
55 | |||
56 | return volume; | ||
57 | } | ||
58 | #endif /* #ifdef HAVE_MULTIVOLUME */ | ||
59 | |||
60 | #endif /* __PCTOOL__ */ | ||
61 | /* Test file existence, using dircache of possible */ | ||
62 | bool file_exists(const char *file) | ||
63 | { | ||
64 | int fd; | ||
65 | |||
66 | #ifdef DEBUG | ||
67 | if (!file || !*file) | ||
68 | { | ||
69 | DEBUGF("%s(%p): Invalid parameter!\n", __func__, file); | ||
70 | return false; | ||
71 | } | ||
72 | #endif | ||
73 | |||
74 | #ifdef HAVE_DIRCACHE | ||
75 | if (dircache_is_enabled()) | ||
76 | return (dircache_get_entry_id(file) >= 0); | ||
77 | #endif | ||
78 | |||
79 | fd = open(file, O_RDONLY); | ||
80 | if (fd < 0) | ||
81 | return false; | ||
82 | close(fd); | ||
83 | return true; | ||
84 | } | ||
85 | |||
86 | bool dir_exists(const char *path) | ||
87 | { | ||
88 | DIR* d = opendir(path); | ||
89 | if (!d) | ||
90 | return false; | ||
91 | closedir(d); | ||
92 | return true; | ||
93 | } | ||
94 | |||
95 | |||
96 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) || defined(SIMULATOR) | ||
97 | struct dirinfo dir_get_info(DIR* parent, struct dirent *entry) | ||
98 | { | ||
99 | (void)parent; | ||
100 | return entry->info; | ||
101 | } | ||
102 | #endif | ||