diff --git a/BasiliskII/ChangeLog b/BasiliskII/ChangeLog index 311257e0..47d55b3f 100644 --- a/BasiliskII/ChangeLog +++ b/BasiliskII/ChangeLog @@ -7,6 +7,7 @@ V0.9 - - Unix: FreeBSD configure script cleanups [Michael Alyn Miller] - Unix: ether_linux.cpp moved and renamed to ether_unix.cpp, now also works with the tap driver under FreeBSD [Michael Alyn Miller] + - BeOS: fixed some bugs in the extfs file types handling V0.9 (snapshot) - 17.Feb.2001 - adapted for mon V3.0 which is now the required minimum diff --git a/BasiliskII/src/AmigaOS/extfs_amiga.cpp b/BasiliskII/src/AmigaOS/extfs_amiga.cpp index 3eb1c4b8..dd047f2e 100644 --- a/BasiliskII/src/AmigaOS/extfs_amiga.cpp +++ b/BasiliskII/src/AmigaOS/extfs_amiga.cpp @@ -211,7 +211,7 @@ static const ext2type e2t_translation[] = { {NULL, 0, 0} // End marker }; -void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) +void get_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) { // Set default finder info Mac_memset(finfo, 0, SIZEOF_FInfo); @@ -232,8 +232,7 @@ void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) } // No Finder info file, translate file name extension to MacOS type/creator - struct stat st; - if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) { + if (!is_dir) { int path_len = strlen(path); for (int i=0; e2t_translation[i].ext; i++) { int ext_len = strlen(e2t_translation[i].ext); @@ -248,7 +247,7 @@ void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) } } -void set_finfo(const char *path, uint32 finfo, uint32 fxinfo) +void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) { // Open Finder info file int fd = open_finf(path, O_RDWR); diff --git a/BasiliskII/src/BeOS/extfs_beos.cpp b/BasiliskII/src/BeOS/extfs_beos.cpp index d56e5d80..23705260 100644 --- a/BasiliskII/src/BeOS/extfs_beos.cpp +++ b/BasiliskII/src/BeOS/extfs_beos.cpp @@ -137,7 +137,7 @@ static const mime2type m2t_translation[] = { {NULL, 0, 0, false} // End marker }; -void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) +void get_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) { // Set default finder info Mac_memset(finfo, 0, SIZEOF_FInfo); @@ -151,87 +151,84 @@ void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) if (fd < 0) return; - // Read BeOS MIME type - char mime[256]; - ssize_t actual = fs_read_attr(fd, "BEOS:TYPE", B_MIME_STRING_TYPE, 0, mime, 256); - mime[255] = 0; + if (!is_dir) { - if (actual > 0) { + // Read BeOS MIME type + ssize_t actual = fs_read_attr(fd, "BEOS:TYPE", B_MIME_STRING_TYPE, 0, tmp_buf, 256); + tmp_buf[255] = 0; - // Translate MIME type to MacOS type/creator - uint8 mactype[4]; - if (sscanf(mime, "application/x-MacOS-%c%c%c%c", mactype, mactype+1, mactype+2, mactype+3) == 4) { + if (actual > 0) { - // MacOS style type - WriteMacInt32(finfo + fdType, (mactype[0] << 24) | (mactype[1] << 16) | (mactype[2] << 8) | mactype[3]); + // Translate MIME type to MacOS type/creator + uint8 mactype[4]; + if (sscanf((char *)tmp_buf, "application/x-MacOS-%c%c%c%c", mactype, mactype+1, mactype+2, mactype+3) == 4) { - } else { + // MacOS style type + WriteMacInt32(finfo + fdType, (mactype[0] << 24) | (mactype[1] << 16) | (mactype[2] << 8) | mactype[3]); - // MIME string, look in table - for (int i=0; m2t_translation[i].mime; i++) { - if (!strcmp(mime, m2t_translation[i].mime)) { - WriteMacInt32(finfo + fdType, m2t_translation[i].type); - WriteMacInt32(finfo + fdCreator, m2t_translation[i].creator); - break; + } else { + + // MIME string, look in table + for (int i=0; m2t_translation[i].mime; i++) { + if (!strcmp((char *)tmp_buf, m2t_translation[i].mime)) { + WriteMacInt32(finfo + fdType, m2t_translation[i].type); + WriteMacInt32(finfo + fdCreator, m2t_translation[i].creator); + break; + } } } } + + // Override file type with MACOS:CREATOR attribute + if (fs_read_attr(fd, "MACOS:CREATOR", B_UINT32_TYPE, 0, tmp_buf, 4) == 4) + WriteMacInt32(finfo + fdCreator, (tmp_buf[0] << 24) | (tmp_buf[1] << 16) | (tmp_buf[2] << 8) | tmp_buf[3]); } - // Override file type with MACOS:CREATOR attribute - if (fs_read_attr(fd, "MACOS:CREATOR", B_UINT32_TYPE, 0, &mime, 4) == 4) - WriteMacInt32(finfo + fdCreator, (mime[0] << 24) | (mime[1] << 16) | (mime[2] << 8) | mime[3]); - // Read MACOS:HFS_FLAGS attribute - if (fs_read_attr(fd, "MACOS:HFS_FLAGS", B_UINT16_TYPE, 0, &mime, 2) == 2) - WriteMacInt16(finfo + fdFlags, (mime[0] << 8) | mime[1]); + if (fs_read_attr(fd, "MACOS:HFS_FLAGS", B_UINT16_TYPE, 0, tmp_buf, 2) == 2) + WriteMacInt16(finfo + fdFlags, (tmp_buf[0] << 8) | tmp_buf[1]); // Close file close(fd); } -void set_finfo(const char *path, uint32 finfo, uint32 fxinfo) +void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) { - char mime[256]; - // Open file int fd = open(path, O_WRONLY); if (fd < 0) return; - // Set BEOS:TYPE attribute - uint32 type = ReadMacInt32(finfo + fdType); - if (type) { - bool written = false; - for (int i=0; m2t_translation[i].mime; i++) { - if (m2t_translation[i].type == type && m2t_translation[i].reversible) { - fs_write_attr(fd, "BEOS:TYPE", B_MIME_STRING_TYPE, 0, m2t_translation[i].mime, strlen(m2t_translation[i].mime) + 1); - written = true; - break; + if (!is_dir) { + + // Set BEOS:TYPE attribute + uint32 type = ReadMacInt32(finfo + fdType); + if (type) { + for (int i=0; m2t_translation[i].mime; i++) { + if (m2t_translation[i].type == type && m2t_translation[i].reversible) { + fs_write_attr(fd, "BEOS:TYPE", B_MIME_STRING_TYPE, 0, m2t_translation[i].mime, strlen(m2t_translation[i].mime) + 1); + break; + } } } - if (!written) { - sprintf(mime, "application/x-MacOS-%c%c%c%c", type >> 24, type >> 16, type >> 8, type); - fs_write_attr(fd, "BEOS:TYPE", B_MIME_STRING_TYPE, 0, mime, strlen(mime) + 1); - } - } - // Set MACOS:CREATOR attribute - uint32 creator = ReadMacInt32(finfo + fdType); - if (creator) { - mime[0] = creator >> 24; - mime[1] = creator >> 16; - mime[2] = creator >> 8; - mime[3] = creator; - fs_write_attr(fd, "MACOS:CREATOR", B_UINT32_TYPE, 0, &mime, 4); + // Set MACOS:CREATOR attribute + uint32 creator = ReadMacInt32(finfo + fdCreator); + if (creator) { + tmp_buf[0] = creator >> 24; + tmp_buf[1] = creator >> 16; + tmp_buf[2] = creator >> 8; + tmp_buf[3] = creator; + fs_write_attr(fd, "MACOS:CREATOR", B_UINT32_TYPE, 0, tmp_buf, 4); + } } // Write MACOS:HFS_FLAGS attribute uint16 flags = ReadMacInt16(finfo + fdFlags); if (flags != DEFAULT_FINDER_FLAGS) { - mime[0] = flags >> 8; - mime[1] = flags; - fs_write_attr(fd, "MACOS:HFS_FLAGS", B_UINT16_TYPE, 0, &mime, 2); + tmp_buf[0] = flags >> 8; + tmp_buf[1] = flags; + fs_write_attr(fd, "MACOS:HFS_FLAGS", B_UINT16_TYPE, 0, tmp_buf, 2); } else fs_remove_attr(fd, "MACOS:HFS_FLAGS"); diff --git a/BasiliskII/src/BeOS/video_beos.cpp b/BasiliskII/src/BeOS/video_beos.cpp index f8841061..cebd5ade 100644 --- a/BasiliskII/src/BeOS/video_beos.cpp +++ b/BasiliskII/src/BeOS/video_beos.cpp @@ -41,7 +41,6 @@ #include "memory.h" #include "readcpu.h" #include "newcpu.h" -#include "compiler.h" #define DEBUG 0 #include "debug.h" diff --git a/BasiliskII/src/Unix/extfs_unix.cpp b/BasiliskII/src/Unix/extfs_unix.cpp index ffb665cf..d810ce97 100644 --- a/BasiliskII/src/Unix/extfs_unix.cpp +++ b/BasiliskII/src/Unix/extfs_unix.cpp @@ -218,7 +218,7 @@ static const ext2type e2t_translation[] = { {NULL, 0, 0} // End marker }; -void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) +void get_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) { // Set default finder info Mac_memset(finfo, 0, SIZEOF_FInfo); @@ -239,8 +239,7 @@ void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) } // No Finder info file, translate file name extension to MacOS type/creator - struct stat st; - if (stat(path, &st) == 0 && !S_ISDIR(st.st_mode)) { + if (!is_dir) { int path_len = strlen(path); for (int i=0; e2t_translation[i].ext; i++) { int ext_len = strlen(e2t_translation[i].ext); @@ -255,7 +254,7 @@ void get_finfo(const char *path, uint32 finfo, uint32 fxinfo) } } -void set_finfo(const char *path, uint32 finfo, uint32 fxinfo) +void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir) { // Open Finder info file int fd = open_finf(path, O_RDWR); diff --git a/BasiliskII/src/extfs.cpp b/BasiliskII/src/extfs.cpp index c138cd3b..5638a606 100644 --- a/BasiliskII/src/extfs.cpp +++ b/BasiliskII/src/extfs.cpp @@ -1237,7 +1237,7 @@ read_next_de: #endif WriteMacInt32(pb + ioFlMdDat, st.st_mtime + TIME_OFFSET); - get_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0); + get_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0, false); WriteMacInt16(pb + ioFlStBlk, 0); WriteMacInt32(pb + ioFlLgLen, st.st_size); @@ -1274,7 +1274,7 @@ static int16 fs_set_file_info(uint32 pb, bool hfs, uint32 dirID) return fnfErr; // Set Finder info - set_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0); + set_finfo(full_path, pb + ioFlFndrInfo, hfs ? pb + ioFlXFndrInfo : 0, false); //!! times return noErr; @@ -1366,7 +1366,7 @@ read_next_de: WriteMacInt32(pb + ioFlMdDat, mtime + TIME_OFFSET); WriteMacInt32(pb + ioFlBkDat, 0); - get_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo); + get_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo, S_ISDIR(st.st_mode)); if (S_ISDIR(st.st_mode)) { @@ -1422,7 +1422,7 @@ static int16 fs_set_cat_info(uint32 pb) return errno2oserr(); // Set Finder info - set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo); + set_finfo(full_path, pb + ioFlFndrInfo, pb + ioFlXFndrInfo, S_ISDIR(st.st_mode)); //!! times return noErr; @@ -1510,7 +1510,7 @@ static int16 fs_open(uint32 pb, uint32 dirID, uint32 vcb, bool resource_fork) WriteMacInt32(fcb + fcbVPtr, vcb); WriteMacInt32(fcb + fcbClmpSize, CLUMP_SIZE); - get_finfo(full_path, fs_data + fsPB, 0); + get_finfo(full_path, fs_data + fsPB, 0, false); WriteMacInt32(fcb + fcbFType, ReadMacInt32(fs_data + fsPB + fdType)); WriteMacInt32(fcb + fcbCatPos, fd); diff --git a/BasiliskII/src/include/extfs.h b/BasiliskII/src/include/extfs.h index b1f85822..92b175f1 100644 --- a/BasiliskII/src/include/extfs.h +++ b/BasiliskII/src/include/extfs.h @@ -33,8 +33,8 @@ extern int16 ExtFSHFS(uint32 vcb, uint16 selectCode, uint32 paramBlock, uint32 g extern void extfs_init(void); extern void extfs_exit(void); extern void add_path_component(char *path, const char *component); -extern void get_finfo(const char *path, uint32 finfo, uint32 fxinfo); -extern void set_finfo(const char *path, uint32 finfo, uint32 fxinfo); +extern void get_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir); +extern void set_finfo(const char *path, uint32 finfo, uint32 fxinfo, bool is_dir); extern uint32 get_rfork_size(const char *path); extern int open_rfork(const char *path, int flag); extern void close_rfork(const char *path, int fd);