mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-11-29 14:49:44 +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
|
* ftruncate() is missing from libnix
|
||||||
*/
|
*/
|
||||||
|
@ -455,3 +455,19 @@ size_t extfs_write(int fd, void *buffer, size_t length)
|
|||||||
}
|
}
|
||||||
return actual;
|
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;
|
errno = 0;
|
||||||
return write(fd, buffer, length);
|
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,17 +1898,10 @@ static int16 fs_delete(uint32 pb, uint32 dirID)
|
|||||||
return result;
|
return result;
|
||||||
|
|
||||||
// Delete file
|
// Delete file
|
||||||
if (remove(full_path) < 0) {
|
if (!extfs_remove(full_path))
|
||||||
int16 err = errno2oserr();
|
|
||||||
if (errno == EISDIR) { // Workaround for BeOS bug
|
|
||||||
if (rmdir(full_path) < 0)
|
|
||||||
return errno2oserr();
|
return errno2oserr();
|
||||||
else
|
else
|
||||||
return noErr;
|
return noErr;
|
||||||
} else
|
|
||||||
return err;
|
|
||||||
} else
|
|
||||||
return noErr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rename file/directory
|
// Rename file/directory
|
||||||
|
@ -42,6 +42,7 @@ extern int open_rfork(const char *path, int flag);
|
|||||||
extern void close_rfork(const char *path, int fd);
|
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_read(int fd, void *buffer, size_t length);
|
||||||
extern size_t extfs_write(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
|
// Maximum length of full path name
|
||||||
const int MAX_PATH_LENGTH = 1024;
|
const int MAX_PATH_LENGTH = 1024;
|
||||||
|
Loading…
Reference in New Issue
Block a user