diff options
| author | Mel <einebeere@gmail.com> | 2021-10-01 00:34:16 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2021-10-01 00:34:16 +0200 |
| commit | 3f5c5026909af023c8a3885a4a3d97c669302c1b (patch) | |
| tree | 44c7e3e81d3b71ad6977afe4ac1596033b5834a6 /src/files.rs | |
| parent | 8f700551fd3f98c7b9846af647a7318c171152a6 (diff) | |
| download | ka-3f5c5026909af023c8a3885a4a3d97c669302c1b.tar.zst ka-3f5c5026909af023c8a3885a4a3d97c669302c1b.zip | |
Global repository cursor
Diffstat (limited to 'src/files.rs')
| -rw-r--r-- | src/files.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/files.rs b/src/files.rs index 41dbad1..a2b1db4 100644 --- a/src/files.rs +++ b/src/files.rs @@ -15,6 +15,10 @@ pub struct Locations { } impl Locations { + pub fn get_repository_index(&self) -> PathBuf { + return self.ka_path.join("index") + } + pub fn get_repository_files(&self) -> Result<Vec<FileState>, Error> { let working_entries = fs::read_dir(&self.repository_path) .context("Failed reading working file entries.")? @@ -124,10 +128,18 @@ impl FileState { }) }) } + + pub fn get_working_path(&self, locations: &Locations) -> Result<PathBuf> { + match self { + FileState::Deleted(deleted) => locations.working_from_history(&deleted.history_path), + FileState::Untracked(untracked) => Ok(untracked.path.clone()), + FileState::Tracked(tracked) => Ok(tracked.working_path.clone()), + } + } } pub struct FileDeleted { - history_path: PathBuf, + pub history_path: PathBuf, } impl FileDeleted { @@ -146,7 +158,7 @@ impl FileDeleted { } pub struct FileUntracked { - path: PathBuf, + pub path: PathBuf, } impl FileUntracked { @@ -168,8 +180,8 @@ impl FileUntracked { } pub struct FileTracked { - history_path: PathBuf, - working_path: PathBuf, + pub history_path: PathBuf, + pub working_path: PathBuf, } impl FileTracked { |
