204 |
|
const int MAX_PATH_LENGTH = 1024; |
205 |
|
static char full_path[MAX_PATH_LENGTH]; |
206 |
|
|
207 |
< |
static void add_path_component(const char *s) |
207 |
> |
static void add_path_comp(const char *s) |
208 |
|
{ |
209 |
< |
int l = strlen(full_path); |
210 |
< |
if (l < MAX_PATH_LENGTH-1 && full_path[l-1] != '/') { |
211 |
< |
full_path[l] = '/'; |
212 |
< |
full_path[l+1] = 0; |
213 |
< |
} |
214 |
< |
strncat(full_path, s, MAX_PATH_LENGTH-1); |
209 |
> |
add_path_component(full_path, s, MAX_PATH_LENGTH); |
210 |
|
} |
211 |
|
|
212 |
|
static void get_path_for_fsitem(FSItem *p) |
216 |
|
full_path[MAX_PATH_LENGTH-1] = 0; |
217 |
|
} else { |
218 |
|
get_path_for_fsitem(p->parent); |
219 |
< |
add_path_component(p->name); |
219 |
> |
add_path_comp(p->name); |
220 |
|
} |
221 |
|
} |
222 |
|
|
435 |
|
WriteMacInt16(p, 0x7006); p+= 2; // UTAllocateVCB |
436 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
437 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
438 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
438 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
439 |
|
if (p - fs_data != fsAddNewVCB) |
440 |
|
goto fsdat_error; |
441 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
445 |
|
WriteMacInt16(p, 0x7007); p+= 2; // UTAddNewVCB |
446 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
447 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
448 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
448 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
449 |
|
if (p - fs_data != fsDetermineVol) |
450 |
|
goto fsdat_error; |
451 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
457 |
|
WriteMacInt16(p, 0x701d); p+= 2; // UTDetermineVol |
458 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
459 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
460 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
460 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
461 |
|
if (p - fs_data != fsResolveWDCB) |
462 |
|
goto fsdat_error; |
463 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
468 |
|
WriteMacInt16(p, 0x700e); p+= 2; // UTResolveWDCB |
469 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
470 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
471 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
471 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
472 |
|
if (p - fs_data != fsGetDefaultVol) |
473 |
|
goto fsdat_error; |
474 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
476 |
|
WriteMacInt16(p, 0x7012); p+= 2; // UTGetDefaultVol |
477 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
478 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
479 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
479 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
480 |
|
if (p - fs_data != fsGetPathComponentName) |
481 |
|
goto fsdat_error; |
482 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
484 |
|
WriteMacInt16(p, 0x701c); p+= 2; // UTGetPathComponentName |
485 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
486 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
487 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
487 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
488 |
|
if (p - fs_data != fsParsePathname) |
489 |
|
goto fsdat_error; |
490 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
493 |
|
WriteMacInt16(p, 0x701b); p+= 2; // UTParsePathname |
494 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
495 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
496 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
496 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
497 |
|
if (p - fs_data != fsDisposeVCB) |
498 |
|
goto fsdat_error; |
499 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
501 |
|
WriteMacInt16(p, 0x7008); p+= 2; // UTDisposeVCB |
502 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
503 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
504 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
504 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
505 |
|
if (p - fs_data != fsCheckWDRefNum) |
506 |
|
goto fsdat_error; |
507 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
509 |
|
WriteMacInt16(p, 0x7013); p+= 2; // UTCheckWDRefNum |
510 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
511 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
512 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
512 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
513 |
|
if (p - fs_data != fsSetDefaultVol) |
514 |
|
goto fsdat_error; |
515 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
519 |
|
WriteMacInt16(p, 0x7011); p+= 2; // UTSetDefaultVol |
520 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
521 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
522 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
522 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
523 |
|
if (p - fs_data != fsAllocateFCB) |
524 |
|
goto fsdat_error; |
525 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
528 |
|
WriteMacInt16(p, 0x7000); p+= 2; // UTAllocateFCB |
529 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
530 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
531 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
531 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
532 |
|
if (p - fs_data != fsReleaseFCB) |
533 |
|
goto fsdat_error; |
534 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
536 |
|
WriteMacInt16(p, 0x7001); p+= 2; // UTReleaseFCB |
537 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
538 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
539 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
539 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
540 |
|
if (p - fs_data != fsIndexFCB) |
541 |
|
goto fsdat_error; |
542 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
546 |
|
WriteMacInt16(p, 0x7004); p+= 2; // UTIndexFCB |
547 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
548 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
549 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
549 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
550 |
|
if (p - fs_data != fsResolveFCB) |
551 |
|
goto fsdat_error; |
552 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
555 |
|
WriteMacInt16(p, 0x7005); p+= 2; // UTResolveFCB |
556 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
557 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
558 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
558 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
559 |
|
if (p - fs_data != fsAdjustEOF) |
560 |
|
goto fsdat_error; |
561 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
563 |
|
WriteMacInt16(p, 0x7010); p+= 2; // UTAdjustEOF |
564 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
565 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
566 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
566 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
567 |
|
if (p - fs_data != fsAllocateWDCB) |
568 |
|
goto fsdat_error; |
569 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
571 |
|
WriteMacInt16(p, 0x700c); p+= 2; // UTAllocateWDCB |
572 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
573 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
574 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
574 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
575 |
|
if (p - fs_data != fsReleaseWDCB) |
576 |
|
goto fsdat_error; |
577 |
|
WriteMacInt16(p, 0x4267); p+= 2; // clr.w -(sp) |
579 |
|
WriteMacInt16(p, 0x700d); p+= 2; // UTReleaseWDCB |
580 |
|
WriteMacInt16(p, 0xa824); p+= 2; // FSMgr |
581 |
|
WriteMacInt16(p, 0x301f); p+= 2; // move.w (sp)+,d0 |
582 |
< |
WriteMacInt16(p, M68K_EXEC_RETURN); p+= 2; |
582 |
> |
WriteMacInt16(p, M68K_RTS); p+= 2; |
583 |
|
if (p - fs_data != SIZEOF_fsdat) |
584 |
|
goto fsdat_error; |
585 |
|
|
1187 |
|
goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) |
1188 |
|
//!! suppress directories |
1189 |
|
} |
1190 |
< |
add_path_component(de->d_name); |
1190 |
> |
add_path_comp(de->d_name); |
1191 |
|
|
1192 |
|
// Get FSItem for queried item |
1193 |
|
fs_item = find_fsitem(de->d_name, p); |
1315 |
|
if (de->d_name[0] == '.') |
1316 |
|
goto read_next_de; // Suppress name beginning with '.' (MacOS could interpret these as driver names) |
1317 |
|
} |
1318 |
< |
add_path_component(de->d_name); |
1318 |
> |
add_path_comp(de->d_name); |
1319 |
|
|
1320 |
|
// Get FSItem for queried item |
1321 |
|
fs_item = find_fsitem(de->d_name, p); |
1973 |
|
return result; |
1974 |
|
|
1975 |
|
// Append old file/dir name |
1976 |
< |
add_path_component(fs_item->name); |
1976 |
> |
add_path_comp(fs_item->name); |
1977 |
|
|
1978 |
|
// Does the new name already exist? |
1979 |
|
if (access(full_path, F_OK) == 0) |