Skip to content

Commit

Permalink
Merge pull request #25 from QW-Group/demo-listing-cull-empty
Browse files Browse the repository at this point in the history
DEMOS: do not list empty demo files, fixes issue #24
  • Loading branch information
vikpe authored Mar 14, 2024
2 parents c2dbdaa + 26cce33 commit 9e8aa9d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ void Cluster_BuildAvailableDemoList(cluster_t *cluster)
if (cluster->availdemoscount == sizeof(cluster->availdemos)/sizeof(cluster->availdemos[0]))
break;

if (ffd.nFileSizeLow == 0)
continue; // Ignore empty files

strlcpy(cluster->availdemos[cluster->availdemoscount].name, ffd.cFileName, sizeof(cluster->availdemos[0].name));
cluster->availdemos[cluster->availdemoscount].size = ffd.nFileSizeLow;
cluster->availdemos[cluster->availdemoscount].time = ffd.ftLastWriteTime.dwHighDateTime;
Expand Down Expand Up @@ -121,6 +124,9 @@ void Cluster_BuildAvailableDemoList(cluster_t *cluster)
if (stat(fullname, &sb))
continue; // Some kind of error.

if (sb.st_size == 0)
continue; // Ignore empty files

strlcpy(cluster->availdemos[cluster->availdemoscount].name, ent->d_name, sizeof(cluster->availdemos[0].name));
cluster->availdemos[cluster->availdemoscount].size = sb.st_size;
cluster->availdemos[cluster->availdemoscount].time = sb.st_mtime;
Expand Down

0 comments on commit 9e8aa9d

Please sign in to comment.