 |
Changeset 3481
- 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
| r3480 |
r3481 |
|
| 326 | 326 | |
|---|
| 327 | 327 | 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_); |
|---|
| 328 | 331 | if(socket_ !is null) { |
|---|
| 329 | 332 | try { |
|---|
| … | … | |
| 889 | 892 | |
|---|
| 890 | 893 | // 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 | |
|---|
| 892 | 898 | } |
|---|
| 893 | 899 | |
|---|
| … | … | |
| 1368 | 1374 | } else { |
|---|
| 1369 | 1375 | // Allocate space for the file, if we need to. |
|---|
| 1370 | | this.allocate(file.length); |
|---|
| | 1376 | //this.allocate(file.length); |
|---|
| 1371 | 1377 | } |
|---|
| 1372 | 1378 | |
|---|
| … | … | |
| 1531 | 1537 | |
|---|
| 1532 | 1538 | public InputStream input(char[] path){ |
|---|
| 1533 | | SocketConduit dataSocket_ = this.processDataCommand("RETR", path); |
|---|
| | 1539 | dataSocket_ = this.processDataCommand("RETR", path); |
|---|
| 1534 | 1540 | return dataSocket_; |
|---|
| 1535 | 1541 | } |
|---|
| 1536 | 1542 | |
|---|
| 1537 | 1543 | public OutputStream output(char[] path){ |
|---|
| 1538 | | SocketConduit dataSocket_ = this.processDataCommand("STOR", path); |
|---|
| | 1544 | dataSocket_ = this.processDataCommand("STOR", path); |
|---|
| 1539 | 1545 | return dataSocket_; |
|---|
| 1540 | 1546 | } |
|---|
| … | … | |
| 1551 | 1557 | FileSystem.setDirectory(FileSystem.toAbsolute("Z:/")); |
|---|
| 1552 | 1558 | auto fp = new FilePath(FileSystem.toAbsolute("Z:/")); |
|---|
| | 1559 | |
|---|
| 1553 | 1560 | Stdout("Testing the new parts in FtpClient.d").newline.flush; |
|---|
| 1554 | 1561 | FTPConnection conn = new FTPConnection("localhost", "me", "pass", 21); |
|---|
| 1555 | 1562 | Stdout("Connecting works!").newline.flush; |
|---|
| | 1563 | |
|---|
| 1556 | 1564 | Stdout("Making directory SS.").newline.flush; |
|---|
| 1557 | 1565 | conn.mkdir("/SS"); |
|---|
| | 1566 | |
|---|
| 1558 | 1567 | Stdout("Setting current directory to SS.").newline.flush; |
|---|
| 1559 | 1568 | conn.cd("/SS"); |
|---|
| | 1569 | |
|---|
| 1560 | 1570 | Stdout("Setting current directory to parent directory.").newline.flush; |
|---|
| 1561 | 1571 | conn.cdup(); |
|---|
| | 1572 | |
|---|
| 1562 | 1573 | Stdout("Removing directory SS.").newline.flush; |
|---|
| 1563 | 1574 | conn.rm("/SS"); |
|---|
| | 1575 | |
|---|
| 1564 | 1576 | Stdout("Checking for the existence of a file.").newline.flush; |
|---|
| 1565 | 1577 | if(conn.exist("ServingSchedule.tif")) { |
|---|
| … | … | |
| 1575 | 1587 | Stdout("The file was modified: "); |
|---|
| 1576 | 1588 | Stdout(layout("{:ddd, dd MMMM yyyy HH:mm:ss z}", modified)).newline.flush; |
|---|
| 1577 | | Stdout("Press enter.").newline.flush; |
|---|
| 1578 | | Cin.get(); |
|---|
| 1579 | 1589 | Stdout("Deleting the file No.").newline.flush; |
|---|
| 1580 | 1590 | conn.del("No"); |
|---|
| 1581 | 1591 | } else |
|---|
| 1582 | 1592 | Stdout("The file does not exist.").newline.flush; |
|---|
| | 1593 | |
|---|
| | 1594 | Stdout("Listing content.").newline.flush; |
|---|
| 1583 | 1595 | FtpFileInfo[] infs = conn.ls(); |
|---|
| 1584 | 1596 | foreach(FtpFileInfo inf; infs) { |
|---|
| 1585 | 1597 | Stdout(inf.name).newline.flush; |
|---|
| 1586 | 1598 | } |
|---|
| | 1599 | |
|---|
| 1587 | 1600 | Stdout("Now getting a file and writing it to a place.").newline.flush; |
|---|
| 1588 | 1601 | conn.get("/Backup/ServingSchedule.tif", "/newFile.whatever"); |
|---|
| | 1602 | |
|---|
| 1589 | 1603 | Stdout("Now putting a file to the server.").newline.flush; |
|---|
| 1590 | 1604 | 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 | |
|---|
| 1591 | 1614 | conn.close(); |
|---|
| 1592 | | fp.file("/newFile.whatever"); |
|---|
| | 1615 | fcon.close(); |
|---|
| | 1616 | fp = fp.file("/newFile.whatever"); |
|---|
| 1593 | 1617 | fp.remove(); |
|---|
| 1594 | 1618 | Stdout("Finished.").newline.flush; |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic