This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 613
Implement Brackets Portable Build on Mac and Windows #333
Open
bchintx
wants to merge
17
commits into
master
Choose a base branch
from
bchin/portable-build
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
989351a
implement portable Brackets on Windows
bchintx 502e06f
simplify portable install filename
bchintx 8c0779a
implement portable install on Mac
bchintx b722bd8
re-indenting with spaces
bchintx ce581d2
re-indenting with spaces
bchintx a08c88f
Merge remote-tracking branch 'origin/bchin/portable-build' into bchin…
bchintx 4549c80
merging latest master and porting portable changes into darkshell cla…
bchintx 698f6f6
refactoring
bchintx 92c9415
fixing merge from master on Mac
bchintx 97e10b6
Merge remote-tracking branch 'origin/master' into bchin/portable-build
bchintx 9e6c826
merging latest master changes
bchintx 4800e8b
Merge remote-tracking branch 'origin/master' into bchin/portable-build
bchintx 080a162
changes per code review
bchintx 0537c9f
fixing Mac implmentation w/ code review requested changes
bchintx dcd0165
correcting Windows build error
bchintx ab57b8a
Merge remote-tracking branch 'origin/master' into bchin/portable-build
bchintx 0bcc6ae
changes per code review
bchintx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,12 +90,46 @@ double ClientApp::GetElapsedMilliseconds() | |
return (timeGetTime() - g_appStartupTime); | ||
} | ||
|
||
// returns the directory to which the app has been installed | ||
CefString ClientApp::AppGetAppDirectory() | ||
{ | ||
// find the full pathname of the app .exe | ||
std::wstring appPath; | ||
HMODULE hModule = ::GetModuleHandle(NULL); | ||
if (hModule) | ||
{ | ||
WCHAR filename[MAX_PATH+1] = {0}; | ||
::GetModuleFileName(hModule, filename, MAX_PATH); | ||
appPath = filename; | ||
|
||
// strip off the filename and extension | ||
int idx = appPath.rfind('\\'); | ||
if (idx >= 0) | ||
appPath = appPath.substr(0, idx); | ||
} | ||
|
||
// Convert '\\' to '/' | ||
replace(appPath.begin(), appPath.end(), '\\', '/'); | ||
|
||
return CefString(appPath); | ||
} | ||
|
||
CefString ClientApp::AppGetSupportDirectory() | ||
{ | ||
wchar_t dataPath[MAX_UNC_PATH]; | ||
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, dataPath); | ||
|
||
std::wstring appSupportPath = dataPath; | ||
std::wstring appSupportPath; | ||
if (!IsPortableInstall()) | ||
{ | ||
// for normal installations, use the user's APPDATA folder | ||
wchar_t dataPath[MAX_UNC_PATH]; | ||
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, dataPath); | ||
appSupportPath = dataPath; | ||
} | ||
else | ||
{ | ||
// for portable installations, use the app's installed folder | ||
appSupportPath = ClientApp::AppGetAppDirectory(); | ||
} | ||
|
||
appSupportPath += L"\\" GROUP_NAME APP_NAME; | ||
|
||
// Convert '\\' to '/' | ||
|
@@ -116,3 +150,33 @@ CefString ClientApp::AppGetDocumentsDirectory() | |
|
||
return CefString(appUserDocuments); | ||
} | ||
|
||
|
||
// check if this is a portable installation | ||
// to be a portable installation, the installer should write the empty file to the app folder | ||
bool ClientApp::IsPortableInstall() | ||
{ | ||
typedef enum { UNINITIALIZED = -1, ISNOTPORTABLE, ISPORTABLE } ePortableFlag; | ||
static ePortableFlag isPortableInstall = UNINITIALIZED; | ||
|
||
if (isPortableInstall == UNINITIALIZED) | ||
{ | ||
std::wstring filename; | ||
GetPortableInstallFilename(filename); | ||
HANDLE hFile = ::CreateFile(filename.c_str(), GENERIC_READ, | ||
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | ||
isPortableInstall = (INVALID_HANDLE_VALUE != hFile) ? ISPORTABLE : ISNOTPORTABLE; | ||
::CloseHandle(hFile); | ||
} | ||
return (isPortableInstall == ISPORTABLE) ? true : false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not know C++ so I could be completely wrong here, but wouldn't simply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove ternary operator. |
||
} | ||
|
||
// return the name of the portable install data file | ||
void ClientApp::GetPortableInstallFilename(std::wstring& filename) | ||
{ | ||
// the existence of this file in the same folder as the Brackets application will | ||
// cause the application to be run in a "portable" state | ||
filename = ClientApp::AppGetAppDirectory(); | ||
filename += L"/"; | ||
filename += MAKEPORTABLE_BRACKETS_FILENAME; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment here is probably a tad redundant, as each clause only contains a single statement and the condition for the clause is a mere four lines above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will remove.