Skip to content

Commit

Permalink
Implement PortableProfile: if a dir named "PortableProfile" exits in …
Browse files Browse the repository at this point in the history
…the same dir of the stub, use it as the profile.
  • Loading branch information
duanyao committed Mar 13, 2016
1 parent dcfec0e commit 9e375e5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/stub/nsXULStub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ main(int argc, char **argv)
char iniPath[MAXPATHLEN];
char tmpPath[MAXPATHLEN];
char greDir[MAXPATHLEN];
char portableProfileDir[MAXPATHLEN];
bool greFound = false;

#if defined(XP_MACOSX)
Expand Down Expand Up @@ -268,6 +269,9 @@ main(int argc, char **argv)

greFound = FolderExists(greDir);

snprintf(portableProfileDir, sizeof(portableProfileDir),
"%sPortableProfile", iniPath);

#ifdef XP_UNIX
if (greFound) {
char resolved_greDir[MAXPATHLEN] = "";
Expand Down Expand Up @@ -439,7 +443,29 @@ main(int argc, char **argv)
#endif
}

bool hasProfileArg = false;
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-profile") == 0) {
hasProfileArg = true;
break;
}
}
char** oldArgv = argv;
if (!hasProfileArg && FolderExists(portableProfileDir)) {
int oldArgc = argc;
argc = oldArgc + 2;
argv = new char*[argc + 1];
memcpy(argv, oldArgv, sizeof(char*) * oldArgc);
argv[argc - 2] = "-profile";
argv[argc - 1] = portableProfileDir;
argv[argc] = 0;
}

retval = XRE_main(argc, argv, appData, 0);

if (oldArgv != argv) {
delete argv;
}
}

NS_LogTerm();
Expand Down

0 comments on commit 9e375e5

Please # to comment.