use of com.sun.tools.javac.file.RelativePath.RelativeDirectory in project ceylon-compiler by ceylon.
the class ZipFileIndex method getRelativeDirectory.
private RelativeDirectory getRelativeDirectory(String path) {
RelativeDirectory rd;
SoftReference<RelativeDirectory> ref = relativeDirectoryCache.get(path);
if (ref != null) {
rd = ref.get();
if (rd != null)
return rd;
}
rd = new RelativeDirectory(path);
relativeDirectoryCache.put(path, new SoftReference<RelativeDirectory>(rd));
return rd;
}
use of com.sun.tools.javac.file.RelativePath.RelativeDirectory in project ceylon-compiler by ceylon.
the class ZipFileIndex method writeIndex.
private boolean writeIndex() {
boolean ret = false;
if (readFromIndex || !usePreindexedCache) {
return true;
}
if (!writeIndex) {
return true;
}
File indexFile = getIndexFile();
if (indexFile == null) {
return false;
}
RandomAccessFile raf = null;
long writtenSoFar = 0;
try {
raf = new RandomAccessFile(indexFile, "rw");
raf.writeLong(zipFileLastModified);
writtenSoFar += 8;
List<DirectoryEntry> directoriesToWrite = new ArrayList<DirectoryEntry>();
Map<RelativeDirectory, Long> offsets = new HashMap<RelativeDirectory, Long>();
raf.writeInt(directories.keySet().size());
writtenSoFar += 4;
for (RelativeDirectory dirName : directories.keySet()) {
DirectoryEntry dirEntry = directories.get(dirName);
directoriesToWrite.add(dirEntry);
// Write the dir name bytes
byte[] dirNameBytes = dirName.getPath().getBytes("UTF-8");
int dirNameBytesLen = dirNameBytes.length;
raf.writeInt(dirNameBytesLen);
writtenSoFar += 4;
raf.write(dirNameBytes);
writtenSoFar += dirNameBytesLen;
// Write the number of files in the dir
List<Entry> dirEntries = dirEntry.getEntriesAsCollection();
raf.writeInt(dirEntries.size());
writtenSoFar += 4;
offsets.put(dirName, new Long(writtenSoFar));
// Write the offset of the file's data in the dir
dirEntry.writtenOffsetOffset = 0L;
raf.writeLong(0L);
writtenSoFar += 8;
}
for (DirectoryEntry de : directoriesToWrite) {
// Fix up the offset in the directory table
long currFP = raf.getFilePointer();
long offsetOffset = offsets.get(de.dirName).longValue();
raf.seek(offsetOffset);
raf.writeLong(writtenSoFar);
raf.seek(currFP);
// Now write each of the files in the DirectoryEntry
List<Entry> list = de.getEntriesAsCollection();
for (Entry zfie : list) {
// Write the name bytes
byte[] zfieNameBytes = zfie.name.getBytes("UTF-8");
int zfieNameBytesLen = zfieNameBytes.length;
raf.writeInt(zfieNameBytesLen);
writtenSoFar += 4;
raf.write(zfieNameBytes);
writtenSoFar += zfieNameBytesLen;
// Write isDir
raf.writeByte(zfie.isDir ? (byte) 1 : (byte) 0);
writtenSoFar += 1;
// Write offset of bytes in the real Jar/Zip file
raf.writeInt(zfie.offset);
writtenSoFar += 4;
// Write size of the file in the real Jar/Zip file
raf.writeInt(zfie.size);
writtenSoFar += 4;
// Write compressed size of the file in the real Jar/Zip file
raf.writeInt(zfie.compressedSize);
writtenSoFar += 4;
// Write java time stamp of the file in the real Jar/Zip file
raf.writeLong(zfie.getLastModified());
writtenSoFar += 8;
}
}
} catch (Throwable t) {
// Do nothing
} finally {
try {
if (raf != null) {
raf.close();
}
} catch (IOException ioe) {
// Do nothing
}
}
return ret;
}
use of com.sun.tools.javac.file.RelativePath.RelativeDirectory in project ceylon-compiler by ceylon.
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 com.sun.tools.javac.file.RelativePath.RelativeDirectory in project ceylon-compiler by ceylon.
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 com.sun.tools.javac.file.RelativePath.RelativeDirectory in project ceylon-compiler by ceylon.
the class JavacFileManager method list.
public Iterable<JavaFileObject> list(Location location, String packageName, Set<JavaFileObject.Kind> kinds, boolean recurse) throws IOException {
// validatePackageName(packageName);
nullCheck(packageName);
nullCheck(kinds);
Iterable<? extends File> path = getLocation(location);
if (path == null)
return List.nil();
RelativeDirectory subdirectory = RelativeDirectory.forPackage(packageName);
ListBuffer<JavaFileObject> results = new ListBuffer<JavaFileObject>();
for (File directory : path) listContainer(directory, subdirectory, kinds, recurse, results);
return results.toList();
}
Aggregations