summaryrefslogtreecommitdiffstats
path: root/libimagref
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-06-09 19:34:25 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-07-04 19:29:02 +0200
commita3b35205913f018cfbf3cfe6defafe503dddae68 (patch)
treefebccdf9e7ba4dec903885d985b7ddc90d7a35f5 /libimagref
parent6d41747fdb112d0aa730da5d5805547fe3f29330 (diff)
Add Ref type
Diffstat (limited to 'libimagref')
-rw-r--r--libimagref/src/lib.rs6
-rw-r--r--libimagref/src/reference.rs106
2 files changed, 111 insertions, 1 deletions
diff --git a/libimagref/src/lib.rs b/libimagref/src/lib.rs
index c62abbd0..e9fca89f 100644
--- a/libimagref/src/lib.rs
+++ b/libimagref/src/lib.rs
@@ -12,4 +12,8 @@ extern crate walkdir;
module_entry_path_mod!("ref", "0.1.0");
-pub mod ref;
+pub mod reference;
+pub mod flags;
+pub mod error;
+pub mod result;
+
diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs
new file mode 100644
index 00000000..67c210bd
--- /dev/null
+++ b/libimagref/src/reference.rs
@@ -0,0 +1,106 @@
+//! The Ref object is a helper over the link functionality, so one is able to create references to
+//! files outside of the imag store.
+
+use std::path::PathBuf;
+use std::ops::Deref;
+use std::ops::DerefMut;
+
+use libimagstore::store::FileLockEntry;
+use libimagstore::storeid::StoreId;
+use libimagstore::store::Store;
+
+use result::Result;
+use flags::RefFlags;
+
+pub struct Ref<'a>(FileLockEntry<'a>);
+
+impl<'a> Ref<'a> {
+
+ /// Try to open `si` as Ref object from the store
+ pub fn open(store: &Store, si: StoreId) -> Result<Ref<'a>> {
+ unimplemented!()
+ }
+
+ /// Create a Ref object which refers to `pb`
+ pub fn create(store: &Store, pb: PathBuf, flags: RefFlags) -> Result<Ref<'a>> {
+ unimplemented!()
+ }
+
+ /// Creates a Hash from a PathBuf by making the PathBuf absolute and then running a hash
+ /// algorithm on it
+ fn hash_path(pb: &PathBuf) -> String {
+ unimplemented!()
+ }
+
+ /// check whether the pointer the Ref represents still points to a file which exists
+ pub fn fs_link_exists(&self) -> bool {
+ unimplemented!()
+ }
+
+ /// check whether the pointer the Ref represents is valid
+ /// This includes:
+ /// - Hashsum of the file is still the same as stored in the Ref
+ /// - file permissions are still valid
+ pub fn fs_link_valid(&self) -> bool {
+ unimplemented!()
+ }
+
+ /// Check whether the file permissions of the referenced file are equal to the stored
+ /// permissions
+ pub fn fs_link_valid_permissions(&self) -> bool {
+ unimplemented!()
+ }
+
+ /// Check whether the Hashsum of the referenced file is equal to the stored hashsum
+ pub fn fs_link_valid_hash(&self) -> bool {
+ unimplemented!()
+ }
+
+ /// Update the Ref by re-checking the file from FS
+ /// This errors if the file is not present or cannot be read()
+ pub fn update_ref(&mut self) -> Result<()> {
+ unimplemented!()
+ }
+
+ /// Get the path of the file which is reffered to by this Ref
+ pub fn fs_file(&self) -> &PathBuf {
+ unimplemented!()
+ }
+
+ /// Check whether there is a reference to the file at `pb`
+ pub fn exists(store: &Store, pb: PathBuf) -> Result<bool> {
+ unimplemented!()
+ }
+
+ /// Re-find a referenced file
+ ///
+ /// This function tries to re-find a ref by searching all directories in `search_roots` recursively
+ /// for a file which matches the hash of the Ref `ref`.
+ ///
+ /// If `search_roots` is `None`, it starts at the filesystem root `/`.
+ ///
+ /// # Warning
+ ///
+ /// This option causes heavy I/O as it recursively searches the Filesystem.
+ pub fn refind(&self, search_roots: Option<Vec<PathBuf>>) -> Option<PathBuf> {
+ unimplemented!()
+ }
+
+}
+
+impl<'a> Deref for Ref<'a> {
+ type Target = FileLockEntry<'a>;
+
+ fn deref(&self) -> &FileLockEntry<'a> {
+ &self.0
+ }
+
+}
+
+impl<'a> DerefMut for Ref<'a> {
+
+ fn deref_mut(&mut self) -> &mut FileLockEntry<'a> {
+ &mut self.0
+ }
+
+}