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

Changeset 3377

Show
Ignore:
Timestamp:
03/17/08 21:19:41 (9 months ago)
Author:
lmartin92
Message:

Updated to get the final Folder part of FtpFolder?.d implemented. A bit of FtpFile? is implemented. All constructors minus one are implemented. Need to finish FtpFiles? and FtpFile?, add comments, and maybe rearange stuff to make the code more clear or for other reasons

Files:

Legend:

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

    r3372 r3377  
    1717 
    1818    public this(char[] server, char[] path, char[] username = "anonymous", 
    19                 char[] password = "anonymous@anonymous", uint port = 21) 
     19           char[] password = "anonymous@anonymous", uint port = 21) 
    2020    in { 
    2121        assert(server != ""); 
     
    7171 
    7272    public this(char[] server, char[] path, char[] username = "anonymous", 
    73                 char[] password = "anonymous@anonymous", uint port = 21) 
     73           char[] password = "anonymous@anonymous", uint port = 21) 
    7474    in { 
    7575        assert(server != ""); 
     
    104104    VfsFolders self() { 
    105105        return new VfsFolders(toString_, name_, username_, password_, port_, 
    106             true); 
     106               true); 
    107107    } 
    108108 
    109109    VfsFolders tree() { 
    110110        return new VfsFolders(toString_, name_, username_, password_, port_, 
    111             false); 
     111               false); 
    112112    } 
    113113 
     
    123123            if(fi.type = FtpFileType.dir) { 
    124124                FtpFolder x = new FtpFolder(toString_, fi.name, username_, 
    125                     password_, port_); 
     125                       password_, port_); 
    126126                if((result = dg(x)) != 0) 
    127127                    break; 
     
    178178 
    179179    public this(char[] server, char[] path, char[] username = "anonymous", 
    180                 char[] password = "anonymous@anonymous", uint port = 21) 
     180           char[] password = "anonymous@anonymous", uint port = 21) 
    181181    in { 
    182182        assert(server != ""); 
     
    195195    int opApply(int delegate(inout VfsFolder) dg) { 
    196196        FtpFolder ftp = new FtpFolder(toString_, name_, username, password_, 
    197             port_); 
     197               port_); 
    198198        ftp.opApply(dg); 
    199199    } 
     
    250250    VfsFiles catalog(char[] pattern) { 
    251251        return new FtpFiles(toString_, name_, username_, password_, port_, 
    252             pattern); 
     252               pattern); 
    253253    } 
    254254 
    255255    VfsFiles catalog(VfsFilter filter = null) { 
    256256        return new FtpFiles(toString_, name_, username_, password_, port_, 
    257             filter); 
     257               filter); 
    258258    } 
    259259} 
    260260 
    261261class FtpFile: VfsFile { 
     262 
     263    FTPConnection ftp_; 
     264    char[] toString_, name_, username_, password_; 
     265    uint port_; 
     266    bool writeable_, writeableSet_; 
     267 
     268    public this(char[] server, char[] path, char[] username = "anonymous", 
     269            char[] password = "anonymous@anonymous", uint port = 21) 
     270    in { 
     271        assert(server != ""); 
     272    } 
     273    out { 
     274        assert(server != ""); 
     275    } 
     276    body { 
     277        toString_ = server; 
     278        name_ = name != "" ? path : server; 
     279        username_ = username; 
     280        password_ = password; 
     281        port_ = port; 
     282    } 
     283 
    262284    char[] name() { 
    263         return null
     285        return name_
    264286    } 
    265287 
    266288    char[] toString() { 
    267         return null
     289        return toString_ ~ '/' ~ name_
    268290    } 
    269291 
    270292    bool exists() { 
    271         return null; 
     293        ftp_ = new FTPConnection(); 
     294        ftp_.connect(toString_, username_, password_, port_); 
     295        bool result = ftp_.exist(name_) == 1 ? true : false; 
     296        ftp_.close(); 
     297        return result; 
    272298    } 
    273299 
    274300    ulong size() { 
    275         return null; 
     301        ulong result = 0; 
     302        if(exists()) { 
     303            ftp_ = new FTPConnection(); 
     304            ftp_.connect(toString_, username_, password_, port_); 
     305            result = ftp_.getFileInfo(name_).size; 
     306            ftp_.close(); 
     307        } 
     308        return result; 
    276309    } 
    277310 
     
    310343 
    311344class FtpFiles: VfsFiles { 
     345 
     346    FTPConnection ftp_; 
     347    char[] toString_, name_, username_, password_; 
     348    uint port_; 
     349    bool writeable_, writeableSet_; 
     350    char[] filter_; 
     351    VfsFilter ffilter_; 
     352    bool useFilter = false; 
     353 
     354    public this(char[] server, char[] path, char[] username = "anonymous", 
     355            char[] password = "anonymous@anonymous", uint port = 21, 
     356            char[] filtPattern = "") 
     357    in { 
     358        assert(server != ""); 
     359    } 
     360    out { 
     361        assert(server != ""); 
     362    } 
     363    body { 
     364        toString_ = server; 
     365        name_ = name != "" ? path : server; 
     366        username_ = username; 
     367        password_ = password; 
     368        port_ = port; 
     369        filter_ = filtPattern; 
     370        useFilter = true; 
     371    } 
     372 
     373    public this(char[] server, char[] path, char[] username = "anonymous", 
     374            char[] password = "anonymous@anonymous", uint port = 21, 
     375            VfsFilter filter = null) 
     376    in { 
     377        assert(server != ""); 
     378    } 
     379    out { 
     380        assert(server != ""); 
     381    } 
     382    body { 
     383        toString_ = server; 
     384        name_ = name != "" ? path : server; 
     385        username_ = username; 
     386        password_ = password; 
     387        port_ = port; 
     388        ffilter_ = filter; 
     389    } 
     390 
    312391    int opApply(int delegate(inout VfsFile) dg) { 
    313392        return null;