--- uae/src/od-win32/fsdb_win32.c 2018/04/24 16:59:28 1.1.1.2 +++ uae/src/od-win32/fsdb_win32.c 2018/04/24 17:08:17 1.1.1.4 @@ -13,6 +13,7 @@ #include "sysdeps.h" #include "fsdb.h" +#include /* these are deadly (but I think allowed on the Amiga): */ #define NUM_EVILCHARS 7 @@ -26,6 +27,7 @@ int fsdb_name_invalid (const char *n) char b = (a == '\0' ? a : n[1]); char c = (b == '\0' ? b : n[2]); char d = (c == '\0' ? c : n[3]); + int l = strlen (n); if (a >= 'a' && a <= 'z') a -= 32; @@ -34,19 +36,15 @@ int fsdb_name_invalid (const char *n) if (c >= 'a' && c <= 'z') c -= 32; - /* reserved dos devices */ - if ((a == 'A' && b == 'U' && c == 'X') /* AUX */ - || (a == 'C' && b == 'O' && c == 'N') /* CON */ - || (a == 'P' && b == 'R' && c == 'N') /* PRN */ - || (a == 'N' && b == 'U' && c == 'L') /* NUL */ - || (a == 'L' && b == 'P' && c == 'T' && (d >= '0' && d <= '9')) /* LPT# */ - || (a == 'C' && b == 'O' && c == 'M' && (d >= '0' && d <= '9'))) /* COM# */ + if ((a == 'A' && b == 'U' && c == 'X' && l == 3) /* AUX */ + || (a == 'C' && b == 'O' && c == 'N' && l == 3) /* CON */ + || (a == 'P' && b == 'R' && c == 'N' && l == 3) /* PRN */ + || (a == 'N' && b == 'U' && c == 'L' && l == 3) /* NUL */ + || (a == 'L' && b == 'P' && c == 'T' && (d >= '0' && d <= '9') && l == 4) /* LPT# */ + || (a == 'C' && b == 'O' && c == 'M' && (d >= '0' && d <= '9') && l == 4)) /* COM# */ return 1; - - /* spaces and periods at the beginning or the end are a no-no */ - if (n[0] == '.' || n[0] == ' ') - return 1; - + + /* spaces and periods at the end are a no-no */ i = strlen(n) - 1; if (n[i] == '.' || n[i] == ' ') return 1; @@ -82,7 +80,7 @@ void fsdb_fill_file_attrs (a_inode *aino aino->amigaos_mode = filesys_parse_mask(aino->amigaos_mode); } -int fsdb_set_file_attrs (a_inode *aino, uae_u32 mask) +int fsdb_set_file_attrs (a_inode *aino, int mask) { struct stat statbuf; uae_u32 mode=0, tmpmask; @@ -152,7 +150,7 @@ char *fsdb_create_unique_nname (a_inode /* tmpnam isn't reentrant and I don't really want to hack configure * right now to see whether tmpnam_r is available... */ for (i = 0; i < 8; i++) { - tmp[i+8] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[random () % 63]; + tmp[i+8] = "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[rand () % 63]; } } }