Search in sources :

Example 1 with IAdminReader

use of org.netbeans.lib.cvsclient.admin.IAdminReader in project intellij-community by JetBrains.

the class DirectoryPruner method pruneEmptyDirectory.

// Utils ==================================================================
private boolean pruneEmptyDirectory(DirectoryObject directoryObject) throws IOException {
    final ILocalFileReader localFileReader = clientEnvironment.getLocalFileReader();
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    final IAdminWriter adminWriter = clientEnvironment.getAdminWriter();
    final IAdminReader adminReader = clientEnvironment.getAdminReader();
    directoriesToScan.remove(directoryObject);
    if (!localFileReader.exists(directoryObject, cvsFileSystem)) {
        return true;
    }
    final List fileNames = new ArrayList();
    final List directoryNames = new ArrayList();
    localFileReader.listFilesAndDirectories(directoryObject, fileNames, directoryNames, cvsFileSystem);
    if (fileNames.size() > 0) {
        return false;
    }
    if (hasFileEntry(directoryObject, cvsFileSystem, adminReader)) {
        return false;
    }
    for (Iterator it = directoryNames.iterator(); it.hasNext(); ) {
        final String directoryName = (String) it.next();
        if (!pruneEmptyDirectory(DirectoryObject.createInstance(directoryObject, directoryName))) {
            return false;
        }
    }
    if (adminReader.hasCvsDirectory(directoryObject, cvsFileSystem)) {
        try {
            adminWriter.removeEntryForFile(directoryObject, cvsFileSystem);
        } catch (FileNotFoundException ex) {
            // ignore
            return false;
        }
        adminWriter.pruneDirectory(directoryObject, cvsFileSystem);
        return true;
    }
    return false;
}
Also used : ILocalFileReader(org.netbeans.lib.cvsclient.file.ILocalFileReader) ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) FileNotFoundException(java.io.FileNotFoundException) IAdminReader(org.netbeans.lib.cvsclient.admin.IAdminReader) IAdminWriter(org.netbeans.lib.cvsclient.admin.IAdminWriter) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 IAdminReader (org.netbeans.lib.cvsclient.admin.IAdminReader)1 IAdminWriter (org.netbeans.lib.cvsclient.admin.IAdminWriter)1 ICvsFileSystem (org.netbeans.lib.cvsclient.file.ICvsFileSystem)1 ILocalFileReader (org.netbeans.lib.cvsclient.file.ILocalFileReader)1