Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / December 2003

Tip: Looking for answers? Try searching our database.

Copy task of Ant sets wrong permissions under cygwin

Thread view: 
Ronald Fischer - 26 Nov 2003 13:39 GMT
When executing the Ant task

  <copy file="source" tofile="target" />

with Ant running under cygwin, and source has permission
0500, the resulting file has permission 0000!!!!!
Stefan Bodewig - 27 Nov 2003 09:11 GMT
> When executing the Ant task
>
>    <copy file="source" tofile="target" />
>
> with Ant running under cygwin, and source has permission
> 0500, the resulting file has permission 0000!!!!!

Don't blame it on Ant, blame it on Java.

There is no way to access the permissions of a file from within Java (without
falling back to native methods, that is) and no way to change them.

Ant will create plain files while copying and they will get your default
permissions.  If they are not correct, use <apply> (or <attrib> in 1.6beta)
to change them afterwards.

Stefan
Ronald Fischer - 28 Nov 2003 10:07 GMT
> > When executing the Ant task
> >
[quoted text clipped - 7 lines]
> Ant will create plain files while copying and they will get your default
> permissions.  

If it only would!!! My umask displays at

 0022

So the resulting files should then have permissions 0640!

> If they are not correct, use <apply>

OK ... this means I should first write a BAT-file, say CHGPROT.BAT,
containing something like

   sh -c chmod 0640 %1

and then use it like this:

  <apply executable="CHGPROT.BAT" os="???" >
     My fileset goes here...
  </apply>

But what do I put for the question marks to indicate that the task
should be executed only under cygwin?

Ronald
Stefan Bodewig - 01 Dec 2003 09:33 GMT
> > Ant will create plain files while copying and they will get your default
> > permissions.  
[quoted text clipped - 4 lines]
>
> So the resulting files should then have permissions 0640!

Your Java VM doesn't know anything about Cygwin - so neither does Ant.
The permissions you see are those that any File created by Java will get.
Sorry.

> > If they are not correct, use <apply>
>
[quoted text clipped - 4 lines]
> But what do I put for the question marks to indicate that the task
> should be executed only under cygwin?

Cygwin is not an OS.

Instead of using <apply>'s os attribute, you better check for some Cygwin
indicator (like the presence of a cygwin.user.home property that gets set
by Ant's wrapper script) with <condition> and put the apply into a <target>
that's guarded by if/unless attributes.

Stefan
Signature

http://stefanbodewig.blogger.de/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.