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