Is "chmod +x ..." equiv. to IFileInfo.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, ...)? [message #34568] |
Wed, 10 May 2006 14:21  |
Eclipse User |
|
|
|
What's the Eclipse way of doing
the unix equivalent of "chmod +x <file>"?
From my understanding of the Eclipse file system APIs,
I believed the following code should work.
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
Bundle bundle = ...; // a plugin bundle
String path = "/some-script.sh";
URL url = bundle.getEntry(path);
URI uri = URIUtil.toURI(url.getFile);
IFileStore store = EFS.getStore(uri);
IFileInfo info = store.fetchInfo();
if (!info.getAttribute(EFS.ATTRIBUTE_EXECUTABLE)) {
System.out.println(" -x => +x");
info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
store.putInfo(info, EFS.SET_ATTRIBUTES, null);
} else {
System.out.println(" +x is set!");
}
When I manually do chmod -x some-script.sh;
I can see the message: -x => +x
but the file doesn't get the x flag set.
When I manually do chmod +x some-script.sh;
I can see the message: +x is set!
So, the IFileInfo.getAttribute(...) part is OK;
however, it seems that
the IFileInfo.setAttribute + IFileStore.putInfo part is not OK.
I searched for references to these methods and I haven't found
evidence of anything in Eclipse that specifically uses the file system
API to do the equivalent of "chmod +x ...".
Any suggestions for alternative workarounds known to work as expected?
-- Nicolas.
|
|
|
Re: Is "chmod +x ..." equiv. to IFileInfo.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, ...)? [message #34602 is a reply to message #34568] |
Wed, 10 May 2006 22:13  |
Eclipse Webmaster Messages: 607353 Registered: July 2009 |
Senior Member |
|
|
Nicolas,
Welcome to the Eclipse community. Your question would likely be best
answered in the eclipse.newcomers group:
http://www.eclipse.org/newsportal/thread.php?group=eclipse.n ewcomer
D.
Nicolas Rouquette wrote:
> What's the Eclipse way of doing
> the unix equivalent of "chmod +x <file>"?
>
> From my understanding of the Eclipse file system APIs,
> I believed the following code should work.
>
> import org.eclipse.core.filesystem.EFS;
> import org.eclipse.core.filesystem.IFileInfo;
> import org.eclipse.core.filesystem.IFileStore;
>
> Bundle bundle = ...; // a plugin bundle
> String path = "/some-script.sh";
> URL url = bundle.getEntry(path);
> URI uri = URIUtil.toURI(url.getFile);
> IFileStore store = EFS.getStore(uri);
> IFileInfo info = store.fetchInfo();
> if (!info.getAttribute(EFS.ATTRIBUTE_EXECUTABLE)) {
> System.out.println(" -x => +x");
> info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
> store.putInfo(info, EFS.SET_ATTRIBUTES, null);
> } else {
> System.out.println(" +x is set!");
> }
>
> When I manually do chmod -x some-script.sh;
> I can see the message: -x => +x
> but the file doesn't get the x flag set.
>
> When I manually do chmod +x some-script.sh;
> I can see the message: +x is set!
>
> So, the IFileInfo.getAttribute(...) part is OK;
> however, it seems that
> the IFileInfo.setAttribute + IFileStore.putInfo part is not OK.
>
> I searched for references to these methods and I haven't found
> evidence of anything in Eclipse that specifically uses the file system
> API to do the equivalent of "chmod +x ...".
>
> Any suggestions for alternative workarounds known to work as expected?
>
> -- Nicolas.
|
|
|
Powered by
FUDForum. Page generated in 0.06384 seconds