about summary refs log tree commit diff
path: root/src/files.rs
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2021-10-01 00:34:16 +0200
committerMel <einebeere@gmail.com>2021-10-01 00:34:16 +0200
commit3f5c5026909af023c8a3885a4a3d97c669302c1b (patch)
tree44c7e3e81d3b71ad6977afe4ac1596033b5834a6 /src/files.rs
parent8f700551fd3f98c7b9846af647a7318c171152a6 (diff)
downloadka-3f5c5026909af023c8a3885a4a3d97c669302c1b.tar.zst
ka-3f5c5026909af023c8a3885a4a3d97c669302c1b.zip
Global repository cursor
Diffstat (limited to 'src/files.rs')
-rw-r--r--src/files.rs20
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 {