Search in sources :

Example 6 with DirectoryObject

use of org.netbeans.lib.cvsclient.file.DirectoryObject in project intellij-community by JetBrains.

the class DirectoryPruner method pruneEmptyDirectories.

// Actions ================================================================
/**
	 * Remove any directories that don't contain any files
	 */
public final void pruneEmptyDirectories() throws IOException {
    while (directoriesToScan.size() > 0) {
        final DirectoryObject directoryObject = (DirectoryObject) directoriesToScan.remove(0);
        pruneEmptyDirectory(directoryObject);
    }
}
Also used : DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 7 with DirectoryObject

use of org.netbeans.lib.cvsclient.file.DirectoryObject in project intellij-community by JetBrains.

the class FileSystemScanner method scanDirectory.

private List<DirectoryObject> scanDirectory(DirectoryObject directoryObject, CvsFiles cvsFiles) throws IOException {
    if (!clientEnvironment.getLocalFileReader().exists(directoryObject, clientEnvironment.getCvsFileSystem())) {
        return Collections.emptyList();
    }
    cvsFiles.add(CvsFile.createCvsDirectory(directoryObject));
    final Set<String> subDirectoryNames = new HashSet<>();
    final LocalFiles localFiles = new LocalFiles(directoryObject, clientEnvironment);
    // get all the entries we know about, and process them
    final Collection<Entry> entries = clientEnvironment.getAdminReader().getEntries(directoryObject, clientEnvironment.getCvsFileSystem());
    for (final Entry entry : entries) {
        if (entry.isDirectory()) {
            subDirectoryNames.add(entry.getFileName());
        } else {
            final FileObject fileObject = FileObject.createInstance(directoryObject, entry.getFileName());
            final boolean fileExists = clientEnvironment.getLocalFileReader().exists(fileObject, clientEnvironment.getCvsFileSystem());
            cvsFiles.add(CvsFile.createCvsFileForEntry(fileObject, entry, fileExists));
            localFiles.removeFile(entry.getFileName());
        }
    }
    for (final String fileName : localFiles.getFileNames()) {
        cvsFiles.add(CvsFile.createCvsFileForExistingFile(FileObject.createInstance(directoryObject, fileName)));
    }
    final List<DirectoryObject> subDirectories = new ArrayList<>(subDirectoryNames.size());
    for (final String directoryName : subDirectoryNames) {
        subDirectories.add(DirectoryObject.createInstance(directoryObject, directoryName));
    }
    return subDirectories;
}
Also used : Entry(org.netbeans.lib.cvsclient.admin.Entry) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) FileObject(org.netbeans.lib.cvsclient.file.FileObject) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 8 with DirectoryObject

use of org.netbeans.lib.cvsclient.file.DirectoryObject in project intellij-community by JetBrains.

the class FileSystemScanner method scanDirectories.

// Utils ==================================================================
private void scanDirectories(DirectoryObject rootDirectoryObject, CvsFiles cvsFiles) throws IOException {
    final List<DirectoryObject> directories = new LinkedList<>();
    directories.add(rootDirectoryObject);
    while (directories.size() > 0) {
        final DirectoryObject directoryObject = directories.remove(0);
        final List<DirectoryObject> subDirectories = scanDirectory(directoryObject, cvsFiles);
        if (recursive) {
            directories.addAll(subDirectories);
        }
    }
}
Also used : DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 9 with DirectoryObject

use of org.netbeans.lib.cvsclient.file.DirectoryObject in project intellij-community by JetBrains.

the class AddCommand method addDirectoryRequestsUpToLocalDirectory.

private DirectoryObject addDirectoryRequestsUpToLocalDirectory(DirectoryObject directoryObject, Requests requests, IRequestProcessor requestProcessor, IClientEnvironment clientEnvironment) {
    final DirectoryObject parentDirectoryObject = directoryObject.getParent();
    if (parentDirectoryObject == null) {
        return null;
    }
    DirectoryObject parentDirectoryUnderCvsControl;
    if (clientEnvironment.getAdminReader().hasCvsDirectory(parentDirectoryObject, clientEnvironment.getCvsFileSystem())) {
        parentDirectoryUnderCvsControl = parentDirectoryObject;
        requests.addDirectoryRequest(DirectoryObject.getRoot());
        addDirectoryRequest(parentDirectoryUnderCvsControl, requests);
    } else {
        parentDirectoryUnderCvsControl = addDirectoryRequestsUpToLocalDirectory(parentDirectoryObject, requests, requestProcessor, clientEnvironment);
        if (parentDirectoryUnderCvsControl == null) {
            parentDirectoryUnderCvsControl = parentDirectoryObject;
        }
    }
    addDirectoryRequest(directoryObject, requests);
    return parentDirectoryObject;
}
Also used : DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 10 with DirectoryObject

use of org.netbeans.lib.cvsclient.file.DirectoryObject in project intellij-community by JetBrains.

the class AddCommand method addRequestsForFile.

private void addRequestsForFile(FileObject fileObject, Requests requests, IClientEnvironment clientEnvironment) throws IOException {
    final DirectoryObject parentDirectory = fileObject.getParent();
    addDirectoryRequest(parentDirectory, requests);
    addStickyRequest(parentDirectory, requests, clientEnvironment.getCvsFileSystem(), clientEnvironment);
    final Entry entry = clientEnvironment.getAdminReader().getEntry(fileObject, clientEnvironment.getCvsFileSystem());
    if (entry != null) {
        requests.addEntryRequest(entry);
    } else {
        requests.addIsModifiedRequest(fileObject);
    }
}
Also used : Entry(org.netbeans.lib.cvsclient.admin.Entry) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Aggregations

DirectoryObject (org.netbeans.lib.cvsclient.file.DirectoryObject)12 AbstractFileObject (org.netbeans.lib.cvsclient.file.AbstractFileObject)5 File (java.io.File)4 FileObject (org.netbeans.lib.cvsclient.file.FileObject)3 Entry (org.netbeans.lib.cvsclient.admin.Entry)2 ICvsFileSystem (org.netbeans.lib.cvsclient.file.ICvsFileSystem)2 HashMap (com.intellij.util.containers.HashMap)1 Iterator (java.util.Iterator)1 DirectoryRequest (org.netbeans.lib.cvsclient.request.DirectoryRequest)1