mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-21 06:37:30 +09:00
Leverage strings to get working dirs in nsUpdateDriver.
This commit is contained in:
parent
8b52506007
commit
a194aefa0d
1 changed files with 18 additions and 13 deletions
|
|
@ -75,21 +75,26 @@ GetUpdateLog()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
GetCurrentWorkingDir(char *buf, size_t size)
|
GetCurrentWorkingDir(nsACString& aOutPath)
|
||||||
{
|
{
|
||||||
// Cannot use NS_GetSpecialDirectory because XPCOM is not yet initialized.
|
// Cannot use NS_GetSpecialDirectory because XPCOM is not yet initialized.
|
||||||
// This code is duplicated from xpcom/io/SpecialSystemDirectory.cpp:
|
|
||||||
|
// Just in case junk has been passed in.
|
||||||
|
aOutPath.Truncate();
|
||||||
|
|
||||||
#if defined(XP_WIN)
|
#if defined(XP_WIN)
|
||||||
wchar_t wpath[MAX_PATH];
|
wchar_t wpath[MAX_PATH];
|
||||||
if (!_wgetcwd(wpath, size))
|
if (!_wgetcwd(wpath, ArrayLength(wpath)))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
NS_ConvertUTF16toUTF8 path(wpath);
|
CopyUTF16toUTF8(nsDependentString(wpath), aOutPath);
|
||||||
strncpy(buf, path.get(), size);
|
|
||||||
#else
|
#else
|
||||||
if(!getcwd(buf, size))
|
char path[MAXPATHLEN];
|
||||||
|
if (!getcwd(path, ArrayLength(path))) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
aOutPath = path;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -535,8 +540,8 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the current working directory.
|
// Get the current working directory.
|
||||||
char workingDirPath[MAXPATHLEN];
|
nsAutoCString workingDirPath;
|
||||||
rv = GetCurrentWorkingDir(workingDirPath, sizeof(workingDirPath));
|
rv = GetCurrentWorkingDir(workingDirPath);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -565,7 +570,7 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir,
|
||||||
argv[3] = (char*) applyToDir.get();
|
argv[3] = (char*) applyToDir.get();
|
||||||
argv[4] = (char*) pid.get();
|
argv[4] = (char*) pid.get();
|
||||||
if (appArgc) {
|
if (appArgc) {
|
||||||
argv[5] = workingDirPath;
|
argv[5] = (char*) workingDirPath.get();
|
||||||
argv[6] = (char*) appFilePath.get();
|
argv[6] = (char*) appFilePath.get();
|
||||||
for (int i = 1; i < appArgc; ++i)
|
for (int i = 1; i < appArgc; ++i)
|
||||||
argv[6 + i] = appArgv[i];
|
argv[6 + i] = appArgv[i];
|
||||||
|
|
@ -743,8 +748,8 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current working directory.
|
// Get the current working directory.
|
||||||
char workingDirPath[MAXPATHLEN];
|
nsAutoCString workingDirPath;
|
||||||
rv = GetCurrentWorkingDir(workingDirPath, sizeof(workingDirPath));
|
rv = GetCurrentWorkingDir(workingDirPath);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -786,7 +791,7 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile,
|
||||||
argv[3] = (char*) applyToDir.get();
|
argv[3] = (char*) applyToDir.get();
|
||||||
argv[4] = (char*) pid.get();
|
argv[4] = (char*) pid.get();
|
||||||
if (restart && appArgc) {
|
if (restart && appArgc) {
|
||||||
argv[5] = workingDirPath;
|
argv[5] = (char*) workingDirPath.get();
|
||||||
argv[6] = (char*) appFilePath.get();
|
argv[6] = (char*) appFilePath.get();
|
||||||
for (int i = 1; i < appArgc; ++i)
|
for (int i = 1; i < appArgc; ++i)
|
||||||
argv[6 + i] = appArgv[i];
|
argv[6 + i] = appArgv[i];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue