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) |
161 |
> |
char name[32]; // 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 |
|
}; |
222 |
|
return NULL; |
223 |
|
} |
224 |
|
|
225 |
+ |
/* |
226 |
+ |
* Create FSItem with the given parameters |
227 |
+ |
*/ |
228 |
+ |
|
229 |
+ |
static FSItem *create_fsitem(const char *name, const char *guest_name, FSItem *parent) |
230 |
+ |
{ |
231 |
+ |
FSItem *p = new FSItem; |
232 |
+ |
last_fs_item->next = p; |
233 |
+ |
p->next = NULL; |
234 |
+ |
last_fs_item = p; |
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; |
240 |
+ |
strncpy(p->guest_name, guest_name, 31); |
241 |
+ |
p->guest_name[31] = 0; |
242 |
+ |
p->mtime = 0; |
243 |
+ |
return p; |
244 |
+ |
} |
245 |
|
|
246 |
|
/* |
247 |
|
* Find FSItem for given name and parent, construct new FSItem if not found |
257 |
|
} |
258 |
|
|
259 |
|
// Not found, construct new FSItem |
260 |
< |
p = new FSItem; |
240 |
< |
last_fs_item->next = p; |
241 |
< |
p->next = NULL; |
242 |
< |
last_fs_item = p; |
243 |
< |
p->id = next_cnid++; |
244 |
< |
p->parent_id = parent->id; |
245 |
< |
p->parent = parent; |
246 |
< |
strncpy(p->name, name, 31); |
247 |
< |
p->name[31] = 0; |
248 |
< |
p->mtime = 0; |
249 |
< |
return p; |
260 |
> |
return create_fsitem(name, host_encoding_to_macroman(name), parent); |
261 |
|
} |
262 |
|
|
263 |
+ |
/* |
264 |
+ |
* Find FSItem for given guest_name and parent, construct new FSItem if not found |
265 |
+ |
*/ |
266 |
+ |
|
267 |
+ |
static FSItem *find_fsitem_guest(const char *guest_name, FSItem *parent) |
268 |
+ |
{ |
269 |
+ |
FSItem *p = first_fs_item; |
270 |
+ |
while (p) { |
271 |
+ |
if (p->parent == parent && !strcmp(p->guest_name, guest_name)) |
272 |
+ |
return p; |
273 |
+ |
p = p->next; |
274 |
+ |
} |
275 |
+ |
|
276 |
+ |
// Not found, construct new FSItem |
277 |
+ |
return create_fsitem(guest_name, guest_name, parent); |
278 |
+ |
} |
279 |
|
|
280 |
|
/* |
281 |
|
* Get full path (->full_path) for given FSItem |
417 |
|
p->parent_id = 0; |
418 |
|
p->parent = NULL; |
419 |
|
p->name[0] = 0; |
420 |
+ |
p->guest_name[0] = 0; |
421 |
|
|
422 |
|
// Create root FSItem |
423 |
|
p = new FSItem; |
429 |
|
p->parent = first_fs_item; |
430 |
|
strncpy(p->name, GetString(STR_EXTFS_VOLUME_NAME), 32); |
431 |
|
p->name[31] = 0; |
432 |
+ |
strncpy(p->guest_name, host_encoding_to_macroman(p->name), 32); |
433 |
+ |
p->guest_name[31] = 0; |
434 |
|
|
435 |
|
// Find path for root |
436 |
|
if ((RootPath = PrefsFindString("extfs")) != NULL) { |
941 |
|
char name[32]; |
942 |
|
strn2cstr(name, (char *)Mac2HostAddr(ReadMacInt32(parseRec + ppNamePtr)) + ReadMacInt16(parseRec + ppStartOffset) + 1, ReadMacInt16(parseRec + ppComponentLength)); |
943 |
|
D(bug(" entering %s\n", name)); |
944 |
< |
p = find_fsitem(name, p); |
944 |
> |
p = find_fsitem_guest(name, p); |
945 |
|
current_dir = p->id; |
946 |
|
|
947 |
|
// startOffset = start of next component |
964 |
|
char name[32]; |
965 |
|
strn2cstr(name, (char *)Mac2HostAddr(ReadMacInt32(parseRec + ppNamePtr)) + ReadMacInt16(parseRec + ppStartOffset) + 1, ReadMacInt16(parseRec + ppComponentLength)); |
966 |
|
D(bug(" object is %s\n", name)); |
967 |
< |
item = find_fsitem(name, p); |
967 |
> |
item = find_fsitem_guest(name, p); |
968 |
|
} |
969 |
|
} |
970 |
|
} |
1300 |
|
|
1301 |
|
// Fill in struct from fs_item and stats |
1302 |
|
if (ReadMacInt32(pb + ioNamePtr)) |
1303 |
< |
cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->name); |
1303 |
> |
cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->guest_name); |
1304 |
|
WriteMacInt16(pb + ioFRefNum, 0); |
1305 |
|
WriteMacInt8(pb + ioFlAttrib, access(full_path, W_OK) == 0 ? 0 : faLocked); |
1306 |
|
WriteMacInt32(pb + ioDirID, fs_item->id); |
1423 |
|
|
1424 |
|
// Fill in struct from fs_item and stats |
1425 |
|
if (ReadMacInt32(pb + ioNamePtr)) |
1426 |
< |
cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->name); |
1426 |
> |
cstr2pstr((char *)Mac2HostAddr(ReadMacInt32(pb + ioNamePtr)), fs_item->guest_name); |
1427 |
|
WriteMacInt16(pb + ioFRefNum, 0); |
1428 |
|
WriteMacInt8(pb + ioFlAttrib, (S_ISDIR(st.st_mode) ? faIsDir : 0) | (access(full_path, W_OK) == 0 ? 0 : faLocked)); |
1429 |
|
WriteMacInt8(pb + ioACUser, 0); |
1594 |
|
|
1595 |
|
WriteMacInt32(fcb + fcbCatPos, fd); |
1596 |
|
WriteMacInt32(fcb + fcbDirID, fs_item->parent_id); |
1597 |
< |
cstr2pstr((char *)Mac2HostAddr(fcb + fcbCName), fs_item->name); |
1597 |
> |
cstr2pstr((char *)Mac2HostAddr(fcb + fcbCName), fs_item->guest_name); |
1598 |
|
return noErr; |
1599 |
|
} |
1600 |
|
|