Skip to content

Commit

Permalink
DEMOS: do not list empty demo files, fixes issue #24
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscon committed Mar 14, 2024
1 parent c2dbdaa commit 26cce33
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 26cce33

Please sign in to comment.