use of org.netbeans.lib.cvsclient.file.ILocalFileReader 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;
}
Aggregations