Java Code Examples for org.eclipse.core.filesystem.provider.FileInfo#setDirectory()

The following examples show how to use org.eclipse.core.filesystem.provider.FileInfo#setDirectory() . 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: ServletFileStoreHandler.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 2
Source File: SftpFileStore.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 3
Source File: HistoryFileStore.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}