pub fn new(cfg: &config::Config, dir: &str) -> HashIndex<T> {
        let dir = &cfg.root.clone().join(dir);

        let is_new = !dir.exists();

        let mut fileset = FlatFileSet::new(
            dir, "hi-", FILE_SIZE, MAX_CONTENT_SIZE);

        let hash_root_fileptr = if is_new {

            // allocate space for root hash table
            fileset.alloc_write_space(mem::size_of::<[IndexPtr; HASH_ROOT_COUNT]>() as u64)
        }
        else {
            // hash root must have been the first thing written
            IndexPtr::new(0, super::flatfile::INITIAL_WRITEPOS)
        };

        // and keep a reference to it
        let hash_root_ref: &'static [IndexPtr; HASH_ROOT_COUNT]
            = fileset.read_fixed(hash_root_fileptr);

        HashIndex {
            fileset: fileset,
            hash_index_root: hash_root_ref,
            phantom: ::std::marker::PhantomData
        }
    }
/// Opens the hash_index at the location given in the config
///
/// Creates a new fileset if needed
Opens the hash_index at the location given in the config
Creates a new fileset if needed
Opens the hash_index at the location given in the config Creates a new fileset if needed
pub fn new(cfg: &config::Config, dir: &str) -> HashIndex<T> {
        let dir = &cfg.root.clone().join(dir);
        let is_new = !dir.exists();
        let mut fileset = FlatFileSet::new(
            dir, "hi-", FILE_SIZE, MAX_CONTENT_SIZE);
        let hash_root_fileptr = if is_new {
            // allocate space for root hash table
            fileset.alloc_write_space(mem::size_of::<[IndexPtr; HASH_ROOT_COUNT]>() as u64)
        }
        else {
            // hash root must have been the first thing written
            IndexPtr::new(0, super::flatfile::INITIAL_WRITEPOS)
        };
        // and keep a reference to it
        let hash_root_ref: &'static [IndexPtr; HASH_ROOT_COUNT]
            = fileset.read_fixed(hash_root_fileptr);
        HashIndex {
            fileset: fileset,
            hash_index_root: hash_root_ref,
            phantom: ::std::marker::PhantomData
        }
    }
pub fn new ( cfg : & config :: Config , dir : & str ) -> HashIndex < T > { let dir = & cfg . root . clone ( ) . join ( dir ) ; let is_new = ! dir . exists ( ) ; let mut fileset = FlatFileSet :: new ( dir , " " , FILE_SIZE , MAX_CONTENT_SIZE ) ; let hash_root_fileptr = if is_new { // allocate space for root hash table fileset . alloc_write_space ( mem :: size_of :: < [ IndexPtr ; HASH_ROOT_COUNT ] > ( ) as u64 ) } else { // hash root must have been the first thing written IndexPtr :: new ( 0 , super :: flatfile :: INITIAL_WRITEPOS ) } ; // and keep a reference to it let hash_root_ref : & ' static [ IndexPtr ; HASH_ROOT_COUNT ] = fileset . read_fixed ( hash_root_fileptr ) ; HashIndex { fileset : fileset , hash_index_root : hash_root_ref , phantom : :: std :: marker :: PhantomData } }
Opens the hash_index at the location given in the config
Creates a new fileset if needed
Opens the hash_index at the location given in the config Creates a new fileset if needed
cfg
&config::Config
dir
&str
cfg
&config::Config
dir
&str