72 |
|
|
73 |
|
|
74 |
|
/* |
75 |
+ |
* Add component to path name |
76 |
+ |
*/ |
77 |
+ |
|
78 |
+ |
void add_path_component(char *path, const char *component) |
79 |
+ |
{ |
80 |
+ |
int l = strlen(path); |
81 |
+ |
if (l < MAX_PATH_LENGTH-1 && path[l-1] != '/') { |
82 |
+ |
path[l] = '/'; |
83 |
+ |
path[l+1] = 0; |
84 |
+ |
} |
85 |
+ |
strncat(path, component, MAX_PATH_LENGTH-1); |
86 |
+ |
} |
87 |
+ |
|
88 |
+ |
|
89 |
+ |
/* |
90 |
|
* Get/set finder type/creator for file specified by full path |
91 |
|
*/ |
92 |
|
|
283 |
|
// Open temporary file for resource fork |
284 |
|
char rname[L_tmpnam]; |
285 |
|
tmpnam(rname); |
286 |
< |
int rfd = open(rname, O_RDWR | O_CREAT | O_TRUNC, 0664); |
286 |
> |
int rfd = open(rname, O_RDWR | O_CREAT | O_TRUNC, 0666); |
287 |
|
if (rfd < 0) { |
288 |
|
close(fd); |
289 |
|
return -1; |
455 |
|
} |
456 |
|
return actual; |
457 |
|
} |
458 |
+ |
|
459 |
+ |
|
460 |
+ |
/* |
461 |
+ |
* Remove file/directory, returns false on error (and sets errno) |
462 |
+ |
*/ |
463 |
+ |
|
464 |
+ |
bool extfs_remove(const char *path) |
465 |
+ |
{ |
466 |
+ |
if (remove(path) < 0) { |
467 |
+ |
if (errno == EISDIR) |
468 |
+ |
return rmdir(path) == 0; |
469 |
+ |
else |
470 |
+ |
return false; |
471 |
+ |
} |
472 |
+ |
return true; |
473 |
+ |
} |
474 |
+ |
|
475 |
+ |
|
476 |
+ |
/* |
477 |
+ |
* Rename/move file/directory, returns false on error (and sets errno) |
478 |
+ |
*/ |
479 |
+ |
|
480 |
+ |
bool extfs_rename(const char *old_path, const char *new_path) |
481 |
+ |
{ |
482 |
+ |
return rename(old_path, new_path) == 0; |
483 |
+ |
} |