Clean up: shortening comment, adding if/else braces. Thanks Axel\!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30725 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
cf38cb6974
commit
3aa9a86343
@ -245,31 +245,12 @@ StyledEditApp::RefsReceived(BMessage *message)
|
||||
void
|
||||
StyledEditApp::ArgvReceived(int32 argc, char* argv[])
|
||||
{
|
||||
// StyledEdit has the "single launch" flag set in its
|
||||
// resources. This means that while StyledEdit is running,
|
||||
// additional StyledEdit invocations will not result in a
|
||||
// new process but re-use the existing one, calling the
|
||||
// hook methods of the BApplication subclass: ArgvReceived(),
|
||||
// RefsReceived() or MessageReceived(B_SILENT_RELAUNCH),
|
||||
// depending on the nature of the invocation.
|
||||
|
||||
// An implication of this relevant to ArgvReceived() is
|
||||
// that the running application might have a current
|
||||
// working directory different from the one of a later
|
||||
// invocation. Arguments received from the later invocation,
|
||||
// if having relative paths, will be incorrect when
|
||||
// interpreted as relative to the current working directory.
|
||||
|
||||
// BApplication's ArgvReceived() method does not supply
|
||||
// the cwd of the invocation, but the BMessage by which
|
||||
// the arguments get communicated to the BApplication
|
||||
// supplies a cwd string. So we ask the BApplication,
|
||||
// to show the current message - the one that triggered
|
||||
// the ArgvReceived() hook method - extract the cwd
|
||||
// string from it and patch any relative paths in argv.
|
||||
|
||||
// This does not take into account --option handling
|
||||
// and how to avoid prepending a path to such arguments
|
||||
// If StyledEdit is already running and gets invoked again
|
||||
// we need to account for a possible mismatch in current
|
||||
// working directory. The paths of the new arguments are
|
||||
// relative to the cwd of the invocation, if they are not
|
||||
// absolute. This cwd we find as a string named "cwd" in
|
||||
// the BLooper's current message.
|
||||
|
||||
const char* cwd = "";
|
||||
BMessage* message = CurrentMessage();
|
||||
@ -281,11 +262,12 @@ StyledEditApp::ArgvReceived(int32 argc, char* argv[])
|
||||
|
||||
for (int i = 1 ; (i < argc) ; i++) {
|
||||
BPath path;
|
||||
if (argv[i][0] == '/')
|
||||
if (argv[i][0] == '/') {
|
||||
path.SetTo(argv[i]);
|
||||
else
|
||||
} else {
|
||||
path.SetTo(cwd, argv[i]);
|
||||
// patch relative paths only
|
||||
}
|
||||
|
||||
entry_ref ref;
|
||||
get_ref_for_path(path.Path(), &ref);
|
||||
|
Loading…
Reference in New Issue
Block a user