use of org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
the class SymbolArchive method addZipEntry.
@Override
void addZipEntry(ZipEntry entry) {
String name = entry.getName();
if (!name.startsWith(prefix.path)) {
return;
}
name = name.substring(prefix.path.length());
int i = name.lastIndexOf('/');
RelativeDirectory dirname = new RelativeDirectory(name.substring(0, i + 1));
String basename = name.substring(i + 1);
if (basename.length() == 0) {
return;
}
List<String> list = map.get(dirname);
if (list == null)
list = List.nil();
list = list.prepend(basename);
map.put(dirname, list);
}
use of org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
the class ZipArchive method addZipEntry.
void addZipEntry(ZipEntry entry) {
String name = entry.getName();
int i = name.lastIndexOf('/');
RelativeDirectory dirname = new RelativeDirectory(name.substring(0, i + 1));
String basename = name.substring(i + 1);
if (basename.length() == 0)
return;
List<String> list = map.get(dirname);
if (list == null)
list = List.nil();
list = list.prepend(basename);
map.put(dirname, list);
}
use of org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
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 org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
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 org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory in project ceylon by eclipse.
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