xref: /aoo4110/main/lucene/long_path.patch (revision b1cdbd2c)
1*b1cdbd2cSJim Jagielski--- misc/lucene-2.9.4/src/java/org/apache/lucene/store/FSDirectory.java	2010-11-27 19:21:44.000000000 -0500
2*b1cdbd2cSJim Jagielski+++ misc/build/lucene-2.9.4/src/java/org/apache/lucene/store/FSDirectory.java	2012-12-08 19:23:23.000000000 -0500
3*b1cdbd2cSJim Jagielski@@ -266,7 +266,14 @@
4*b1cdbd2cSJim Jagielski   public static FSDirectory getDirectory(File file, LockFactory lockFactory)
5*b1cdbd2cSJim Jagielski     throws IOException
6*b1cdbd2cSJim Jagielski   {
7*b1cdbd2cSJim Jagielski-    file = getCanonicalPath(file);
8*b1cdbd2cSJim Jagielski+    String path = file.getPath();
9*b1cdbd2cSJim Jagielski+    //File.getCanonicalPath fails on Windows with long path names
10*b1cdbd2cSJim Jagielski+    //Long path names created by osl_getSystemPathFromFileURL are already
11*b1cdbd2cSJim Jagielski+    //unique because its implementation replaces the occurrences of .. and .
12*b1cdbd2cSJim Jagielski+    //That is using the com.sun.star.help.HelpIndexer service from c++ is
13*b1cdbd2cSJim Jagielski+    //relatively safe.
14*b1cdbd2cSJim Jagielski+    if (!path.startsWith("\\\\?\\"))
15*b1cdbd2cSJim Jagielski+	file = getCanonicalPath(file);
16*b1cdbd2cSJim Jagielski
17*b1cdbd2cSJim Jagielski     FSDirectory dir;
18*b1cdbd2cSJim Jagielski     synchronized (DIRECTORIES) {
19*b1cdbd2cSJim Jagielski@@ -721,7 +728,15 @@
20*b1cdbd2cSJim Jagielski     ensureOpen();
21*b1cdbd2cSJim Jagielski     String dirName;                               // name to be hashed
22*b1cdbd2cSJim Jagielski     try {
23*b1cdbd2cSJim Jagielski-      dirName = directory.getCanonicalPath();
24*b1cdbd2cSJim Jagielski+      //File.getCanonicalPath fails on Windows with long path names
25*b1cdbd2cSJim Jagielski+      //Long path names created by osl_getSystemPathFromFileURL are already
26*b1cdbd2cSJim Jagielski+      //unique because its implementation replaces the occurrences of .. and .
27*b1cdbd2cSJim Jagielski+      //That is using the com.sun.star.help.HelpIndexer service from c++ is
28*b1cdbd2cSJim Jagielski+      //relatively safe.
29*b1cdbd2cSJim Jagielski+      if (!directory.getPath().startsWith("\\\\?\\"))
30*b1cdbd2cSJim Jagielski+	  dirName = directory.getCanonicalPath();
31*b1cdbd2cSJim Jagielski+      else
32*b1cdbd2cSJim Jagielski+	  dirName = directory.getPath();
33*b1cdbd2cSJim Jagielski     } catch (IOException e) {
34*b1cdbd2cSJim Jagielski       throw new RuntimeException(e.toString(), e);
35*b1cdbd2cSJim Jagielski     }
36