1 |
|
/* |
2 |
|
* extfs.cpp - MacOS file system for native file system access |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2005 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2008 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
158 |
|
uint32 id; // CNID of this file/dir |
159 |
|
uint32 parent_id; // CNID of parent file/dir |
160 |
|
FSItem *parent; // Pointer to parent |
161 |
< |
char name[32]; // Object name (C string) - Host OS |
162 |
< |
char guest_name[32]; // Object name (C string) - Guest OS |
161 |
> |
char *name; // Object name (C string) - Host OS |
162 |
> |
char guest_name[32]; // Object name (C string) - Guest OS |
163 |
|
time_t mtime; // Modification time for get_cat_info caching |
164 |
|
int cache_dircount; // Cached number of files in directory |
165 |
|
}; |
235 |
|
p->id = next_cnid++; |
236 |
|
p->parent_id = parent->id; |
237 |
|
p->parent = parent; |
238 |
< |
strncpy(p->name, name, 31); |
239 |
< |
p->name[31] = 0; |
238 |
> |
p->name = new char[strlen(name) + 1]; |
239 |
> |
strcpy(p->name, name); |
240 |
|
strncpy(p->guest_name, guest_name, 31); |
241 |
|
p->guest_name[31] = 0; |
242 |
|
p->mtime = 0; |
274 |
|
} |
275 |
|
|
276 |
|
// Not found, construct new FSItem |
277 |
< |
return create_fsitem(guest_name, guest_name, parent); |
277 |
> |
return create_fsitem(macroman_to_host_encoding(guest_name), guest_name, parent); |
278 |
|
} |
279 |
|
|
280 |
|
/* |
416 |
|
p->id = ROOT_PARENT_ID; |
417 |
|
p->parent_id = 0; |
418 |
|
p->parent = NULL; |
419 |
+ |
p->name = new char[1]; |
420 |
|
p->name[0] = 0; |
421 |
|
p->guest_name[0] = 0; |
422 |
|
|
428 |
|
p->id = ROOT_ID; |
429 |
|
p->parent_id = ROOT_PARENT_ID; |
430 |
|
p->parent = first_fs_item; |
431 |
< |
strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32); |
432 |
< |
p->name[31] = 0; |
431 |
> |
const char *volume_name = GetString(STR_EXTFS_VOLUME_NAME); |
432 |
> |
p->name = new char[strlen(volume_name) + 1]; |
433 |
> |
strcpy(p->name, volume_name); |
434 |
|
strncpy(p->guest_name, host_encoding_to_macroman(p->name), 32); |
435 |
|
p->guest_name[31] = 0; |
436 |
|
|
455 |
|
FSItem *p = first_fs_item, *next; |
456 |
|
while (p) { |
457 |
|
next = p->next; |
458 |
+ |
delete[] p->name; |
459 |
|
delete p; |
460 |
|
p = next; |
461 |
|
} |
1800 |
|
return fnOpnErr; |
1801 |
|
|
1802 |
|
// Set file position |
1803 |
< |
switch (ReadMacInt16(pb + ioPosMode)) { |
1803 |
> |
switch (ReadMacInt16(pb + ioPosMode) & 3) { |
1804 |
|
case fsFromStart: |
1805 |
|
if (lseek(fd, ReadMacInt32(pb + ioPosOffset), SEEK_SET) < 0) |
1806 |
|
return posErr; |