Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » General (non-technical) » Eclipse Foundation » Is "chmod +x ..." equiv. to IFileInfo.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, ...)?
Is "chmod +x ..." equiv. to IFileInfo.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, ...)? [message #34568] Wed, 10 May 2006 18:21 Go to next message
Nicolas Rouquette is currently offline Nicolas RouquetteFriend
Messages: 157
Registered: July 2009
Senior Member
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] Thu, 11 May 2006 02:13 Go to previous message
Eclipse Webmaster is currently offline Eclipse WebmasterFriend
Messages: 607343
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.
Previous Topic:Re: Get Selected Object in Eclipse - Help Please
Next Topic:The same Eclipse installation on Windows and Linux
Goto Forum:
  


Current Time: Thu Apr 25 12:31:16 GMT 2024

Powered by FUDForum. Page generated in 0.03562 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top