/** * Changes the given file's readonly status * * @param readonly - A boolean used to determine what status to set the file to * @param modelFile - The file in which the status should be altered */ public static void changeFileReadonlyStatus(boolean readonly, IFile modelFile) { ResourceAttributes resourceAttributes = modelFile.getResourceAttributes(); if (resourceAttributes != null) { resourceAttributes.setReadOnly(readonly); try { modelFile.setResourceAttributes(resourceAttributes); } catch (CoreException e) { CorePlugin.logError("Core Exception", e); } } }
/** * Write the passed resource to the current archive. * * @param resource org.eclipse.core.resources.IFile * @param destinationPath java.lang.String * @exception java.io.IOException * @exception org.eclipse.core.runtime.CoreException */ @Override public void write(IFile resource, String destinationPath) throws IOException, CoreException { if (!resolveLinks && resource.isLinked(IResource.DEPTH_INFINITE)) { return; } TarEntry newEntry = new TarEntry(destinationPath); if (resource.getLocalTimeStamp() != IResource.NULL_STAMP) { newEntry.setTime(resource.getLocalTimeStamp() / 1000); } ResourceAttributes attributes = resource.getResourceAttributes(); if (attributes != null && attributes.isExecutable()) { newEntry.setMode(newEntry.getMode() | 0111); } if (attributes != null && attributes.isReadOnly()) { newEntry.setMode(newEntry.getMode() & ~0222); } write(newEntry, resource); }
private static IFile resolveFile(final IFile file) { IFile result = file; if (file.getResourceAttributes().isSymbolicLink()) { try { final File f = new File(file.getLocation().toString()); final IFileInfo info = EFS.getFileSystem(EFS.SCHEME_FILE).fromLocalFile(f).fetchInfo(); final String target = info.getStringAttribute(EFS.ATTRIBUTE_LINK_TARGET); if (target != null) { // FIXME this is wrong in the general case // find the file in the externals! result = (IFile) file.getParent().findMember(target); if (result == null) { result = file; } } } catch (final Exception e) { ErlLogger.warn(e); } } return result; }