use of org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
the class JavacFileManager method listDirectory.
/**
* Insert all files in subdirectory subdirectory of directory directory
* which match fileKinds into resultList
*/
private void listDirectory(File directory, RelativeDirectory subdirectory, Set<JavaFileObject.Kind> fileKinds, boolean recurse, ListBuffer<JavaFileObject> resultList) {
File d = subdirectory.getFile(directory);
if (!caseMapCheck(d, subdirectory))
return;
File[] files = d.listFiles();
if (files == null)
return;
if (sortFiles != null)
Arrays.sort(files, sortFiles);
for (File f : files) {
String fname = f.getName();
if (f.isDirectory()) {
if (recurse && isValidDirectory(fname)) {
listDirectory(directory, new RelativeDirectory(subdirectory, fname), fileKinds, recurse, resultList);
}
} else {
if (isValidFile(fname, fileKinds)) {
JavaFileObject fe = new RegularFileObject(this, fname, new File(d, fname));
resultList.append(fe);
}
}
}
}
use of org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
the class SymbolArchive method getFileObject.
@Override
public JavaFileObject getFileObject(RelativeDirectory subdirectory, String file) {
RelativeDirectory prefix_subdir = new RelativeDirectory(prefix, subdirectory.path);
ZipEntry ze = new RelativeFile(prefix_subdir, file).getZipEntry(zfile);
return new SymbolFileObject(this, file, ze);
}
use of org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
the class ZipArchive method contains.
public boolean contains(RelativePath name) {
RelativeDirectory dirname = name.dirname();
String basename = name.basename();
if (basename.length() == 0)
return false;
List<String> list = map.get(dirname);
return (list != null && list.contains(basename));
}
use of org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
the class ZipFileIndex method readIndex.
private boolean readIndex() {
if (triedToReadIndex || !usePreindexedCache) {
return false;
}
boolean ret = false;
synchronized (this) {
triedToReadIndex = true;
RandomAccessFile raf = null;
try {
File indexFileName = getIndexFile();
raf = new RandomAccessFile(indexFileName, "r");
long fileStamp = raf.readLong();
if (zipFile.lastModified() != fileStamp) {
ret = false;
} else {
directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>();
int numDirs = raf.readInt();
for (int nDirs = 0; nDirs < numDirs; nDirs++) {
int dirNameBytesLen = raf.readInt();
byte[] dirNameBytes = new byte[dirNameBytesLen];
raf.read(dirNameBytes);
RelativeDirectory dirNameStr = getRelativeDirectory(new String(dirNameBytes, "UTF-8"));
DirectoryEntry de = new DirectoryEntry(dirNameStr, this);
de.numEntries = raf.readInt();
de.writtenOffsetOffset = raf.readLong();
directories.put(dirNameStr, de);
}
ret = true;
zipFileLastModified = fileStamp;
}
} catch (Throwable t) {
// Do nothing
} finally {
if (raf != null) {
try {
raf.close();
} catch (Throwable tt) {
// Do nothing
}
}
}
if (ret == true) {
readFromIndex = true;
}
}
return ret;
}
Aggregations