Skip to content

Commit

Permalink
Merge pull request #136 from QW-Group/use_larger_integer_for_size
Browse files Browse the repository at this point in the history
BUG: use size_t for holding the size of a directory, continue calculating dir size after we've hit file number limit
  • Loading branch information
ciscon committed May 17, 2024
2 parents 3925960 + cf48f59 commit 4bdd739
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/sv_sys_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int Sys_FileTime (const char *path)
return stat(path, &buf) == -1 ? -1 : buf.st_mtime;
}

int Sys_FileSizeTime (char *path, int *time1)
int Sys_FileSizeTime (char *path, time_t *time1)
{
struct stat buf;
if (stat(path, &buf) == -1)
Expand Down Expand Up @@ -179,8 +179,8 @@ dir_t Sys_listdir (const char *path, const char *ext, int sort_type)
}
strlcpy (list[dir.numfiles].name, oneentry->d_name, MAX_DEMO_NAME);

if (++dir.numfiles == MAX_DIRFILES - 1)
break;
if (dir.numfiles != MAX_DIRFILES - 1) dir.numfiles++;

}
closedir(d);
if (!all)
Expand Down
3 changes: 1 addition & 2 deletions src/sv_sys_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ dir_t Sys_listdir (const char *path, const char *ext, int sort_type)
}
strlcpy (list[dir.numfiles].name, fd.cFileName, sizeof(list[0].name));

if (++dir.numfiles == MAX_DIRFILES - 1)
break;
if (dir.numfiles != MAX_DIRFILES - 1) dir.numfiles++;

}
while (FindNextFile(h, &fd));
Expand Down
12 changes: 6 additions & 6 deletions src/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
typedef struct
{
char name[MAX_DEMO_NAME];
int size;
int time;
size_t size;
time_t time;
qbool isdir; //bliP: list dir
} file_t;

typedef struct
{
file_t *files;
int size;
int numfiles;
int numdirs;
file_t *files;
size_t size;
size_t numfiles;
size_t numdirs;
} dir_t;

int Sys_FileTime (const char *path);
Expand Down

0 comments on commit 4bdd739

Please sign in to comment.