Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changeset 3347

Show
Ignore:
Timestamp:
03/13/08 13:25:14 (9 months ago)
Author:
lmartin92
Message:

Updated FtpFolder?; now all but one class is finished. Will finish soon. Then testing time :-)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/lmartin/ftp/tango/io/vfs/FtpFolder.d

    r3346 r3347  
    6565        _ftp = new FTPConnection(_toString, _username, _password, _port); 
    6666        writable(); 
     67    } 
     68 
     69    package this(VfsFolder fol) 
     70    { 
     71        this(cast(FtpFolder)fol); 
    6772    } 
    6873     
     
    524529    package this(FtpFolder fol, char[] path) 
    525530    { 
    526         _name = path[locatePrior(path, '/', cast(int)path.length) > locatePrior(path, '\\', path.length) && locatePrior(path, '/', path.length) != path.length ? locatePrior(path, '/', path.length) : locatePrior(path, '\\', path.length) .. path.length]; 
    527         _toString = path; 
     531        _name = path[locatePrior(path, '/', cast(int)path.length) > locatePrior(path, '\\', path.length) && locatePrior(path, '/', path.length) != path.length ? locatePrior(path, '/', path.length) : locatePrior(path, '\\', path.length) .. $]; 
     532        _toString = fol.toString ~ path; 
    528533        _folder = new FtpFolder(fol); 
    529534        _filt.name = _name; 
     
    713718class FtpFiles : VfsFiles 
    714719{ 
     720    FtpFile[] _files; 
     721    FtpFolder[] _folders; 
    715722    /*********************************************************************** 
    716723 
     
    721728    package this(FtpFolders folders) 
    722729    { 
     730        foreach(folder; folders) 
     731        { 
     732            _folders ~= new FtpFolder(folder); 
     733        } 
     734        populateFiles(); 
     735    } 
     736 
     737    private void populateFiles() 
     738    { 
     739        foreach(FtpFolder folder; _folders) 
     740        { 
     741            foreach(VfsFolder fol; folder) 
     742            { 
     743                FtpFolder cfol = cast(FtpFolder) fol; 
     744                FtpFileInfo[] fis = cfol._ftp.ls(); 
     745                foreach(FtpFileInfo fi; fis) 
     746                { 
     747                    if(fi.type == FtpFileType.file || fi.type == FtpFileType.other || fi.type == FtpFileType.unknown) 
     748                    { 
     749                        _files ~= new FtpFile(cfol, fi.name); 
     750                    } 
     751                } 
     752            } 
     753        } 
    723754    } 
    724755 
    725756    package this(FtpFile[] files) 
    726757    { 
     758        _files = files; 
    727759    } 
    728760 
     
    739771    int opApply (int delegate(inout VfsFile) dg) 
    740772    { 
    741         return 0; 
     773        int result; 
     774         
     775        foreach(file; _files) 
     776        { 
     777            VfsFile x = file; 
     778            if ((result = dg(x)) != 0) 
     779                    break; 
     780        } 
     781 
     782        return result; 
    742783    } 
    743784 
     
    750791    uint files() 
    751792    { 
    752         return 0
     793        return _files.length
    753794    } 
    754795 
     
    761802    ulong bytes() 
    762803    { 
    763         return 0; 
     804        ulong to_return; 
     805        foreach(file; this) 
     806        { 
     807            to_return += file.size; 
     808        } 
     809        return to_return; 
    764810    } 
    765811}