summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2007-07-20 17:06:55 +0000
committerKevin Ferrare <kevin@rockbox.org>2007-07-20 17:06:55 +0000
commit011a325e32c05f6e4817dcdc555615e6b7b6c102 (patch)
treeab22ab91b99524dba823cda861b17520db030911 /apps/plugins
parent930278bcc0fd944ec50f30074b53b4c7cf0e3ccf (diff)
downloadrockbox-011a325e32c05f6e4817dcdc555615e6b7b6c102.tar.gz
rockbox-011a325e32c05f6e4817dcdc555615e6b7b6c102.zip
Makes apps and plugins interract with directories using a posix-like api instead of calling dircache / simulator functions (no additionnal layer added, only a cosmetic change)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13943 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/doom/rockdoom.c8
-rw-r--r--apps/plugins/doom/rockmacros.h11
-rw-r--r--apps/plugins/properties.c53
-rw-r--r--apps/plugins/rockboy/rockboy.c6
-rw-r--r--apps/plugins/rockboy/rockmacros.h13
-rw-r--r--apps/plugins/rockpaint.c22
6 files changed, 22 insertions, 91 deletions
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index 90c446b9eb..a9e348160f 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -329,7 +329,7 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory
329 char *startpt; 329 char *startpt;
330 struct menu_item *temp; 330 struct menu_item *temp;
331 331
332 filedir=opendir(directory); 332 filedir=rb->opendir(directory);
333 333
334 if(filedir==NULL) 334 if(filedir==NULL)
335 { 335 {
@@ -345,8 +345,8 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory
345 i++; 345 i++;
346 346
347 // Reset the directory 347 // Reset the directory
348 closedir(filedir); 348 rb->closedir(filedir);
349 filedir=opendir(directory); 349 filedir=rb->opendir(directory);
350 350
351 i++; 351 i++;
352 temp=malloc(i*sizeof(struct opt_items)); 352 temp=malloc(i*sizeof(struct opt_items));
@@ -365,7 +365,7 @@ int Dbuild_filelistm(struct menu_item **names, char *firstentry, char *directory
365 i++; 365 i++;
366 } 366 }
367 } 367 }
368 closedir(filedir); 368 rb->closedir(filedir);
369 *names=temp; 369 *names=temp;
370 return i; 370 return i;
371} 371}
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h
index 86de4cbe13..1541ef48fd 100644
--- a/apps/plugins/doom/rockmacros.h
+++ b/apps/plugins/doom/rockmacros.h
@@ -40,26 +40,17 @@ char *my_strtok( char * s, const char * delim );
40#define read_line(a,b,c) rb->read_line((a),(b),(c)) 40#define read_line(a,b,c) rb->read_line((a),(b),(c))
41 41
42#ifdef SIMULATOR 42#ifdef SIMULATOR
43#undef opendir
44#undef closedir
45#undef mkdir
46#undef open 43#undef open
47#undef lseek 44#undef lseek
48#undef filesize 45#undef filesize
49#define opendir(a) rb->sim_opendir((a))
50#define closedir(a) rb->sim_closedir((a))
51#define mkdir(a) rb->sim_mkdir((a))
52#define open(a,b) rb->sim_open((a),(b)) 46#define open(a,b) rb->sim_open((a),(b))
53#define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) 47#define lseek(a,b,c) rb->sim_lseek((a),(b),(c))
54#define filesize(a) rb->sim_filesize((a)) 48#define filesize(a) rb->sim_filesize((a))
55#else /* !SIMULATOR */ 49#else /* !SIMULATOR */
56#define opendir(a) rb->opendir((a))
57#define closedir(a) rb->closedir((a))
58#define filesize(a) rb->filesize((a))
59#define mkdir(a) rb->mkdir((a))
60#define open(a,b) my_open((a),(b)) 50#define open(a,b) my_open((a),(b))
61#define close(a) my_close((a)) 51#define close(a) my_close((a))
62#define lseek(a,b,c) rb->lseek((a),(b),(c)) 52#define lseek(a,b,c) rb->lseek((a),(b),(c))
53#define filesize(a) rb->filesize((a))
63#endif /* !SIMULATOR */ 54#endif /* !SIMULATOR */
64 55
65#define strtok(a,b) my_strtok((a),(b)) 56#define strtok(a,b) my_strtok((a),(b))
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index 3b4f2797af..86817e2cc7 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -59,30 +59,18 @@ static bool file_properties(char* selected_file)
59{ 59{
60 bool found = false; 60 bool found = false;
61 char tstr[MAX_PATH]; 61 char tstr[MAX_PATH];
62#ifdef HAVE_DIRCACHE
63 DIRCACHED* dir;
64 struct dircache_entry* entry;
65#else
66 DIR* dir; 62 DIR* dir;
67 struct dirent* entry; 63 struct dirent* entry;
68#endif 64
69 char* ptr = rb->strrchr(selected_file, '/') + 1; 65 char* ptr = rb->strrchr(selected_file, '/') + 1;
70 int dirlen = (ptr - selected_file); 66 int dirlen = (ptr - selected_file);
71 rb->strncpy(tstr, selected_file, dirlen); 67 rb->strncpy(tstr, selected_file, dirlen);
72 tstr[dirlen] = 0; 68 tstr[dirlen] = 0;
73 69
74#ifdef HAVE_DIRCACHE
75 dir = rb->opendir_cached(tstr);
76#else
77 dir = rb->opendir(tstr); 70 dir = rb->opendir(tstr);
78#endif
79 if (dir) 71 if (dir)
80 { 72 {
81#ifdef HAVE_DIRCACHE
82 while(0 != (entry = rb->readdir_cached(dir)))
83#else
84 while(0 != (entry = rb->readdir(dir))) 73 while(0 != (entry = rb->readdir(dir)))
85#endif
86 { 74 {
87 if(!rb->strcmp(entry->d_name, selected_file+dirlen)) 75 if(!rb->strcmp(entry->d_name, selected_file+dirlen))
88 { 76 {
@@ -103,11 +91,7 @@ static bool file_properties(char* selected_file)
103 break; 91 break;
104 } 92 }
105 } 93 }
106#ifdef HAVE_DIRCACHE
107 rb->closedir_cached(dir);
108#else
109 rb->closedir(dir); 94 rb->closedir(dir);
110#endif
111 } 95 }
112 return found; 96 return found;
113} 97}
@@ -128,30 +112,17 @@ static bool _dir_properties(DPS* dps)
128 and informs the user of the progress */ 112 and informs the user of the progress */
129 bool result; 113 bool result;
130 int dirlen; 114 int dirlen;
131#ifdef HAVE_DIRCACHE
132 DIRCACHED* dir;
133 struct dircache_entry* entry;
134#else
135 DIR* dir; 115 DIR* dir;
136 struct dirent* entry; 116 struct dirent* entry;
137#endif
138 117
139 result = true; 118 result = true;
140 dirlen = rb->strlen(dps->dirname); 119 dirlen = rb->strlen(dps->dirname);
141#ifdef HAVE_DIRCACHE
142 dir = rb->opendir_cached(dps->dirname);
143#else
144 dir = rb->opendir(dps->dirname); 120 dir = rb->opendir(dps->dirname);
145#endif
146 if (!dir) 121 if (!dir)
147 return false; /* open error */ 122 return false; /* open error */
148 123
149 /* walk through the directory content */ 124 /* walk through the directory content */
150#ifdef HAVE_DIRCACHE
151 while(result && (0 != (entry = rb->readdir_cached(dir))))
152#else
153 while(result && (0 != (entry = rb->readdir(dir)))) 125 while(result && (0 != (entry = rb->readdir(dir))))
154#endif
155 { 126 {
156 /* append name to current directory */ 127 /* append name to current directory */
157 rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s", 128 rb->snprintf(dps->dirname+dirlen, dps->len-dirlen, "/%s",
@@ -189,12 +160,7 @@ static bool _dir_properties(DPS* dps)
189 result = false; 160 result = false;
190 rb->yield(); 161 rb->yield();
191 } 162 }
192#ifdef HAVE_DIRCACHE
193 rb->closedir_cached(dir);
194#else
195 rb->closedir(dir); 163 rb->closedir(dir);
196#endif
197
198 return result; 164 return result;
199} 165}
200 166
@@ -256,30 +222,17 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file)
256 222
257 /* determine if it's a file or a directory */ 223 /* determine if it's a file or a directory */
258 bool found = false; 224 bool found = false;
259#ifdef HAVE_DIRCACHE
260 DIRCACHED* dir;
261 struct dircache_entry* entry;
262#else
263 DIR* dir; 225 DIR* dir;
264 struct dirent* entry; 226 struct dirent* entry;
265#endif
266 char* ptr = rb->strrchr((char*)file, '/') + 1; 227 char* ptr = rb->strrchr((char*)file, '/') + 1;
267 int dirlen = (ptr - (char*)file); 228 int dirlen = (ptr - (char*)file);
268 rb->strncpy(str_dirname, (char*)file, dirlen); 229 rb->strncpy(str_dirname, (char*)file, dirlen);
269 str_dirname[dirlen] = 0; 230 str_dirname[dirlen] = 0;
270 231
271#ifdef HAVE_DIRCACHE
272 dir = rb->opendir_cached(str_dirname);
273#else
274 dir = rb->opendir(str_dirname); 232 dir = rb->opendir(str_dirname);
275#endif
276 if (dir) 233 if (dir)
277 { 234 {
278#ifdef HAVE_DIRCACHE
279 while(0 != (entry = rb->readdir_cached(dir)))
280#else
281 while(0 != (entry = rb->readdir(dir))) 235 while(0 != (entry = rb->readdir(dir)))
282#endif
283 { 236 {
284 if(!rb->strcmp(entry->d_name, file+dirlen)) 237 if(!rb->strcmp(entry->d_name, file+dirlen))
285 { 238 {
@@ -288,11 +241,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* file)
288 break; 241 break;
289 } 242 }
290 } 243 }
291#ifdef HAVE_DIRCACHE
292 rb->closedir_cached(dir);
293#else
294 rb->closedir(dir); 244 rb->closedir(dir);
295#endif
296 } 245 }
297 /* now we know if it's a file or a dir or maybe something failed */ 246 /* now we know if it's a file or a dir or maybe something failed */
298 247
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 46a0aa56c3..93bd98ca78 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -71,11 +71,11 @@ void setoptions (void)
71 DIR* dir; 71 DIR* dir;
72 char optionsave[sizeof(savedir)+sizeof(optionname)]; 72 char optionsave[sizeof(savedir)+sizeof(optionname)];
73 73
74 dir=opendir(savedir); 74 dir=rb->opendir(savedir);
75 if(!dir) 75 if(!dir)
76 mkdir(savedir); 76 rb->mkdir(savedir);
77 else 77 else
78 closedir(dir); 78 rb->closedir(dir);
79 79
80 snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname); 80 snprintf(optionsave, sizeof(optionsave), "%s/%s", savedir, optionname);
81 81
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index ecf8a1ef6a..5d60d3f3e3 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -71,22 +71,13 @@ void dynamic_recompile (struct dynarec_block *newblock);
71#define isalnum(c) (isdigit(c) || (isalpha(c))) 71#define isalnum(c) (isdigit(c) || (isalpha(c)))
72 72
73#ifdef SIMULATOR 73#ifdef SIMULATOR
74#undef opendir
75#define opendir(a) rb->sim_opendir((a))
76#undef closedir
77#define closedir(a) rb->sim_closedir((a))
78#undef mkdir
79#define mkdir(a) rb->sim_mkdir((a))
80#undef open 74#undef open
81#define open(a,b) rb->sim_open((a),(b)) 75#define open(a,b) rb->sim_open((a),(b))
82#undef close
83#define close(a) rb->close((a))
84#undef lseek 76#undef lseek
85#define lseek(a,b,c) rb->sim_lseek((a),(b),(c)) 77#define lseek(a,b,c) rb->sim_lseek((a),(b),(c))
78#undef close
79#define close(a) rb->close((a))
86#else /* !SIMULATOR */ 80#else /* !SIMULATOR */
87#define opendir(a) rb->opendir((a))
88#define closedir(a) rb->closedir((a))
89#define mkdir(a) rb->mkdir((a))
90#define open(a,b) rb->open((a),(b)) 81#define open(a,b) rb->open((a),(b))
91#define lseek(a,b,c) rb->lseek((a),(b),(c)) 82#define lseek(a,b,c) rb->lseek((a),(b),(c))
92#define close(a) rb->close((a)) 83#define close(a) rb->close((a))
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index d478bf9947..a273e4ca37 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -688,7 +688,7 @@ static bool browse( char *dst, int dst_size, const char *start )
688 688
689 while( 1 ) 689 while( 1 )
690 { 690 {
691 d = rb->PREFIX(opendir)( bbuf ); 691 d = rb->opendir( bbuf );
692 if( !d ) 692 if( !d )
693 { 693 {
694 /* 694 /*
@@ -702,7 +702,7 @@ static bool browse( char *dst, int dst_size, const char *start )
702 else if( errno == EACCES || errno == ENOENT ) 702 else if( errno == EACCES || errno == ENOENT )
703 { 703 {
704 bbuf[0] = '/'; bbuf[1] = '\0'; 704 bbuf[0] = '/'; bbuf[1] = '\0';
705 d = rb->PREFIX(opendir)( "/" ); 705 d = rb->opendir( "/" );
706 } 706 }
707 else 707 else
708 { 708 {
@@ -714,12 +714,12 @@ static bool browse( char *dst, int dst_size, const char *start )
714 li = -1; 714 li = -1;
715 while( i < fvi ) 715 while( i < fvi )
716 { 716 {
717 rb->PREFIX(readdir)( d ); 717 rb->readdir( d );
718 i++; 718 i++;
719 } 719 }
720 while( top_inside+(i-fvi)*(fh+LINE_SPACE) < HEIGHT ) 720 while( top_inside+(i-fvi)*(fh+LINE_SPACE) < HEIGHT )
721 { 721 {
722 de = rb->PREFIX(readdir)( d ); 722 de = rb->readdir( d );
723 if( !de ) 723 if( !de )
724 { 724 {
725 li = i-1; 725 li = i-1;
@@ -737,12 +737,12 @@ static bool browse( char *dst, int dst_size, const char *start )
737 lvi = i-1; 737 lvi = i-1;
738 if( li == -1 ) 738 if( li == -1 )
739 { 739 {
740 if( !rb->PREFIX(readdir)( d ) ) 740 if( !rb->readdir( d ) )
741 { 741 {
742 li = lvi; 742 li = lvi;
743 } 743 }
744 } 744 }
745 rb->PREFIX(closedir)( d ); 745 rb->closedir( d );
746 746
747 rb->lcd_update(); 747 rb->lcd_update();
748 748
@@ -863,7 +863,7 @@ static bool browse_fonts( char *dst, int dst_size )
863 { 863 {
864 b_need_redraw = 0; 864 b_need_redraw = 0;
865 865
866 d = rb->PREFIX(opendir)( FONT_DIR "/" ); 866 d = rb->opendir( FONT_DIR "/" );
867 if( !d ) 867 if( !d )
868 { 868 {
869 return false; 869 return false;
@@ -873,7 +873,7 @@ static bool browse_fonts( char *dst, int dst_size )
873 li = -1; 873 li = -1;
874 while( i < fvi ) 874 while( i < fvi )
875 { 875 {
876 rb->PREFIX(readdir)( d ); 876 rb->readdir( d );
877 i++; 877 i++;
878 } 878 }
879 cp = top_inside+LINE_SPACE; 879 cp = top_inside+LINE_SPACE;
@@ -883,7 +883,7 @@ static bool browse_fonts( char *dst, int dst_size )
883 883
884 while( cp < top+HEIGHT ) 884 while( cp < top+HEIGHT )
885 { 885 {
886 de = rb->PREFIX(readdir)( d ); 886 de = rb->readdir( d );
887 if( !de ) 887 if( !de )
888 { 888 {
889 li = i-1; 889 li = i-1;
@@ -920,7 +920,7 @@ static bool browse_fonts( char *dst, int dst_size )
920 lvi = i-1; 920 lvi = i-1;
921 if( li == -1 ) 921 if( li == -1 )
922 { 922 {
923 if( !(de = rb->PREFIX(readdir)( d ) ) ) 923 if( !(de = rb->readdir( d ) ) )
924 { 924 {
925 li = lvi; 925 li = lvi;
926 } 926 }
@@ -936,7 +936,7 @@ static bool browse_fonts( char *dst, int dst_size )
936 } 936 }
937 } 937 }
938 rb->font_load( old_font ); 938 rb->font_load( old_font );
939 rb->PREFIX(closedir)( d ); 939 rb->closedir( d );
940 } 940 }
941 941
942 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 942 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);