Show More
@@ -519,30 +519,60 impl Drop for AtomicFile { | |||||
519 | /// filesystem layer (like passing one from Python). |
|
519 | /// filesystem layer (like passing one from Python). | |
520 | pub trait Vfs: Sync + Send + DynClone { |
|
520 | pub trait Vfs: Sync + Send + DynClone { | |
521 | // TODO make `open` readonly and make `open_read` an `open_write` |
|
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 | fn open(&self, filename: &Path) -> Result<VfsFile, HgError>; |
|
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 | fn open_read(&self, filename: &Path) -> Result<VfsFile, HgError>; |
|
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 | fn open_check_ambig(&self, filename: &Path) -> Result<VfsFile, HgError>; |
|
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 | fn create( |
|
535 | fn create( | |
526 | &self, |
|
536 | &self, | |
527 | filename: &Path, |
|
537 | filename: &Path, | |
528 | check_ambig: bool, |
|
538 | check_ambig: bool, | |
529 | ) -> Result<VfsFile, HgError>; |
|
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 | fn create_atomic( |
|
543 | fn create_atomic( | |
532 | &self, |
|
544 | &self, | |
533 | filename: &Path, |
|
545 | filename: &Path, | |
534 | check_ambig: bool, |
|
546 | check_ambig: bool, | |
535 | ) -> Result<VfsFile, HgError>; |
|
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 | fn file_size(&self, file: &VfsFile) -> Result<u64, HgError>; |
|
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 | fn exists(&self, filename: &Path) -> bool; |
|
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 | fn unlink(&self, filename: &Path) -> Result<(), HgError>; |
|
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 | fn rename( |
|
563 | fn rename( | |
540 | &self, |
|
564 | &self, | |
541 | from: &Path, |
|
565 | from: &Path, | |
542 | to: &Path, |
|
566 | to: &Path, | |
543 | check_ambig: bool, |
|
567 | check_ambig: bool, | |
544 | ) -> Result<(), HgError>; |
|
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 | fn copy(&self, from: &Path, to: &Path) -> Result<(), HgError>; |
|
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 | fn base(&self) -> &Path; |
|
576 | fn base(&self) -> &Path; | |
547 | } |
|
577 | } | |
548 |
|
578 |
General Comments 0
You need to be logged in to leave comments.
Login now