Bug 455394 Crash reporter fails if your Firefox profile is in a volume other than /home

r=luser
This commit is contained in:
timeless@mozdev.org 2009-08-18 09:04:53 -07:00
parent da105abed8
commit c455d9beb7
2 changed files with 43 additions and 2 deletions

View File

@ -41,6 +41,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <errno.h>
#include <dlfcn.h>
@ -879,7 +880,35 @@ bool UIFileExists(const string& path)
bool UIMoveFile(const string& file, const string& newfile)
{
return (rename(file.c_str(), newfile.c_str()) != -1);
if (!rename(file.c_str(), newfile.c_str()))
return true;
if (errno != EXDEV)
return false;
// use system /bin/mv instead, time to fork
pid_t pID = vfork();
if (pID < 0) {
// Failed to fork
return false;
}
if (pID == 0) {
char* const args[4] = {
"mv",
strdup(file.c_str()),
strdup(newfile.c_str()),
0
};
if (args[1] && args[2])
execve("/bin/mv", args, 0);
if (args[1])
free(args[1]);
if (args[2])
free(args[2]);
exit(-1);
}
int status;
waitpid(pID, &status, 0);
return UIFileExists(newfile);
}
bool UIDeleteFile(const string& file)

View File

@ -866,7 +866,19 @@ bool UIFileExists(const string& path)
bool UIMoveFile(const string& file, const string& newfile)
{
return (rename(file.c_str(), newfile.c_str()) != -1);
if (!rename(file.c_str(), newfile.c_str()))
return true;
if (errno != EXDEV)
return false;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *source = [fileManager stringWithFileSystemRepresentation:file.c_str() length:file.length()];
NSString *dest = [fileManager stringWithFileSystemRepresentation:newfile.c_str() length:newfile.length()];
if (!source || !dest)
return false;
[fileManager movePath:source toPath:dest handler:nil];
return UIFileExists(newfile);
}
bool UIDeleteFile(const string& file)