mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-09-07 16:54:28 +00:00
- fs_delete() will also delete helper files
This commit is contained in:
parent
5bad3ea92e
commit
30b45e559b
@ -365,6 +365,31 @@ size_t extfs_write(int fd, void *buffer, size_t length)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove file/directory (and associated helper files),
|
||||
* returns false on error (and sets errno)
|
||||
*/
|
||||
|
||||
bool extfs_remove(const char *path)
|
||||
{
|
||||
// Remove helpers first, don't complain if this fails
|
||||
char helper_path[MAX_PATH_LENGTH];
|
||||
make_helper_path(path, helper_path, ".finf/", false);
|
||||
remove(helper_path);
|
||||
make_helper_path(path, helper_path, ".rsrc/", false);
|
||||
remove(helper_path);
|
||||
|
||||
// Now remove file or directory
|
||||
if (remove(path) < 0) {
|
||||
if (errno == EISDIR)
|
||||
return rmdir(path) == 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ftruncate() is missing from libnix
|
||||
*/
|
||||
|
@ -455,3 +455,19 @@ size_t extfs_write(int fd, void *buffer, size_t length)
|
||||
}
|
||||
return actual;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove file/directory, returns false on error (and sets errno)
|
||||
*/
|
||||
|
||||
bool extfs_remove(const char *path)
|
||||
{
|
||||
if (remove(path) < 0) {
|
||||
if (errno == EISDIR)
|
||||
return rmdir(path) == 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -368,3 +368,28 @@ size_t extfs_write(int fd, void *buffer, size_t length)
|
||||
errno = 0;
|
||||
return write(fd, buffer, length);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Remove file/directory (and associated helper files),
|
||||
* returns false on error (and sets errno)
|
||||
*/
|
||||
|
||||
bool extfs_remove(const char *path)
|
||||
{
|
||||
// Remove helpers first, don't complain if this fails
|
||||
char helper_path[MAX_PATH_LENGTH];
|
||||
make_helper_path(path, helper_path, ".finf/", false);
|
||||
remove(helper_path);
|
||||
make_helper_path(path, helper_path, ".rsrc/", false);
|
||||
remove(helper_path);
|
||||
|
||||
// Now remove file or directory
|
||||
if (remove(path) < 0) {
|
||||
if (errno == EISDIR)
|
||||
return rmdir(path) == 0;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1898,16 +1898,9 @@ static int16 fs_delete(uint32 pb, uint32 dirID)
|
||||
return result;
|
||||
|
||||
// Delete file
|
||||
if (remove(full_path) < 0) {
|
||||
int16 err = errno2oserr();
|
||||
if (errno == EISDIR) { // Workaround for BeOS bug
|
||||
if (rmdir(full_path) < 0)
|
||||
return errno2oserr();
|
||||
else
|
||||
return noErr;
|
||||
} else
|
||||
return err;
|
||||
} else
|
||||
if (!extfs_remove(full_path))
|
||||
return errno2oserr();
|
||||
else
|
||||
return noErr;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ extern int open_rfork(const char *path, int flag);
|
||||
extern void close_rfork(const char *path, int fd);
|
||||
extern size_t extfs_read(int fd, void *buffer, size_t length);
|
||||
extern size_t extfs_write(int fd, void *buffer, size_t length);
|
||||
extern bool extfs_remove(const char *path);
|
||||
|
||||
// Maximum length of full path name
|
||||
const int MAX_PATH_LENGTH = 1024;
|
||||
|
Loading…
Reference in New Issue
Block a user