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

Changeset 3481

Show
Ignore:
Timestamp:
05/03/08 04:49:33 (7 months ago)
Author:
lmartin92
Message:

Now input and output in ftp/FtpClient.d work perfectly

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/lmartin/ftp/tango/net/ftp/FtpClient.d

    r3480 r3481  
    326326 
    327327    public void close() { 
     328        //make sure no open data connection and if open data connection then kill 
     329        if(dataSocket_ !is null) 
     330            this.finishDataCommand(dataSocket_); 
    328331        if(socket_ !is null) { 
    329332            try { 
     
    889892 
    890893        // We shouldn't get a 250 in STREAM mode. 
    891         this.readResponse("226"); 
     894        FtpResponse r = readResponse(); 
     895        if(!(r.code == "226" || r.code == "420")) 
     896            exception("Bad finish"); 
     897             
    892898    } 
    893899 
     
    13681374        } else { 
    13691375            // Allocate space for the file, if we need to. 
    1370             this.allocate(file.length); 
     1376            //this.allocate(file.length); 
    13711377        } 
    13721378 
     
    15311537 
    15321538    public InputStream input(char[] path){ 
    1533         SocketConduit dataSocket_ = this.processDataCommand("RETR", path); 
     1539        dataSocket_ = this.processDataCommand("RETR", path); 
    15341540        return dataSocket_; 
    15351541    } 
    15361542 
    15371543    public OutputStream output(char[] path){ 
    1538         SocketConduit dataSocket_ = this.processDataCommand("STOR", path); 
     1544        dataSocket_ = this.processDataCommand("STOR", path); 
    15391545        return dataSocket_; 
    15401546    } 
     
    15511557        FileSystem.setDirectory(FileSystem.toAbsolute("Z:/")); 
    15521558        auto fp = new FilePath(FileSystem.toAbsolute("Z:/")); 
     1559         
    15531560        Stdout("Testing the new parts in FtpClient.d").newline.flush; 
    15541561        FTPConnection conn = new FTPConnection("localhost", "me", "pass", 21); 
    15551562        Stdout("Connecting works!").newline.flush; 
     1563         
    15561564        Stdout("Making directory SS.").newline.flush; 
    15571565        conn.mkdir("/SS"); 
     1566         
    15581567        Stdout("Setting current directory to SS.").newline.flush; 
    15591568        conn.cd("/SS"); 
     1569         
    15601570        Stdout("Setting current directory to parent directory.").newline.flush; 
    15611571        conn.cdup(); 
     1572         
    15621573        Stdout("Removing directory SS.").newline.flush; 
    15631574        conn.rm("/SS"); 
     1575         
    15641576        Stdout("Checking for the existence of a file.").newline.flush; 
    15651577        if(conn.exist("ServingSchedule.tif")) { 
     
    15751587            Stdout("The file was modified: "); 
    15761588            Stdout(layout("{:ddd, dd MMMM yyyy HH:mm:ss z}", modified)).newline.flush; 
    1577             Stdout("Press enter.").newline.flush; 
    1578             Cin.get(); 
    15791589            Stdout("Deleting the file No.").newline.flush; 
    15801590            conn.del("No"); 
    15811591        } else 
    15821592            Stdout("The file does not exist.").newline.flush; 
     1593             
     1594        Stdout("Listing content.").newline.flush; 
    15831595        FtpFileInfo[] infs = conn.ls(); 
    15841596        foreach(FtpFileInfo inf; infs) { 
    15851597            Stdout(inf.name).newline.flush; 
    15861598        } 
     1599         
    15871600        Stdout("Now getting a file and writing it to a place.").newline.flush; 
    15881601        conn.get("/Backup/ServingSchedule.tif", "/newFile.whatever"); 
     1602         
    15891603        Stdout("Now putting a file to the server.").newline.flush; 
    15901604        conn.put("ServingSchedule.tif", "/newFile.whatever"); 
     1605 
     1606        Stdout("Testing input.").newline.flush; 
     1607        FileConduit fcon = new FileConduit("Z:/whatever", FileConduit.ReadWriteCreate); 
     1608        fcon.copy(conn.input("/Backup/ServingSchedule.tif")); 
     1609             
     1610        Stdout("Testing output.").newline.flush; 
     1611        OutputStream os = conn.output("ServingSchedule.tif"); 
     1612        os.copy(fcon.input()); 
     1613         
    15911614        conn.close(); 
    1592         fp.file("/newFile.whatever"); 
     1615        fcon.close(); 
     1616        fp = fp.file("/newFile.whatever"); 
    15931617        fp.remove(); 
    15941618        Stdout("Finished.").newline.flush;