| | 487 | /******************************************************************************* |
|---|
| | 488 | |
|---|
| | 489 | A specific file representation |
|---|
| | 490 | |
|---|
| | 491 | *******************************************************************************/ |
|---|
| | 492 | |
|---|
| | 493 | class FtpFile : VfsFile |
|---|
| | 494 | { |
|---|
| | 495 | /*********************************************************************** |
|---|
| | 496 | |
|---|
| | 497 | Return a short name |
|---|
| | 498 | |
|---|
| | 499 | ***********************************************************************/ |
|---|
| | 500 | |
|---|
| | 501 | FtpFolder _folder; |
|---|
| | 502 | char[] _toString; |
|---|
| | 503 | char[] _name; |
|---|
| | 504 | VfsInfo _filt; |
|---|
| | 505 | |
|---|
| | 506 | package this(FtpFolder fol, char[] path) |
|---|
| | 507 | { |
|---|
| | 508 | _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]; |
|---|
| | 509 | _toString = path; |
|---|
| | 510 | _folder = new FtpFolder(fol); |
|---|
| | 511 | _filt.name = _name; |
|---|
| | 512 | _filt.path = _toString; |
|---|
| | 513 | _filt.folder = false; |
|---|
| | 514 | try |
|---|
| | 515 | { |
|---|
| | 516 | _filt.bytes = _folder._ftp.getFileInfo(_toString).size; |
|---|
| | 517 | } |
|---|
| | 518 | catch(Exception e) |
|---|
| | 519 | { |
|---|
| | 520 | _filt.bytes = 0; |
|---|
| | 521 | } |
|---|
| | 522 | } |
|---|
| | 523 | |
|---|
| | 524 | public this(VfsFolder fol, char[] path) |
|---|
| | 525 | { |
|---|
| | 526 | this(cast(FtpFolder) fol, path); |
|---|
| | 527 | } |
|---|
| | 528 | |
|---|
| | 529 | char[] name() |
|---|
| | 530 | { |
|---|
| | 531 | return _name; |
|---|
| | 532 | } |
|---|
| | 533 | |
|---|
| | 534 | /*********************************************************************** |
|---|
| | 535 | |
|---|
| | 536 | Return a long name |
|---|
| | 537 | |
|---|
| | 538 | ***********************************************************************/ |
|---|
| | 539 | |
|---|
| | 540 | char[] toString() |
|---|
| | 541 | { |
|---|
| | 542 | return _toString; |
|---|
| | 543 | } |
|---|
| | 544 | |
|---|
| | 545 | /*********************************************************************** |
|---|
| | 546 | |
|---|
| | 547 | Does this file exist? |
|---|
| | 548 | |
|---|
| | 549 | ***********************************************************************/ |
|---|
| | 550 | |
|---|
| | 551 | bool exists() |
|---|
| | 552 | { |
|---|
| | 553 | if(((_folder._ftp.exist(_name) || _folder._ftp.exist(_toString)) == 0) || ((_folder._ftp.exist(_name) || _folder._ftp.exist(_toString)) == 2)) |
|---|
| | 554 | return false; |
|---|
| | 555 | else |
|---|
| | 556 | return true; |
|---|
| | 557 | } |
|---|
| | 558 | |
|---|
| | 559 | /*********************************************************************** |
|---|
| | 560 | |
|---|
| | 561 | Return the file size |
|---|
| | 562 | |
|---|
| | 563 | ***********************************************************************/ |
|---|
| | 564 | |
|---|
| | 565 | ulong size () |
|---|
| | 566 | { |
|---|
| | 567 | return _filt.bytes; |
|---|
| | 568 | } |
|---|
| | 569 | |
|---|
| | 570 | /*********************************************************************** |
|---|
| | 571 | |
|---|
| | 572 | Create and copy the given source |
|---|
| | 573 | |
|---|
| | 574 | ***********************************************************************/ |
|---|
| | 575 | |
|---|
| | 576 | VfsFile copy (VfsFile source) |
|---|
| | 577 | { |
|---|
| | 578 | return null; |
|---|
| | 579 | } |
|---|
| | 580 | |
|---|
| | 581 | /*********************************************************************** |
|---|
| | 582 | |
|---|
| | 583 | Create and copy the given source, and remove the source |
|---|
| | 584 | |
|---|
| | 585 | ***********************************************************************/ |
|---|
| | 586 | |
|---|
| | 587 | VfsFile move (VfsFile source) |
|---|
| | 588 | { |
|---|
| | 589 | return null; |
|---|
| | 590 | } |
|---|
| | 591 | |
|---|
| | 592 | /*********************************************************************** |
|---|
| | 593 | |
|---|
| | 594 | Create a new file instance |
|---|
| | 595 | |
|---|
| | 596 | ***********************************************************************/ |
|---|
| | 597 | |
|---|
| | 598 | VfsFile create () |
|---|
| | 599 | { |
|---|
| | 600 | _folder._ftp.del(this.toString); |
|---|
| | 601 | return create(null); //needs to replace null with an empty stream |
|---|
| | 602 | } |
|---|
| | 603 | |
|---|
| | 604 | /*********************************************************************** |
|---|
| | 605 | |
|---|
| | 606 | Create a new file instance and populate with stream |
|---|
| | 607 | |
|---|
| | 608 | ***********************************************************************/ |
|---|
| | 609 | |
|---|
| | 610 | VfsFile create (InputStream stream) |
|---|
| | 611 | { |
|---|
| | 612 | _folder._ftp.del(this.toString); |
|---|
| | 613 | _folder._ftp.put(this.toString, stream, null, FtpFormat.image); |
|---|
| | 614 | return new FtpFile(this._folder, this.toString); |
|---|
| | 615 | } |
|---|
| | 616 | |
|---|
| | 617 | /*********************************************************************** |
|---|
| | 618 | |
|---|
| | 619 | Remove this file |
|---|
| | 620 | |
|---|
| | 621 | ***********************************************************************/ |
|---|
| | 622 | |
|---|
| | 623 | VfsFile remove () |
|---|
| | 624 | { |
|---|
| | 625 | _folder._ftp.del(this.toString); |
|---|
| | 626 | return new FtpFile(this._folder, this.toString); |
|---|
| | 627 | } |
|---|
| | 628 | |
|---|
| | 629 | /*********************************************************************** |
|---|
| | 630 | |
|---|
| | 631 | Return the input stream. Don't forget to close it |
|---|
| | 632 | |
|---|
| | 633 | ***********************************************************************/ |
|---|
| | 634 | |
|---|
| | 635 | //cant work until I make new FtpClient |
|---|
| | 636 | InputStream input () |
|---|
| | 637 | { |
|---|
| | 638 | return null; |
|---|
| | 639 | } |
|---|
| | 640 | |
|---|
| | 641 | /*********************************************************************** |
|---|
| | 642 | |
|---|
| | 643 | Return the output stream. Don't forget to close it |
|---|
| | 644 | |
|---|
| | 645 | ***********************************************************************/ |
|---|
| | 646 | |
|---|
| | 647 | //cant work until I make new FtpClient |
|---|
| | 648 | OutputStream output () |
|---|
| | 649 | { |
|---|
| | 650 | return null; |
|---|
| | 651 | } |
|---|
| | 652 | |
|---|
| | 653 | /*********************************************************************** |
|---|
| | 654 | |
|---|
| | 655 | Duplicate this entry |
|---|
| | 656 | |
|---|
| | 657 | ***********************************************************************/ |
|---|
| | 658 | |
|---|
| | 659 | VfsFile dup () |
|---|
| | 660 | { |
|---|
| | 661 | return new FtpFile(_folder, toString); |
|---|
| | 662 | } |
|---|
| | 663 | } |
|---|
| | 664 | |
|---|
| 536 | | |
|---|
| 537 | | |
|---|
| 538 | | /******************************************************************************* |
|---|
| 539 | | |
|---|
| 540 | | A specific file representation |
|---|
| 541 | | |
|---|
| 542 | | *******************************************************************************/ |
|---|
| 543 | | |
|---|
| 544 | | class FtpFile : VfsFile |
|---|
| 545 | | { |
|---|
| 546 | | /*********************************************************************** |
|---|
| 547 | | |
|---|
| 548 | | Return a short name |
|---|
| 549 | | |
|---|
| 550 | | ***********************************************************************/ |
|---|
| 551 | | |
|---|
| 552 | | VfsFilter _filt; |
|---|
| 553 | | |
|---|
| 554 | | package this(FtpFolder fol, char[] path) |
|---|
| 555 | | { |
|---|
| 556 | | } |
|---|
| 557 | | |
|---|
| 558 | | char[] name() |
|---|
| 559 | | { |
|---|
| 560 | | return null; |
|---|
| 561 | | } |
|---|
| 562 | | |
|---|
| 563 | | /*********************************************************************** |
|---|
| 564 | | |
|---|
| 565 | | Return a long name |
|---|
| 566 | | |
|---|
| 567 | | ***********************************************************************/ |
|---|
| 568 | | |
|---|
| 569 | | char[] toString() |
|---|
| 570 | | { |
|---|
| 571 | | return null; |
|---|
| 572 | | } |
|---|
| 573 | | |
|---|
| 574 | | /*********************************************************************** |
|---|
| 575 | | |
|---|
| 576 | | Does this file exist? |
|---|
| 577 | | |
|---|
| 578 | | ***********************************************************************/ |
|---|
| 579 | | |
|---|
| 580 | | bool exists() |
|---|
| 581 | | { |
|---|
| 582 | | return 0; |
|---|
| 583 | | } |
|---|
| 584 | | |
|---|
| 585 | | /*********************************************************************** |
|---|
| 586 | | |
|---|
| 587 | | Return the file size |
|---|
| 588 | | |
|---|
| 589 | | ***********************************************************************/ |
|---|
| 590 | | |
|---|
| 591 | | ulong size () |
|---|
| 592 | | { |
|---|
| 593 | | return 0; |
|---|
| 594 | | } |
|---|
| 595 | | |
|---|
| 596 | | /*********************************************************************** |
|---|
| 597 | | |
|---|
| 598 | | Create and copy the given source |
|---|
| 599 | | |
|---|
| 600 | | ***********************************************************************/ |
|---|
| 601 | | |
|---|
| 602 | | VfsFile copy (VfsFile source) |
|---|
| 603 | | { |
|---|
| 604 | | return null; |
|---|
| 605 | | } |
|---|
| 606 | | |
|---|
| 607 | | /*********************************************************************** |
|---|
| 608 | | |
|---|
| 609 | | Create and copy the given source, and remove the source |
|---|
| 610 | | |
|---|
| 611 | | ***********************************************************************/ |
|---|
| 612 | | |
|---|
| 613 | | VfsFile move (VfsFile source) |
|---|
| 614 | | { |
|---|
| 615 | | return null; |
|---|
| 616 | | } |
|---|
| 617 | | |
|---|
| 618 | | /*********************************************************************** |
|---|
| 619 | | |
|---|
| 620 | | Create a new file instance |
|---|
| 621 | | |
|---|
| 622 | | ***********************************************************************/ |
|---|
| 623 | | |
|---|
| 624 | | VfsFile create () |
|---|
| 625 | | { |
|---|
| 626 | | return null; |
|---|
| 627 | | } |
|---|
| 628 | | |
|---|
| 629 | | /*********************************************************************** |
|---|
| 630 | | |
|---|
| 631 | | Create a new file instance and populate with stream |
|---|
| 632 | | |
|---|
| 633 | | ***********************************************************************/ |
|---|
| 634 | | |
|---|
| 635 | | VfsFile create (InputStream stream) |
|---|
| 636 | | { |
|---|
| 637 | | return null; |
|---|
| 638 | | } |
|---|
| 639 | | |
|---|
| 640 | | /*********************************************************************** |
|---|
| 641 | | |
|---|
| 642 | | Remove this file |
|---|
| 643 | | |
|---|
| 644 | | ***********************************************************************/ |
|---|
| 645 | | |
|---|
| 646 | | VfsFile remove () |
|---|
| 647 | | { |
|---|
| 648 | | return null; |
|---|
| 649 | | } |
|---|
| 650 | | |
|---|
| 651 | | /*********************************************************************** |
|---|
| 652 | | |
|---|
| 653 | | Return the input stream. Don't forget to close it |
|---|
| 654 | | |
|---|
| 655 | | ***********************************************************************/ |
|---|
| 656 | | |
|---|
| 657 | | InputStream input () |
|---|
| 658 | | { |
|---|
| 659 | | return null; |
|---|
| 660 | | } |
|---|
| 661 | | |
|---|
| 662 | | /*********************************************************************** |
|---|
| 663 | | |
|---|
| 664 | | Return the output stream. Don't forget to close it |
|---|
| 665 | | |
|---|
| 666 | | ***********************************************************************/ |
|---|
| 667 | | |
|---|
| 668 | | OutputStream output () |
|---|
| 669 | | { |
|---|
| 670 | | return null; |
|---|
| 671 | | } |
|---|
| 672 | | |
|---|
| 673 | | /*********************************************************************** |
|---|
| 674 | | |
|---|
| 675 | | Duplicate this entry |
|---|
| 676 | | |
|---|
| 677 | | ***********************************************************************/ |
|---|
| 678 | | |
|---|
| 679 | | VfsFile dup () |
|---|
| 680 | | { |
|---|
| 681 | | return null; |
|---|
| 682 | | } |
|---|
| 683 | | } |
|---|
| 684 | | |
|---|