示例#1
0
 public void AddDirStore(DirStore store)
 {
     if (children.Count < branchingFactor)
     {
         children.Add(store);
         string oldPath = store.GetPath();
         store.parent = this;
         string newPath = store.GetPath();
         try
         {
             Directory.Move(oldPath, newPath);
         }
         catch
         {
             // For some reason, the above throws an access violation SOMETIMES.
             // I think this happens when the directory was just created.
             // Retrying the operation here seams to eliminate all problems.
             Directory.Move(oldPath, newPath);
         }
     }
     else
     {
         if (parent == null)
         {
             throw new DirStoreFullException();
         }
         else
         {
             DirStore prevStore = new DirStore(branchingFactor, basePath);
             prevStore.AddDirStore(store);
             parent.AddDirStore(prevStore);
         }
     }
 }
示例#2
0
 public void AddDirStore(DirStore store)
 {
     if (children.Count < branchingFactor)
     {
         children.Add(store);
         string oldPath = store.GetPath();
         store.parent = this;
         string newPath = store.GetPath();
         try
         {
             Directory.Move(oldPath, newPath);
         }
         catch
         {
             // For some reason, the above throws an access violation SOMETIMES.
             // I think this happens when the directory was just created.
             // Retrying the operation here seams to eliminate all problems.
             Directory.Move(oldPath, newPath);
         }
     }
     else
     {
         if (parent == null)
         {
             throw new DirStoreFullException();
         }
         else
         {
             DirStore prevStore = new DirStore(branchingFactor, basePath);
             prevStore.AddDirStore(store);
             parent.AddDirStore(prevStore);
         }
     }
 }
示例#3
0
 public void AddFile(string filepath)
 {
     if (IsSpaceAvailable())
     {
         root.AddFile(filepath, height - 1);
         numFiles += 1;
     }
     else
     {
         // No space is available in the current tree -- add a new level
         DirStore new_root = new DirStore(branchingFactor, basePath);
         new_root.AddDirStore(root);
         root    = new_root;
         height += 1;
         AddFile(filepath);
     }
 }
示例#4
0
 public void AddFile(string filepath)
 {
     if (IsSpaceAvailable())
     {
         root.AddFile(filepath, height - 1);
         numFiles += 1;
     }
     else
     {
         // No space is available in the current tree -- add a new level
         DirStore new_root = new DirStore(branchingFactor, basePath);
         new_root.AddDirStore(root);
         root = new_root;
         height += 1;
         AddFile(filepath);
     }
 }