aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/windows/WindowsFileOperations.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java4
2 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/windows/WindowsFileOperations.java b/src/main/java/com/google/devtools/build/lib/windows/WindowsFileOperations.java
index 516c29ec0e..4750ff5962 100644
--- a/src/main/java/com/google/devtools/build/lib/windows/WindowsFileOperations.java
+++ b/src/main/java/com/google/devtools/build/lib/windows/WindowsFileOperations.java
@@ -42,6 +42,8 @@ public class WindowsFileOperations {
// Prevent construction
}
+ private static final int MAX_PATH = 260;
+
// Keep IS_JUNCTION_* values in sync with src/main/native/windows_file_operations.cc.
private static final int IS_JUNCTION_YES = 0;
private static final int IS_JUNCTION_NO = 1;
@@ -91,11 +93,11 @@ public class WindowsFileOperations {
/**
* Returns a Windows-style path suitable to pass to unicode WinAPI functions.
*
- * <p>Returns an UNC path if `path` is longer than `MAX_PATH` (in <windows.h>). If it's shorter or
- * is already an UNC path, then this method returns `path` itself.
+ * <p>Returns an UNC path if `path` is at least `MAX_PATH` long. If it's shorter or is already an
+ * UNC path, then this method returns `path` itself.
*/
static String asLongPath(String path) {
- return path.length() > 260 && !path.startsWith("\\\\?\\")
+ return path.length() >= MAX_PATH && !path.startsWith("\\\\?\\")
? ("\\\\?\\" + path.replace('/', '\\'))
: path;
}
diff --git a/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java b/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java
index ae8b495cfd..0632baca01 100644
--- a/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/windows/WindowsSubprocessFactory.java
@@ -69,8 +69,8 @@ public class WindowsSubprocessFactory implements Subprocess.Factory {
public String processArgv0(String argv0) {
// Normalize the path and make it Windows-style.
- // If argv0 is longer than MAX_PATH (260 chars), createNativeProcess calls GetShortPathNameW to
- // obtain a 8dot3 name for it (thereby support long paths in CreateProcessA), but then argv0
+ // If argv0 is at least MAX_PATH (260 chars) long, createNativeProcess calls GetShortPathNameW
+ // to obtain a 8dot3 name for it (thereby support long paths in CreateProcessA), but then argv0
// must be prefixed with "\\?\" for GetShortPathNameW to work, so it also must be an absolute,
// normalized, Windows-style path.
// Therefore if it's absolute, then normalize it also.