mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-122344 (incorrect handling of paths around PATH_MAX limit on Windows)
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -204,7 +204,7 @@ static wchar_t* ToWinPath(JNIEnv* env, jstring path, bool dirSuffix) {
|
||||
const jchar* jstr = env->GetStringChars(path, NULL);
|
||||
while (len > 0 && jstr[len - 1] == L'\\') --len; // trim trailing separators
|
||||
if (len == 0) return NULL;
|
||||
if (len >= MAX_PATH) prefix = 4; // prefix long paths by UNC marker
|
||||
if (len >= (MAX_PATH - 12)) prefix = 4; // prefix long paths by UNC marker
|
||||
if (dirSuffix) suffix = 2;
|
||||
|
||||
wchar_t* pathBuf = (wchar_t*)malloc((prefix + len + suffix + 1) * sizeof(wchar_t));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -317,8 +317,8 @@ public class FileAttributesReadingTest {
|
||||
|
||||
@Test
|
||||
public void extraLongName() throws Exception {
|
||||
final String prefix = StringUtil.repeatSymbol('a', 128) + ".";
|
||||
final File dir = FileUtil.createTempDirectory(
|
||||
String prefix = StringUtil.repeatSymbol('a', 128) + ".";
|
||||
File dir = FileUtil.createTempDirectory(
|
||||
FileUtil.createTempDirectory(
|
||||
FileUtil.createTempDirectory(
|
||||
FileUtil.createTempDirectory(
|
||||
@@ -326,7 +326,7 @@ public class FileAttributesReadingTest {
|
||||
prefix, ".dir"),
|
||||
prefix, ".dir"),
|
||||
prefix, ".dir");
|
||||
final File file = FileUtil.createTempFile(dir, prefix, ".txt");
|
||||
File file = FileUtil.createTempFile(dir, prefix, ".txt");
|
||||
assertTrue(file.exists());
|
||||
FileUtil.writeToFile(file, myTestData);
|
||||
|
||||
@@ -335,8 +335,34 @@ public class FileAttributesReadingTest {
|
||||
assertDirectoriesEqual(dir);
|
||||
}
|
||||
|
||||
final String target = FileSystemUtil.resolveSymLink(file);
|
||||
String target = FileSystemUtil.resolveSymLink(file);
|
||||
assertEquals(file.getPath(), target);
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
String path = myTempDirectory.getPath();
|
||||
int length = 250 - path.length();
|
||||
for (int i = 0; i < length / 10; i++) {
|
||||
path += "\\x_x_x_x_x";
|
||||
}
|
||||
|
||||
File baseDir = new File(path);
|
||||
assertTrue(baseDir.mkdirs());
|
||||
assertTrue(getAttributes(baseDir).isDirectory());
|
||||
|
||||
for (int i = 1; i <= 100; i++) {
|
||||
dir = new File(baseDir, StringUtil.repeat("x", i));
|
||||
assertTrue(dir.mkdir());
|
||||
assertTrue(getAttributes(dir).isDirectory());
|
||||
|
||||
file = new File(dir, "file.txt");
|
||||
FileUtil.writeToFile(file, "test".getBytes("UTF-8"));
|
||||
assertTrue(file.exists());
|
||||
assertFileAttributes(file);
|
||||
|
||||
target = FileSystemUtil.resolveSymLink(file);
|
||||
assertEquals(file.getPath(), target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user