Search in sources :

Example 6 with IFileInfo

use of org.eclipse.core.filesystem.IFileInfo in project che by eclipse.

the class FileStoreFileBuffer method create.

public void create(IFileStore fileStore, IProgressMonitor monitor) throws CoreException {
    IFileInfo info = fileStore.fetchInfo();
    fFileStore = fileStore;
    if (fLocation == null)
        fLocation = URIUtil.toPath(fileStore.toURI());
    initializeFileBufferContent(monitor);
    if (info.exists())
        fSynchronizationStamp = info.getLastModified();
    addFileBufferContentListeners();
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo)

Example 7 with IFileInfo

use of org.eclipse.core.filesystem.IFileInfo in project che by eclipse.

the class FileStore method copy.

/**
	 * The default implementation of {@link IFileStore#copy(IFileStore, int, IProgressMonitor)}.
	 * This implementation performs a copy by using other primitive methods. 
	 * Subclasses may override this method.
	 */
public void copy(IFileStore destination, int options, IProgressMonitor monitor) throws CoreException {
    monitor = Policy.monitorFor(monitor);
    Policy.checkCanceled(monitor);
    final IFileInfo sourceInfo = fetchInfo(EFS.NONE, null);
    if (sourceInfo.isDirectory())
        copyDirectory(sourceInfo, destination, options, monitor);
    else
        copyFile(sourceInfo, destination, options, monitor);
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo)

Example 8 with IFileInfo

use of org.eclipse.core.filesystem.IFileInfo in project che by eclipse.

the class LocalFile method fetchInfo.

public IFileInfo fetchInfo(int options, IProgressMonitor monitor) {
    //		if (LocalFileNativesManager.isUsingNatives()) {
    //			FileInfo info = LocalFileNativesManager.fetchFileInfo(filePath);
    //			//natives don't set the file name on all platforms
    //			if (info.getName().length() == 0) {
    //				String name = file.getName();
    //				//Bug 294429: make sure that substring baggage is removed
    //				info.setName(new String(name.toCharArray()));
    //			}
    //			return info;
    //		}
    //in-lined non-native implementation
    FileInfo info = new FileInfo(file.getName());
    final long lastModified = file.lastModified();
    if (lastModified <= 0) {
        //if the file doesn't exist, all other attributes should be default values
        info.setExists(false);
        return info;
    }
    info.setLastModified(lastModified);
    info.setExists(true);
    info.setLength(file.length());
    info.setDirectory(file.isDirectory());
    info.setAttribute(EFS.ATTRIBUTE_READ_ONLY, file.exists() && !file.canWrite());
    info.setAttribute(EFS.ATTRIBUTE_HIDDEN, file.isHidden());
    return info;
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) FileInfo(org.eclipse.core.filesystem.provider.FileInfo)

Example 9 with IFileInfo

use of org.eclipse.core.filesystem.IFileInfo in project bndtools by bndtools.

the class CreateFileChange method isValid.

@Override
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException {
    RefactoringStatus result = new RefactoringStatus();
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    URI location = file.getLocationURI();
    if (location == null) {
        result.addFatalError(String.format("The location for file %s is unknown", path));
        return result;
    }
    IFileInfo jFile = EFS.getStore(location).fetchInfo();
    if (jFile.exists()) {
        result.addFatalError(String.format("File %s already exists", path));
        return result;
    }
    return result;
}
Also used : IFileInfo(org.eclipse.core.filesystem.IFileInfo) IFile(org.eclipse.core.resources.IFile) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) URI(java.net.URI)

Aggregations

IFileInfo (org.eclipse.core.filesystem.IFileInfo)9 IFileStore (org.eclipse.core.filesystem.IFileStore)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 OutputStream (java.io.OutputStream)1 SequenceInputStream (java.io.SequenceInputStream)1 URI (java.net.URI)1 ByteBuffer (java.nio.ByteBuffer)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 Charset (java.nio.charset.Charset)1 CharsetEncoder (java.nio.charset.CharsetEncoder)1 IllegalCharsetNameException (java.nio.charset.IllegalCharsetNameException)1 UnmappableCharacterException (java.nio.charset.UnmappableCharacterException)1 UnsupportedCharsetException (java.nio.charset.UnsupportedCharsetException)1 FileInfo (org.eclipse.core.filesystem.provider.FileInfo)1