org.eclipse.core.filesystem.provider.FileInfo Java Examples
The following examples show how to use
org.eclipse.core.filesystem.provider.FileInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileHandlerV1.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private void handlePutMetadata(BufferedReader reader, String boundary, IFileStore file) throws IOException, CoreException, JSONException { StringBuffer buf = new StringBuffer(); String line; while ((line = reader.readLine()) != null && !line.equals(boundary)) buf.append(line); // merge with existing metadata FileInfo info = (FileInfo) file.fetchInfo(EFS.NONE, null); ServletFileStoreHandler.copyJSONToFileInfo(new JSONObject(buf.toString()), info); file.putInfo(info, EFS.SET_ATTRIBUTES, null); }
Example #2
Source File: ServletFileStoreHandler.java From orion.server with Eclipse Public License 1.0 | 5 votes |
/** * Copies any defined fields in the provided JSON object into the destination file info. * @param source The JSON object to copy fields from * @param destination The file info to copy fields to */ public static void copyJSONToFileInfo(JSONObject source, FileInfo destination) { destination.setName(source.optString(ProtocolConstants.KEY_NAME, destination.getName())); destination.setLastModified(source.optLong(ProtocolConstants.KEY_LAST_MODIFIED, destination.getLastModified())); destination.setDirectory(source.optBoolean(ProtocolConstants.KEY_DIRECTORY, destination.isDirectory())); JSONObject attributes = source.optJSONObject(ProtocolConstants.KEY_ATTRIBUTES); if (attributes != null) { for (int i = 0; i < ATTRIBUTE_KEYS.length; i++) { //undefined means the client does not want to change the value, so can't interpret as false if (!attributes.isNull(ATTRIBUTE_KEYS[i])) destination.setAttribute(ATTRIBUTE_BITS[i], attributes.optBoolean(ATTRIBUTE_KEYS[i])); } } }
Example #3
Source File: SftpFileStore.java From orion.server with Eclipse Public License 1.0 | 5 votes |
/** * Converts a jsch attributes object to an EFS file info. */ private static FileInfo attrsToInfo(String fileName, SftpATTRS stat) { FileInfo info = new FileInfo(fileName); info.setExists(true); info.setDirectory(stat.isDir()); info.setLength(stat.getSize()); info.setLastModified(((long) stat.getMTime()) * 1000); return info; }
Example #4
Source File: HistoryFileStore.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { FileInfo fileInfo = new FileInfo(getName()); fileInfo.setDirectory(false); fileInfo.setLastModified(fileState.getModificationTime()); fileInfo.setExists(true); fileInfo.setAttribute(EFS.ATTRIBUTE_READ_ONLY, true); return fileInfo; }
Example #5
Source File: FileTree.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override public IFileInfo getFileInfo(IFileStore store) { IFileInfo result = infoMap.get(store); if (result != null) { return result; } return new FileInfo(store.getName()); }
Example #6
Source File: WorkspaceFile.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@Override public IFileInfo fetchInfo(int options, IProgressMonitor monitor) throws CoreException { ensureLocalFileStore(); if (localFileStore != null) { FileInfo fileInfo = (FileInfo) localFileStore.fetchInfo(options, monitor); if (path.isRoot()) { fileInfo.setName(path.toPortableString()); } return fileInfo; } FileInfo info = new FileInfo(path.lastSegment()); info.setExists(false); return info; }
Example #7
Source File: ServletFileStoreHandler.java From orion.server with Eclipse Public License 1.0 | 4 votes |
public static IFileInfo fromJSON(JSONObject object) { FileInfo info = (FileInfo) EFS.createFileInfo(); copyJSONToFileInfo(object, info); return info; }
Example #8
Source File: EFSUtils.java From APICloud-Studio with GNU General Public License v3.0 | 3 votes |
/** * Sets the modification time of the client file * * @param serverFile * @param clientFile * @throws CoreException */ public static void setModificationTime(long modifiedTime, IFileStore destFile) throws CoreException { IFileInfo fi = new FileInfo(); fi.setLastModified(modifiedTime); destFile.putInfo(fi, EFS.SET_LAST_MODIFIED, null); }