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