Fixed linux fs driver... cflash would need some rewriiting too...

This commit is contained in:
yabause 2006-11-09 21:51:39 +00:00
parent a531401927
commit 63aaea7bf8
1 changed files with 6 additions and 9 deletions

View File

@ -36,15 +36,11 @@ void * FsReadFirst(const char * path, FsEntry * entry) {
strcpy(entry->cAlternateFileName, "");
entry->flags = 0;
dir->path = strdup(path);
/* hack: reading a directory gives relative file names
* and there's no way to know that directory from
* DIR, so we're changing working directory... */
chdir(path);
getcwd(buffer, 1024);
dir->path = strdup(buffer);
sprintf(buffer, "%s/%s", dir->path, e->d_name);
stat(e->d_name, &s);
stat(buffer, &s);
if (S_ISDIR(s.st_mode)) {
entry->flags = FS_IS_DIR;
}
@ -56,6 +52,7 @@ int FsReadNext(void * search, FsEntry * entry) {
FsLinuxDir * dir = search;
struct dirent * e;
struct stat s;
char buffer[1024];
e = readdir(dir->dir);
if (!e)
@ -66,9 +63,9 @@ int FsReadNext(void * search, FsEntry * entry) {
strcpy(entry->cAlternateFileName, "");
entry->flags = 0;
chdir(dir->path);
sprintf(buffer, "%s/%s", dir->path, e->d_name);
stat(e->d_name, &s);
stat(buffer, &s);
if (S_ISDIR(s.st_mode)) {
entry->flags = FS_IS_DIR;
}