| Author |
What exactly Does <setExecutable()> Do on a Windows Machine?
|
Kevin Simonson
Ranch Hand
Joined: Oct 22, 2011
Posts: 40
|
|
I wrote a Java program that takes two arguments, creates a file using as name the first argument, and simply writes the second argument to that file and closes the file. After all this it calls <setExecutable( false)>, which I thought would make the file non-executable. The code follows.
When I run this with "java OneLine Jqz.Txt Jqz.", it creates file "Jqz.Txt" just fine, and it has contents a single line that says "Jqz.", but when I type in "ls -l Jqz.Txt" I get "-rwx------+ 1 kvnsmnsn Domain Users 6 Feb 10 09:36 Jqz.Txt". Why is the executable bit still set?
I should note that my machine actually has a Windows 7 Operating System; I get the "ls" command from Cygwin, which lets me emulate a lot of Unix commands. In fact I can type in "chmod ugo-x Jqz.Txt" and that does succeed in turning the executable bit off. But why doesn't <setExecutable()> turn the executable bit off?
Kevin Simonson
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 2686
|
|
Did you check the return value from setExecutable ? As it says in the javadoc
If executable is false and the underlying file system does not implement an excute permission, then the operation will fail.
Windows does not have the concept of an executable permission for files.
|
Joanne
|
 |
Kevin Simonson
Ranch Hand
Joined: Oct 22, 2011
Posts: 40
|
|
Joanne Neal wrote:Did you check the return value from setExecutable ? As it says in the javadoc
If executable is false and the underlying file system does not implement an excute permission, then the operation will fail.
Windows does not have the concept of an executable permission for files.
I just checked the return value from <setExecutable()>, and it was <false>. I guess the underlying file system doesn't "implement an excute permission." Oh well.
Kevin Simonson
|
 |
 |
|
|
subject: What exactly Does <setExecutable()> Do on a Windows Machine?
|
|
|