Skip to content

Commit

Permalink
- Handle EOVERFLOW.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Feb 15, 2024
1 parent ca21f57 commit acd0805
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions cube/swiss/source/devices/ftp/deviceHandler-FTP.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ s32 deviceHandler_FTP_readDir(file_handle* ffile, file_handle** dir, u32 type){
(*dir)[0].fileAttrib = IS_SPECIAL;

// Read each entry of the directory
while( (entry = readdir(dp)) != NULL ){
if(!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
do {
errno = 0;
entry = readdir(dp);
if(!entry || !strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
continue;
}
// Do we want this one?
Expand All @@ -124,7 +126,7 @@ s32 deviceHandler_FTP_readDir(file_handle* ffile, file_handle** dir, u32 type){
(*dir)[i].fileAttrib = S_ISDIR(fstat.st_mode) ? IS_DIR : IS_FILE;
++i;
}
}
} while(entry || errno == EOVERFLOW);

closedir(dp);
return num_entries;
Expand Down
8 changes: 5 additions & 3 deletions cube/swiss/source/devices/smb/deviceHandler-SMB.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ s32 deviceHandler_SMB_readDir(file_handle* ffile, file_handle** dir, u32 type){
(*dir)[0].fileAttrib = IS_SPECIAL;

// Read each entry of the directory
while( (entry = readdir(dp)) != NULL ){
if(!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
do {
errno = 0;
entry = readdir(dp);
if(!entry || !strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) {
continue;
}
// Do we want this one?
Expand All @@ -128,7 +130,7 @@ s32 deviceHandler_SMB_readDir(file_handle* ffile, file_handle** dir, u32 type){
(*dir)[i].fileAttrib = S_ISDIR(fstat.st_mode) ? IS_DIR : IS_FILE;
++i;
}
}
} while(entry || errno == EOVERFLOW);

closedir(dp);
return num_entries;
Expand Down

0 comments on commit acd0805

Please sign in to comment.