--- BasiliskII/src/extfs.cpp 2007/01/22 17:14:06 1.32 +++ BasiliskII/src/extfs.cpp 2008/06/20 00:39:47 1.36 @@ -1,7 +1,7 @@ /* * extfs.cpp - MacOS file system for native file system access * - * Basilisk II (C) 1997-2005 Christian Bauer + * Basilisk II (C) 1997-2008 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -158,8 +158,8 @@ struct FSItem { uint32 id; // CNID of this file/dir uint32 parent_id; // CNID of parent file/dir FSItem *parent; // Pointer to parent - char name[32]; // Object name (C string) - Host OS - char guest_name[32]; // Object name (C string) - Guest OS + char *name; // Object name (C string) - Host OS + char guest_name[32]; // Object name (C string) - Guest OS time_t mtime; // Modification time for get_cat_info caching int cache_dircount; // Cached number of files in directory }; @@ -235,8 +235,8 @@ static FSItem *create_fsitem(const char p->id = next_cnid++; p->parent_id = parent->id; p->parent = parent; - strncpy(p->name, name, 31); - p->name[31] = 0; + p->name = new char[strlen(name) + 1]; + strcpy(p->name, name); strncpy(p->guest_name, guest_name, 31); p->guest_name[31] = 0; p->mtime = 0; @@ -274,7 +274,7 @@ static FSItem *find_fsitem_guest(const c } // Not found, construct new FSItem - return create_fsitem(guest_name, guest_name, parent); + return create_fsitem(macroman_to_host_encoding(guest_name), guest_name, parent); } /* @@ -416,6 +416,7 @@ void ExtFSInit(void) p->id = ROOT_PARENT_ID; p->parent_id = 0; p->parent = NULL; + p->name = new char[1]; p->name[0] = 0; p->guest_name[0] = 0; @@ -427,8 +428,9 @@ void ExtFSInit(void) p->id = ROOT_ID; p->parent_id = ROOT_PARENT_ID; p->parent = first_fs_item; - strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32); - p->name[31] = 0; + const char *volume_name = GetString(STR_EXTFS_VOLUME_NAME); + p->name = new char[strlen(volume_name) + 1]; + strcpy(p->name, volume_name); strncpy(p->guest_name, host_encoding_to_macroman(p->name), 32); p->guest_name[31] = 0; @@ -453,6 +455,7 @@ void ExtFSExit(void) FSItem *p = first_fs_item, *next; while (p) { next = p->next; + delete[] p->name; delete p; p = next; } @@ -1797,7 +1800,7 @@ static int16 fs_set_fpos(uint32 pb) return fnOpnErr; // Set file position - switch (ReadMacInt16(pb + ioPosMode)) { + switch (ReadMacInt16(pb + ioPosMode) & 3) { case fsFromStart: if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_SET) < 0) return posErr;