Search in sources :

Example 1 with DirectoryObject

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

the class CheckoutCommand method processExistingModules.

private void processExistingModules(ExpandedModules expandedModules, IClientEnvironment clientEnvironment) {
    final ICvsFileSystem cvsFileSystem = clientEnvironment.getCvsFileSystem();
    for (final String moduleName : expandedModules.getModules()) {
        if (moduleName.equals(".")) {
            addFileObject(DirectoryObject.getRoot());
            break;
        }
        final File moduleFile = cvsFileSystem.getLocalFileSystem().getFile(moduleName);
        final AbstractFileObject abstractFileObject;
        final DirectoryObject directoryObject;
        if (moduleFile.isFile()) {
            abstractFileObject = cvsFileSystem.getLocalFileSystem().getFileObject(moduleFile);
            directoryObject = abstractFileObject.getParent();
        } else {
            directoryObject = cvsFileSystem.getLocalFileSystem().getDirectoryObject(moduleFile);
            abstractFileObject = directoryObject;
        }
        if (clientEnvironment.getAdminReader().hasCvsDirectory(directoryObject, cvsFileSystem)) {
            addFileObject(abstractFileObject);
        }
    }
}
Also used : ICvsFileSystem(org.netbeans.lib.cvsclient.file.ICvsFileSystem) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) File(java.io.File) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 2 with DirectoryObject

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

the class ImportCommand method addFileRequests.

/**
	 * Adds recursively all request for files and directories in the specified
	 * directory to the specified requestList.
	 */
private void addFileRequests(File directory, Requests requests, IRequestProcessor requestProcessor, IClientEnvironment clientEnvironment) throws IOException {
    final DirectoryObject directoryObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(directory);
    final String relativePath = directoryObject.toUnixPath();
    String repository = getRepositoryRoot(clientEnvironment);
    if (!relativePath.equals(".")) {
        repository += '/' + relativePath;
    }
    requests.addRequest(new DirectoryRequest(relativePath, repository));
    final File[] files = directory.listFiles();
    if (files == null) {
        return;
    }
    final List<File> subdirectories = new ArrayList();
    for (final File file : files) {
        if (file.isDirectory()) {
            final DirectoryObject subDirObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(file);
            if (clientEnvironment.getIgnoreFileFilter().shouldBeIgnored(subDirObject, clientEnvironment.getCvsFileSystem())) {
                continue;
            }
            subdirectories.add(file);
        } else {
            final FileObject fileObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getFileObject(file);
            if (clientEnvironment.getIgnoreFileFilter().shouldBeIgnored(fileObject, clientEnvironment.getCvsFileSystem())) {
                continue;
            }
            final KeywordSubstitution keywordSubstMode = getKeywordSubstMode(file.getName());
            final boolean writable = clientEnvironment.getLocalFileReader().isWritable(fileObject, clientEnvironment.getCvsFileSystem());
            if (keywordSubstMode != null) {
                requests.addKoptRequest(keywordSubstMode);
            }
            requests.addModifiedRequest(fileObject, keywordSubstMode == KeywordSubstitution.BINARY, writable);
        }
    }
    for (final File subdirectory : subdirectories) {
        addFileRequests(subdirectory, requests, requestProcessor, clientEnvironment);
    }
}
Also used : FileObject(org.netbeans.lib.cvsclient.file.FileObject) DirectoryRequest(org.netbeans.lib.cvsclient.request.DirectoryRequest) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject) File(java.io.File)

Example 3 with DirectoryObject

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

the class FileSystemScanner method scan.

// Actions ================================================================
public void scan(List<AbstractFileObject> abstractFileObjects, CvsFiles cvsFiles) throws IOException {
    cvsFiles.clear();
    if (abstractFileObjects.size() == 0) {
        // if no arguments have been specified, then specify the
        // local directory - the "top level" for this command
        scanDirectories(DirectoryObject.getRoot(), cvsFiles);
    } else {
        for (final AbstractFileObject fileOrDirectory : abstractFileObjects) {
            if (fileOrDirectory instanceof DirectoryObject) {
                final DirectoryObject directoryObject = (DirectoryObject) fileOrDirectory;
                scanDirectories(directoryObject, cvsFiles);
            } else if (fileOrDirectory instanceof FileObject) {
                final FileObject fileObject = (FileObject) fileOrDirectory;
                addRequestsForFile(fileObject, cvsFiles);
            }
        }
    }
}
Also used : AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) FileObject(org.netbeans.lib.cvsclient.file.FileObject) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 4 with DirectoryObject

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

the class LocalPathIndifferentOperationHelper method createFileObjects.

private AbstractFileObject[] createFileObjects() {
    ArrayList<AbstractFileObject> result = new ArrayList<>();
    Collection<File> parents = collectAllParents();
    Map<File, DirectoryObject> parentsMap = new HashMap<>();
    for (final File file : parents) {
        String relativeFileName = file.getPath().replace(File.separatorChar, '/');
        if (!StringUtil.startsWithChar(relativeFileName, '/'))
            relativeFileName = "/" + relativeFileName;
        parentsMap.put(file, DirectoryObject.createInstance(relativeFileName));
    }
    for (final File file : myFileToEntryMap.keySet()) {
        result.add(FileObject.createInstance(parentsMap.get(file.getParentFile()), "/" + file.getName()));
    }
    return result.toArray(new AbstractFileObject[result.size()]);
}
Also used : HashMap(com.intellij.util.containers.HashMap) AbstractFileObject(org.netbeans.lib.cvsclient.file.AbstractFileObject) File(java.io.File) DirectoryObject(org.netbeans.lib.cvsclient.file.DirectoryObject)

Example 5 with DirectoryObject

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

the class CreateFileObjects method createAbstractFileObject.

private AbstractFileObject createAbstractFileObject(File parent, File file, boolean isDirectory) {
    myCreatedFiles.add(file);
    String relativeFileName = "/" + file.getName();
    if (parent == null) {
        return isDirectory ? DirectoryObject.createInstance(relativeFileName) : FileObject.createInstance(relativeFileName);
    } else {
        DirectoryObject parentObject = getDirectoryObjectFor(parent);
        return isDirectory ? DirectoryObject.createInstance(parentObject, relativeFileName) : FileObject.createInstance(parentObject, relativeFileName);
    }
}
Also used : 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