Show More
@@ -519,30 +519,60 impl Drop for AtomicFile { | |||
|
519 | 519 | /// filesystem layer (like passing one from Python). |
|
520 | 520 | pub trait Vfs: Sync + Send + DynClone { |
|
521 | 521 | // TODO make `open` readonly and make `open_read` an `open_write` |
|
522 | /// Open a [`VfsFile::Normal`] for writing and reading the file at | |
|
523 | /// `filename`, relative to this VFS's root. | |
|
522 | 524 | fn open(&self, filename: &Path) -> Result<VfsFile, HgError>; |
|
525 | /// Open a [`VfsFile::Normal`] for reading the file at `filename`, | |
|
526 | /// relative to this VFS's root. | |
|
523 | 527 | fn open_read(&self, filename: &Path) -> Result<VfsFile, HgError>; |
|
528 | /// Open a [`VfsFile::Normal`] for reading and writing the file at | |
|
529 | /// `filename`, relative to this VFS's root. This file will be checked | |
|
530 | /// for an ambiguous mtime on [`drop`]. See [`is_filetime_ambiguous`]. | |
|
524 | 531 | fn open_check_ambig(&self, filename: &Path) -> Result<VfsFile, HgError>; |
|
532 | /// Create a [`VfsFile::Normal`] for reading and writing the file at | |
|
533 | /// `filename`, relative to this VFS's root. If the file already exists, | |
|
534 | /// it will be truncated to 0 bytes. | |
|
525 | 535 | fn create( |
|
526 | 536 | &self, |
|
527 | 537 | filename: &Path, |
|
528 | 538 | check_ambig: bool, |
|
529 | 539 | ) -> Result<VfsFile, HgError>; |
|
530 | /// Must truncate the new file if exist | |
|
540 | /// Create a [`VfsFile::Atomic`] for reading and writing the file at | |
|
541 | /// `filename`, relative to this VFS's root. If the file already exists, | |
|
542 | /// it will be truncated to 0 bytes. | |
|
531 | 543 | fn create_atomic( |
|
532 | 544 | &self, |
|
533 | 545 | filename: &Path, |
|
534 | 546 | check_ambig: bool, |
|
535 | 547 | ) -> Result<VfsFile, HgError>; |
|
548 | /// Return the total file size in bytes of the open `file`. Errors are | |
|
549 | /// usual IO errors (invalid file handle, permissions, etc.) | |
|
536 | 550 | fn file_size(&self, file: &VfsFile) -> Result<u64, HgError>; |
|
551 | /// Return `true` if `filename` exists relative to this VFS's root. Errors | |
|
552 | /// will coerce to `false`, to this also returns `false` if there are | |
|
553 | /// IO problems. This is fine because any operation that actually tries | |
|
554 | /// to do anything with this path will get the same error. | |
|
537 | 555 | fn exists(&self, filename: &Path) -> bool; |
|
556 | /// Remove the file at `filename` relative to this VFS's root. Errors | |
|
557 | /// are the usual IO errors (lacking permission, file does not exist, etc.) | |
|
538 | 558 | fn unlink(&self, filename: &Path) -> Result<(), HgError>; |
|
559 | /// Rename the file `from` to `to`, both relative to this VFS's root. | |
|
560 | /// Errors are the usual IO errors (lacking permission, file does not | |
|
561 | /// exist, etc.). If `check_ambig` is `true`, the VFS will check for an | |
|
562 | /// ambiguous mtime on rename. See [`is_filetime_ambiguous`]. | |
|
539 | 563 | fn rename( |
|
540 | 564 | &self, |
|
541 | 565 | from: &Path, |
|
542 | 566 | to: &Path, |
|
543 | 567 | check_ambig: bool, |
|
544 | 568 | ) -> Result<(), HgError>; |
|
569 | /// Rename the file `from` to `to`, both relative to this VFS's root. | |
|
570 | /// Errors are the usual IO errors (lacking permission, file does not | |
|
571 | /// exist, etc.). If `check_ambig` is passed, the VFS will check for an | |
|
572 | /// ambiguous mtime on rename. See [`is_filetime_ambiguous`]. | |
|
545 | 573 | fn copy(&self, from: &Path, to: &Path) -> Result<(), HgError>; |
|
574 | /// Returns the absolute root path of this VFS, relative to which all | |
|
575 | /// operations are done. | |
|
546 | 576 | fn base(&self) -> &Path; |
|
547 | 577 | } |
|
548 | 578 |
General Comments 0
You need to be logged in to leave comments.
Login now