|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
Checking whether a file is executableHello,
Ant's <available> condition can check whether a file exists and is a regular file (with type="file"), but I have seen no condition that can tell me whether a given regular file is executable (sorry for the Unix speak - FWIW, a regular file is just that, a file - a directory is just another type of file). Java has .canExecute() which can tell whether a given File object is executable. Where should I start to look if I want to create, say, a <isexecutabe> condition? Or is there something existing that I just overlooked? I could use <exec> and work out the return value, but I'd be better off if I could fail earlier, finding that a given file is just not executable at all... -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
RE: Checking whether a file is executableI had a similar request in this email list. Here is a link:
http://www.nabble.com/zip-tar-and-file-permissions-td22315686.html It has some feedback on this subject. --- Shawn Castrianni -----Original Message----- From: Francis GALIEGUE [mailto:fge@...] Sent: Friday, October 23, 2009 3:01 PM To: Ant Users List Subject: Checking whether a file is executable Hello, Ant's <available> condition can check whether a file exists and is a regular file (with type="file"), but I have seen no condition that can tell me whether a given regular file is executable (sorry for the Unix speak - FWIW, a regular file is just that, a file - a directory is just another type of file). Java has .canExecute() which can tell whether a given File object is executable. Where should I start to look if I want to create, say, a <isexecutabe> condition? Or is there something existing that I just overlooked? I could use <exec> and work out the return value, but I'd be better off if I could fail earlier, finding that a given file is just not executable at all... -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... ---------------------------------------------------------------------- This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message. |
|
|
Re: Checking whether a file is executableOn Fri, Oct 23, 2009 at 22:57, Shawn Castrianni
<Shawn.Castrianni@...> wrote: > I had a similar request in this email list. Here is a link: > > http://www.nabble.com/zip-tar-and-file-permissions-td22315686.html > > It has some feedback on this subject. > Aiee... I didn't know that the .canExecute() method only appeared in Java 1.6 :( If ant aims to stick to 1.4, or even 1.5, I'm SOL, I guess... -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
RE: Checking whether a file is executableI run ANT with 1.6 all the time. Therefore, you could always write your own condition or task with ANT API just as long as you run your ANT builds with 1.6.
--- Shawn Castrianni -----Original Message----- From: Francis GALIEGUE [mailto:fge@...] Sent: Friday, October 23, 2009 4:44 PM To: Ant Users List Subject: Re: Checking whether a file is executable On Fri, Oct 23, 2009 at 22:57, Shawn Castrianni <Shawn.Castrianni@...> wrote: > I had a similar request in this email list. Here is a link: > > http://www.nabble.com/zip-tar-and-file-permissions-td22315686.html > > It has some feedback on this subject. > Aiee... I didn't know that the .canExecute() method only appeared in Java 1.6 :( If ant aims to stick to 1.4, or even 1.5, I'm SOL, I guess... -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... ---------------------------------------------------------------------- This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message. |
|
|
Re: Checking whether a file is executableOn Fri, Oct 23, 2009 at 23:50, Shawn Castrianni
<Shawn.Castrianni@...> wrote: > I run ANT with 1.6 all the time. Therefore, you could always write your own condition or task with ANT API just as long as you run your ANT builds with 1.6. > Which kind of leads back to my original question somewhat, even if this was far from being obvious in my first mail... By "Where should I start to look if I want to create, say, a <isexecutabe> condition", I meant where in the code should I start to look. I have thrown an eye to the source, but without success so far. Pointers appreciated ;) -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Checking whether a file is executablehttp://ant.apache.org/manual/tutorial-writing-tasks.html ;-)
2009/10/23 Francis GALIEGUE <fge@...> > On Fri, Oct 23, 2009 at 23:50, Shawn Castrianni > <Shawn.Castrianni@...> wrote: > > I run ANT with 1.6 all the time. Therefore, you could always write your > own condition or task with ANT API just as long as you run your ANT builds > with 1.6. > > > > Which kind of leads back to my original question somewhat, even if > this was far from being obvious in my first mail... By "Where should I > start to look if I want to create, say, a > <isexecutabe> condition", I meant where in the code should I start to > look. I have thrown an eye to the source, but without success so far. > Pointers appreciated ;) > > -- > > Francis Galiegue > ONE2TEAM > Ingénieur système > Mob : +33 (0) 683 877 875 > Tel : +33 (0) 178 945 552 > fge@... > 40 avenue Raymond Poincaré > 75116 Paris > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Checking whether a file is executableOn 2009-10-23, Francis GALIEGUE <fge@...> wrote:
> On Fri, Oct 23, 2009 at 23:50, Shawn Castrianni > <Shawn.Castrianni@...> wrote: >> I run ANT with 1.6 all the time. Therefore, you could always write your own condition or task with ANT API just as long as you run your ANT builds with 1.6. > Which kind of leads back to my original question somewhat, even if > this was far from being obvious in my first mail... By "Where should I > start to look if I want to create, say, a > <isexecutabe> condition", Apart from the general "this is how Ant maps XML to Java" documents you could look at the implementations of the existing conditions, most of them are in the org.apache.tools.ant.taskdefs.condition package. Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
RE: Checking whether a file is executableHere is example source code for a condition:
import java.io.File; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.condition.Condition; public class FileAgeCondition implements Condition { protected String _file = null; protected float _age = -999.25F; //In seconds protected boolean _olderThan = true; public boolean eval() throws BuildException { if((_file == null) || (_file.length() == 0)) throw new BuildException("file must be set"); if(_age == -999.25F) throw new BuildException("age must be set"); File file = new File(_file); if(!file.exists()) return(true); long now = System.currentTimeMillis(); long fileAge = file.lastModified(); float testAge = _age * 1000.0F; boolean retVal; if(_olderThan) retVal = (now - fileAge) > testAge; else retVal = (now - fileAge) < testAge; return(retVal); } public void setFile(String file) { _file = file; } public void setAge(float age) { _age = age; } } --- Shawn Castrianni -----Original Message----- From: Francis GALIEGUE [mailto:fge@...] Sent: Friday, October 23, 2009 4:54 PM To: Ant Users List Subject: Re: Checking whether a file is executable On Fri, Oct 23, 2009 at 23:50, Shawn Castrianni <Shawn.Castrianni@...> wrote: > I run ANT with 1.6 all the time. Therefore, you could always write your own condition or task with ANT API just as long as you run your ANT builds with 1.6. > Which kind of leads back to my original question somewhat, even if this was far from being obvious in my first mail... By "Where should I start to look if I want to create, say, a <isexecutabe> condition", I meant where in the code should I start to look. I have thrown an eye to the source, but without success so far. Pointers appreciated ;) -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... ---------------------------------------------------------------------- This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message. |
|
|
RE: Checking whether a file is executable-----Original Message----- From: Francis GALIEGUE [mailto:fge@...] Sent: Friday, October 23, 2009 10:01 PM To: Ant Users List Subject: Checking whether a file is executable /* Hello, Ant's <available> condition can check whether a file exists and is a regular file (with type="file"), but I have seen no condition that can tell me whether a given regular file is executable (sorry for the Unix speak - FWIW, a regular file is just that, a file - a directory is just another type of file). Java has .canExecute() which can tell whether a given File object is executable. Where should I start to look if I want to create, say, a <isexecutabe> condition? Or is there something existing that I just overlooked? I could use <exec> and work out the return value, but I'd be better off if I could fail earlier, finding that a given file is just not executable at all... */ another possibility would be to check, whether the file is binary, see = http://marc.info/?l=ant-user&m=118769231408319&w=2 Regards, Gilbert --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Checking whether a file is executableyou might also have a look at jna.dev.java.net as they have some trickery
that allows you to query is a file is executable 2009/10/27 Rebhan, Gilbert <Gilbert.Rebhan@...> > > > > > -----Original Message----- > From: Francis GALIEGUE [mailto:fge@...] > Sent: Friday, October 23, 2009 10:01 PM > To: Ant Users List > Subject: Checking whether a file is executable > > /* > Hello, > > Ant's <available> condition can check whether a file exists and is a > regular file (with type="file"), but I have seen no condition that can > tell me whether a given regular file is executable (sorry for the Unix > speak - FWIW, a regular file is just that, a file - a directory is > just another type of file). > > Java has .canExecute() which can tell whether a given File object is > executable. Where should I start to look if I want to create, say, a > <isexecutabe> condition? Or is there something existing that I just > overlooked? I could use <exec> and work out the return value, but I'd > be better off if I could fail earlier, finding that a given file is > just not executable at all... > */ > > another possibility would be to check, whether the file is binary, see = > http://marc.info/?l=ant-user&m=118769231408319&w=2 > > > > Regards, Gilbert > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
| Free embeddable forum powered by Nabble | Forum Help |