ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Martin" <antu...@gmail.com>
Subject Re: Access source file from mapper
Date Mon, 11 Dec 2006 19:26:19 GMT
Hello,

On 12/11/06, Jan.Materne@rzf.fin-nrw.de <Jan.Materne@rzf.fin-nrw.de> wrote:
> >1. I miss the source folder. As an example task:
> ><copy todir="C:\A">
> ><fileset dir="C:\B" includes="*.JPG" />
> ><mapper... />
> ></copy>
> >Here, the variable "source" would be something matched by
> >*.JPG. It does not include the folder C:\B.
>
>
> mmmh ... that works for me:
>
> <project>
>     <pathconvert property="p">
>         <fileset id="fs" dir="." includes="**/*.jpg"/>
>         <scriptmapper id="mapper" language="javascript">
>             f = new java.io.File(source);
>             project.log(
>                 ((f.exists()) ? "+ " : "- ")
>                 + source
>             );
>         </scriptmapper>
>     </pathconvert>
> </project>
>

This works because of dir="." : the file name passed to the mapper
matches a file in a subdir of the current location.

>
> >2. There might be previous mappers that changed the filename.
> >
> >My question was more to know if there was anyway to access the
> >source File object *directly* from a mapper.
> >Something like
> >public File getSourceFile();
> >would be perfect ;)
>
> I dont think there is something like that. But you'll find it in the
> source code if there is one ;-)

I did not find anything :-(. I was just hoping there would be a trick somewhere.

>
> Think of composite mappers - what should arrive? Especially if the
> earlier mapper has assigned
> multiple targets for one source file? Especially if the result comes
> from a filtermapper?
>
>
> Jan
>

Well, in all those cases, the source file is always unique and its
content could be of some interest for mappers.
- compositemapper should forward the source File instance to its nested mappers.
- If multiple targets, we still have only one source file and that's
the one that's interesting to have
- filtermapper only change the file name, not the file content. So I
don't think there is anything specific there.

Oh well, I guess I'll just need to use a <for> loop, get the exif
atttributes of each file and copy file by file...

Thank you anyway.

Patrick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message