Search in sources :

Example 6 with RelativeDirectory

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);
            }
        }
    }
}
Also used : RelativeDirectory(org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory) JavaFileObject(org.eclipse.ceylon.javax.tools.JavaFileObject) RelativeFile(org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeFile) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 7 with RelativeDirectory

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);
}
Also used : RelativeDirectory(org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory) RelativeFile(org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeFile) ZipEntry(java.util.zip.ZipEntry)

Example 8 with RelativeDirectory

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));
}
Also used : RelativeDirectory(org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory)

Example 9 with RelativeDirectory

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;
}
Also used : RelativeDirectory(org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory) RandomAccessFile(java.io.RandomAccessFile) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) RelativeFile(org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeFile)

Aggregations

RelativeDirectory (org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeDirectory)9 RelativeFile (org.eclipse.ceylon.langtools.tools.javac.file.RelativePath.RelativeFile)5 File (java.io.File)4 RandomAccessFile (java.io.RandomAccessFile)2 ZipFile (java.util.zip.ZipFile)2 JavaFileObject (org.eclipse.ceylon.javax.tools.JavaFileObject)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ZipEntry (java.util.zip.ZipEntry)1 ListBuffer (org.eclipse.ceylon.langtools.tools.javac.util.ListBuffer)1