Skip to content

Commit

Permalink
Valid files can very well be 0 bytes long, so don't generally show th…
Browse files Browse the repository at this point in the history
…ose as splat files. Fixes #1938

git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@44792 379a1393-f5fb-40a0-bcee-ef074d9b53f7
  • Loading branch information
mrdudz committed Nov 26, 2023
1 parent 31b2f48 commit 258f164
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions vice/src/fsdevice/fsdevice-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ static void command_directory_get(vdrive_t *vdrive, bufinfo_t *bufinfo,

if (direntry != NULL) {
uint8_t *p = bufinfo->name;
int splatfile = 0;
int protectfile = 0;

strcpy(buf, bufinfo->dir);
strcat(buf, ARCHDEP_DIR_SEP_STR);
Expand All @@ -473,14 +475,23 @@ static void command_directory_get(vdrive_t *vdrive, bufinfo_t *bufinfo,
*p++ = 1;

statrc = archdep_stat(buf, &filelen, &isdir);
if (statrc == 0) {
blocks = (filelen + 253) / 254;
} else {
blocks = 0; /* this file can't be opened */
if (statrc != 0) {
/* this file can't be opened */
splatfile = 1;
protectfile = 1;
}

if (archdep_access(buf, ARCHDEP_ACCESS_W_OK)) {
/* this file is read only */
protectfile = 1;
}

blocks = (filelen + 253) / 254;
if (blocks > 0xffff) {
blocks = 0xffff; /* Limit file size to 16 bits. */
/* this file is too large, guard it against opening */
splatfile = 1;
protectfile = 1;
}

SET_LO_HI(p, blocks);
Expand Down Expand Up @@ -517,7 +528,7 @@ static void command_directory_get(vdrive_t *vdrive, bufinfo_t *bufinfo,
*p++ = 'I';
*p++ = 'R';
} else {
if (blocks) {
if (splatfile == 0) {
*p++ = ' '; /* normal file */
} else {
*p++ = '*'; /* splat file */
Expand Down Expand Up @@ -551,7 +562,7 @@ static void command_directory_get(vdrive_t *vdrive, bufinfo_t *bufinfo,
}
}

if (archdep_access(buf, ARCHDEP_ACCESS_W_OK)) {
if (protectfile) {
*p++ = '<'; /* read-only file */
}

Expand Down

0 comments on commit 258f164

Please sign in to comment.