summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-09-18 13:38:58 -0700
committerTor Norbye <tnorbye@google.com>2014-09-18 13:38:58 -0700
commitb5fb31ef6a38f19404859755dbd2e345215b97bf (patch)
treee8787c45e494dfcc558faf0f75956f8785c39b94 /platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java
parente222a9e1e66670a56e926a6b0f3e10231eeeb1fb (diff)
parente782c57d74000722f9db4c9426317410520670c6 (diff)
downloadidea-b5fb31ef6a38f19404859755dbd2e345215b97bf.tar.gz
Merge remote-tracking branch 'aosp/upstream-master' into merge
Conflicts: .idea/libraries/asm_tools.xml .idea/libraries/bouncy_castle.xml .idea/libraries/builder_model.xml .idea/libraries/commons_compress.xml .idea/libraries/easymock_tools.xml .idea/libraries/freemarker_2_3_20.xml .idea/libraries/guava_tools.xml .idea/libraries/kxml2.xml .idea/libraries/lombok_ast.xml .idea/libraries/mockito.xml .idea/modules.xml .idea/vcs.xml build/scripts/layouts.gant updater/src/com/intellij/updater/Runner.java Change-Id: I8e1c173e00cd76c855b8a98543b0a0edfdd99d12
Diffstat (limited to 'platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java')
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java b/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java
index b508686ade00..369acf473cbc 100644
--- a/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java
+++ b/platform/platform-impl/src/com/intellij/openapi/diff/ApplicationStarterBase.java
@@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.FileInputStream;
@@ -57,13 +58,13 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx {
}
@Override
- public void processExternalCommandLine(String[] args) {
+ public void processExternalCommandLine(String[] args, @Nullable String currentDirectory) {
if (!checkArguments(args)) {
Messages.showMessageDialog(getUsageMessage(), StringUtil.toTitleCase(getCommandName()), Messages.getInformationIcon());
return;
}
try {
- processCommand(args);
+ processCommand(args, currentDirectory);
}
catch (Exception e) {
Messages.showMessageDialog(String.format("Error showing %s: %s", getCommandName(), e.getMessage()),
@@ -86,7 +87,7 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx {
public abstract String getUsageMessage();
- protected abstract void processCommand(String[] args) throws Exception;
+ protected abstract void processCommand(String[] args, @Nullable String currentDirectory) throws Exception;
@Override
public void premain(String[] args) {
@@ -99,7 +100,7 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx {
@Override
public void main(String[] args) {
try {
- processCommand(args);
+ processCommand(args, null);
}
catch (Exception e) {
e.printStackTrace();
@@ -116,12 +117,12 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx {
System.exit(0);
}
- public static VirtualFile findOrCreateFile(String path) throws IOException {
+ public static VirtualFile findOrCreateFile(String path, @Nullable String currentDirectory) throws IOException {
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(path));
if (file == null) {
boolean result = new File(path).createNewFile();
if (result) {
- return findFile(path);
+ return findFile(path, currentDirectory);
}
else {
throw new FileNotFoundException("Can't create file " + path);
@@ -167,11 +168,10 @@ public abstract class ApplicationStarterBase extends ApplicationStarterEx {
}
@NotNull
- public static VirtualFile findFile(final String path) throws OperationFailedException {
+ public static VirtualFile findFile(final String path, @Nullable String currentDirectory) throws OperationFailedException {
File ioFile = new File(path);
- if (!ioFile.exists()) {
- final String dir = PathManager.getOriginalWorkingDir();
- ioFile = new File(dir + File.separator + path);
+ if (!ioFile.isAbsolute() && currentDirectory != null) {
+ ioFile = new File(currentDirectory, path);
}
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioFile);
if (file == null) {