Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: use size_t for holding the size of a directory, continue calculating dir size after we've hit file number limit #136

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading