Lines 43-55
Link Here
|
43 |
|
43 |
|
44 |
import java.io.File; |
44 |
import java.io.File; |
45 |
import java.io.IOException; |
45 |
import java.io.IOException; |
|
|
46 |
import java.nio.charset.Charset; |
46 |
import java.util.ArrayList; |
47 |
import java.util.ArrayList; |
47 |
import java.util.Collections; |
48 |
import java.util.Collections; |
48 |
import java.util.List; |
49 |
import java.util.List; |
49 |
import java.util.Set; |
50 |
import java.util.Set; |
|
|
51 |
import java.util.logging.Level; |
52 |
import java.util.logging.Logger; |
50 |
import javax.tools.JavaFileObject; |
53 |
import javax.tools.JavaFileObject; |
51 |
import org.netbeans.api.java.classpath.ClassPath; |
54 |
import org.netbeans.api.java.classpath.ClassPath; |
|
|
55 |
import org.netbeans.api.queries.FileEncodingQuery; |
52 |
import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation; |
56 |
import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation; |
|
|
57 |
import org.openide.filesystems.FileObject; |
58 |
import org.openide.filesystems.FileUtil; |
53 |
|
59 |
|
54 |
/** |
60 |
/** |
55 |
* |
61 |
* |
Lines 57-68
Link Here
|
57 |
*/ |
63 |
*/ |
58 |
public class FolderArchive implements Archive { |
64 |
public class FolderArchive implements Archive { |
59 |
|
65 |
|
|
|
66 |
private static final Logger LOG = Logger.getLogger(FolderArchive.class.getName()); |
67 |
|
60 |
final File root; |
68 |
final File root; |
|
|
69 |
final Charset encoding; |
61 |
|
70 |
|
62 |
/** Creates a new instance of FolderArchive */ |
71 |
/** Creates a new instance of FolderArchive */ |
63 |
public FolderArchive (final File root) { |
72 |
public FolderArchive (final File root) { |
64 |
assert root != null; |
73 |
assert root != null; |
65 |
this.root = root; |
74 |
this.root = root; |
|
|
75 |
|
76 |
if (LOG.isLoggable(Level.FINE)) { |
77 |
LOG.log(Level.FINE, "creating FolderArchive for {0}", root.getAbsolutePath()); |
78 |
} |
79 |
|
80 |
FileObject file = FileUtil.toFileObject(root); |
81 |
|
82 |
if (file != null) { |
83 |
encoding = FileEncodingQuery.getEncoding(file); |
84 |
} else { |
85 |
encoding = null; |
86 |
} |
66 |
} |
87 |
} |
67 |
|
88 |
|
68 |
public Iterable<JavaFileObject> getFiles(String folderName, ClassPath.Entry entry, Set<JavaFileObject.Kind> kinds, JavaFileFilterImplementation filter) throws IOException { |
89 |
public Iterable<JavaFileObject> getFiles(String folderName, ClassPath.Entry entry, Set<JavaFileObject.Kind> kinds, JavaFileFilterImplementation filter) throws IOException { |
Lines 80-86
Link Here
|
80 |
if (f.isFile()) { |
101 |
if (f.isFile()) { |
81 |
if (entry == null || entry.includes(f.toURI().toURL())) { |
102 |
if (entry == null || entry.includes(f.toURI().toURL())) { |
82 |
if (kinds == null || kinds.contains(FileObjects.getKind(FileObjects.getExtension(f.getName())))) { |
103 |
if (kinds == null || kinds.contains(FileObjects.getKind(FileObjects.getExtension(f.getName())))) { |
83 |
result.add(FileObjects.fileFileObject(f,this.root,filter)); |
104 |
result.add(FileObjects.fileFileObject(f,this.root,filter, encoding)); |
84 |
} |
105 |
} |
85 |
} |
106 |
} |
86 |
} |
107 |
} |