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

Changeset 3386

Show
Ignore:
Timestamp:
03/21/08 04:44:05 (9 months ago)
Author:
lmartin92
Message:

Fixed it to compile but figured out some changes needed to be made to FtpFolders? so will work on them.

Files:

Legend:

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

    r3383 r3386  
    66 */ 
    77 
     8 //fix flatness 
     9 
    810import tango.net.ftp.FtpClient; 
    911import tango.io.vfs.model.Vfs; 
     12import tango.io.vfs.FileFolder; 
    1013import tango.io.Conduit; 
    1114import tango.text.Util; 
     
    104107 
    105108    VfsFolders self() { 
    106         return new VfsFolders(toString_, name_, username_, password_, port_, 
     109        return new FtpFolders(toString_, name_, username_, password_, port_, 
    107110            true); 
    108111    } 
    109112 
    110113    VfsFolders tree() { 
    111         return new VfsFolders(toString_, name_, username_, password_, port_, 
     114        return new FtpFolders(toString_, name_, username_, password_, port_, 
    112115            false); 
    113116    } 
     
    122125 
    123126        foreach(FtpFileInfo fi; fis) { 
    124             if(fi.type = FtpFileType.dir) { 
    125                 FtpFolder x = new FtpFolder(toString_, fi.name, username_, 
     127            if(fi.type == FtpFileType.dir) { 
     128                VfsFolder x = new FtpFolder(toString_, fi.name, username_, 
    126129                    password_, port_); 
    127130                if((result = dg(x)) != 0) 
     
    177180    char[] toString_, name_, username_, password_; 
    178181    uint port_; 
     182    bool flat_; 
    179183 
    180184    public this(char[] server, char[] path, char[] username = "anonymous", 
     
    188192    body { 
    189193        toString_ = server; 
    190         name_ = name != "" ? path : server; 
    191         username_ = username; 
    192         password_ = password; 
    193         port_ = port; 
     194        name_ = path != "" ? path : server; 
     195        username_ = username; 
     196        password_ = password; 
     197        port_ = port; 
     198    } 
     199 
     200    public this(char[] server, char[] path, char[] username = "anonymous", 
     201                char[] password = "anonymous@anonymous", uint port = 21, bool flat = false) 
     202    in { 
     203        assert(server != ""); 
     204    } 
     205    out { 
     206        assert(server != ""); 
     207    } 
     208    body { 
     209        toString_ = server; 
     210        name_ = path != "" ? path : server; 
     211        username_ = username; 
     212        password_ = password; 
     213        port_ = port; 
     214        flat_ = flat; 
    194215    } 
    195216 
    196217    int opApply(int delegate(inout VfsFolder) dg) { 
    197         FtpFolder ftp = new FtpFolder(toString_, name_, username, password_, 
     218        FtpFolder ftp = new FtpFolder(toString_, name_, username_, password_, 
    198219            port_); 
    199         ftp.opApply(dg); 
     220        return ftp.opApply(dg); 
    200221    } 
    201222 
     
    208229 
    209230        foreach(FtpFileInfo fi; fis) { 
    210             if(fi.type == FtpFileType.unknown || fi.type == FTPFileType.file || fi.type == FtpFileType.other) 
     231            if(fi.type == FtpFileType.unknown || fi.type == FtpFileType.file || fi.type == FtpFileType.other) 
    211232                size++; 
    212233        } 
     
    223244 
    224245        foreach(FtpFileInfo fi; fis) { 
    225             if(fi.type != FtpFileType.unknown || fi.type != FTPFileType.file || fi.type != FtpFileType.other) 
     246            if(fi.type != FtpFileType.unknown || fi.type != FtpFileType.file || fi.type != FtpFileType.other) 
    226247                size++; 
    227248        } 
     
    242263 
    243264        foreach(FtpFileInfo fi; fis) { 
    244             if(fi.type == FtpFileType.unknown || fi.type == FTPFileType.file || fi.type == FtpFileType.other) 
     265            if(fi.type == FtpFileType.unknown || fi.type == FtpFileType.file || fi.type == FtpFileType.other) 
    245266                size += fi.size; 
    246267        } 
     
    257278        return new FtpFiles(toString_, name_, username_, password_, port_, 
    258279            filter); 
     280    } 
     281 
     282    VfsFolders subset (char[] pattern){ 
     283        return null; 
    259284    } 
    260285} 
     
    311336 
    312337    VfsFile copy(VfsFile source) { 
    313         output.write(source.input.read); 
     338        void[] dest; 
     339        source.input.read(dest); 
     340        output.write(dest); 
     341        return new FtpFile(toString_, name_, username_, password_, port_); 
    314342    } 
    315343 
     
    317345        copy(source); 
    318346        source.remove; 
     347        return new FtpFile(toString_, name_, username_, password_, port_); 
    319348    } 
    320349 
    321350    VfsFile create() { 
    322         FileFolder ff = new FileFolder("/NF", true); 
     351        VfsFolder f = new FileFolder(""); 
     352        VfsFile ff = f.file("/NF.NF"); 
    323353        ftp_ = new FTPConnection(); 
    324354        ftp_.connect(toString_, username_, password_, port_); 
    325355        ftp_.put(name_, ff.input); 
    326         ftp.close(); 
     356        ftp_.close(); 
    327357        ff.remove(); 
    328358        return new FtpFile(toString_, name_, username_, password_, port_); 
     
    333363        ftp_.connect(toString_, username_, password_, port_); 
    334364        ftp_.put(name_, stream); 
    335         ftp.close(); 
     365        ftp_.close(); 
    336366        return new FtpFile(toString_, name_, username_, password_, port_); 
    337367    } 
     
    341371        ftp_.connect(toString_, username_, password_, port_); 
    342372        ftp_.del(name_); 
    343         return new VfsFile(toString_, name_, username_, password_, port_); 
     373        return new FtpFile(toString_, name_, username_, password_, port_); 
    344374    } 
    345375 
    346376    InputStream input() { 
    347         ftp_ = new FtpConnection(); 
     377        ftp_ = new FTPConnection(); 
    348378        ftp_.connect(toString_, username_, password_, port_); 
    349379        InputStream input = ftp_.input; 
    350         prepareInputStream(ftp_, input, FtpCommand.RETR, ["", path_]); 
     380        prepareInputStream(ftp_, input, FtpCommand.RETR, ["", name_]); 
    351381        ftp_.close(); 
    352382        return input; 
     
    354384 
    355385    OutputStream output() { 
    356         ftp_ = new FtpConnection(); 
     386        ftp_ = new FTPConnection(); 
    357387        ftp_.connect(toString_, username_, password_, port_); 
    358388        OutputStream output = ftp_.output; 
    359         prepareOutputStream(ftp_, output, FtpCommand.STOR, ["", path_]); 
     389        prepareOutputStream(ftp_, output, FtpCommand.STOR, ["", name_]); 
    360390        ftp_.close(); 
    361391        return output; 
     
    389419    body { 
    390420        toString_ = server; 
    391         name_ = name != "" ? path : server; 
     421        name_ = path != "" ? path : server; 
    392422        username_ = username; 
    393423        password_ = password; 
     
    409439    body { 
    410440        toString_ = server; 
    411         name_ = name != "" ? path : server; 
     441        name_ = path != "" ? path : server; 
    412442        username_ = username; 
    413443        password_ = password; 
     
    419449        int result; 
    420450        foreach(FtpFileInfo inf; getFileInfo()) { 
    421             FtpFile x = new FtpFile(toString_, inf.name, username_, password_, 
    422                 port); 
     451            VfsFile x = new FtpFile(toString_, inf.name, username_, password_, 
     452                port_); 
    423453            if((result = dg(x)) != 0) 
    424454                break; 
     
    436466            FtpFileInfo[] infs = ftp_.ls(); 
    437467            FtpFileInfo[] toReturn; 
    438             if(useFilter) { 
     468            if(useFilter_) { 
    439469                foreach(FtpFileInfo inf; infs) { 
    440                     if(contains(inf.name, filter_)) { 
     470                    if(containsPattern(inf.name, filter_)) { 
    441471                        toReturn ~= inf; 
    442472                    } 
     
    447477                    VfsFilterInfo temp; 
    448478                    temp.name = inf.name; 
    449                     temp.folder = toString_
     479                    temp.folder = false
    450480                    temp.path = toString_ ~ temp.name; 
    451481                    temp.bytes = inf.size;