ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kev Jackson <kevin.jack...@it.fts-vn.com>
Subject Re: Scp is this possible?
Date Wed, 10 May 2006 07:39:44 GMT
Atsuhiko Yamanaka wrote:

> Hi,
>
> 2006/5/10, Kev Jackson <kevin.jackson@it.fts-vn.com>:
>
>> In the SFTP code, there's mention of selectors not supported on remote
>> filesystems.  Why is taht?  The SFTPDirectoryScanner inherits from the
>> normal DirectoyScanner (which does support selectors), is there a
>> problem with the SFTP protocol that will not allow selectors to work?
>
>
> That logic comes from ftp task, but I guess that DateSelector expects 
> only
> java.io.File instances, but remote files are not  java.io.File.

Would it be possible to alter DateSelector to use resources instead and 
see if that works?

> Anyway, after quick and ugly hack, I could get files with date selector.
>
At least you got that far, to be honest I've not managed to look through 
all the code and determine what I would need to do to implement any of 
the selectors

> In that hack, I get an instance of DateSelector and invoke its
> 'isSelected' method
> whith dummy java.io.File instance whose 'lastModifiedTime' is setted
> as timestam of
> remote file.  It is too ugly to post here, so I'll wait for reponses
> from Ant experts.

Currently I'm hacking around with building a list of include patterns 
based on filenames (each of the log files will have a filename 
corresponding to the date pattern YYYY-MM-DD) - this is so brittle it's 
untrue, so I'd be happier to use the 'hacked up' code you've put 
together for my use case - I doubt anyone would ever need to do this 
again, so I'm not bothered about how messy the code is in the jar files 
(I'm treating Ant as a simple lib), and I doubt the rest of the ant team 
would want it to be included in the distribution

...horrible kludgy code to prove the hoops I'm having to jump through

       ArrayList includes = new ArrayList();
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD");
            Date now = new Date();
            now = sdf.parse((sdf.format(now)));
            if (null != from && null == to) {
                Date f = sdf.parse(from);
                System.out.println("Attempting to select files after : 
"+from);
                //after chosen date
                //ds.setDatetime(from); <- elegant using date selector
                //ds.setWhen(TimeComparison.AFTER);
                //fs.addDate(ds);
                Calendar c = Calendar.getInstance(); <- nasty using 
clandar etc
                //loop around calendar adding one to each day
                //until calendar == today
                for (c.setTime(f); c.getTime().equals(now); 
c.add(Calendar.DAY_OF_MONTH, 1)) {
                    includes.add("*"+sdf.format(c.getTime())+"*");
                    System.out.println("*"+sdf.format(c.getTime())+"*");
                }
           .... code elided
        } catch (ParseException e) {
            //do nothing
        }
        String[] includePatterns = new String[includes.size()];
        for(int i = 0, size = includes.size(); i<size; i++) {
            includePatterns[i] = (String)includes.get(i);
        }
        fs.appendIncludes(includePatterns);
        return fs;

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


Mime
View raw message