Reduce stack size a bit using proper size for buffer; reorder code a bit to
have a simpler error checking.
This commit is contained in:
parent
b5cd79371b
commit
4a3c15d11a
|
@ -37,33 +37,29 @@ void * FsReadFirst(const char * path, FsEntry * entry) {
|
|||
FsLinuxDir * dir;
|
||||
struct dirent * e;
|
||||
struct stat s;
|
||||
char buffer[1024];
|
||||
char buffer[512+1]; /* DirSpec[256] + '/' + dirent.d_name[256] */
|
||||
DIR * tmp;
|
||||
|
||||
dir = (FsLinuxDir*)malloc(sizeof(FsLinuxDir));
|
||||
if (!dir)
|
||||
return NULL;
|
||||
|
||||
tmp = opendir(path);
|
||||
if (!tmp)
|
||||
return NULL;
|
||||
dir->dir = tmp;
|
||||
|
||||
e = readdir(tmp);
|
||||
if (!e) {
|
||||
closedir(tmp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dir = (FsLinuxDir*)malloc(sizeof(FsLinuxDir));
|
||||
if (!dir) {
|
||||
closedir(tmp);
|
||||
return NULL;
|
||||
}
|
||||
dir->dir = tmp;
|
||||
|
||||
strcpy(entry->cFileName, e->d_name);
|
||||
// there's no 8.3 file names support on linux :)
|
||||
strcpy(entry->cAlternateFileName, "");
|
||||
entry->flags = 0;
|
||||
|
||||
dir->path = strdup(path);
|
||||
|
||||
sprintf(buffer, "%s/%s", dir->path, e->d_name);
|
||||
|
||||
stat(buffer, &s);
|
||||
|
|
Loading…
Reference in New Issue