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
Родитель b5592178c6
Коммит 72a576fb4d
2 изменённых файлов: 43 добавлений и 2 удалений

Просмотреть файл

@ -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)

Просмотреть файл

@ -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)