예제 #1
0
 private void CheckDirDoesNotExist(MountFilePath file)
 {
     if (file.Mount.Exists(file.Path) && file.Mount.IsDir(file.Path))
     {
         throw new IOException(string.Format("Directory {0} already exists", file.GetGlobalPath()));
     }
 }
예제 #2
0
 private void CheckEitherDoesNotExist(MountFilePath file)
 {
     if (file.Mount.Exists(file.Path))
     {
         throw new IOException(string.Format("Path {0} already exists", file.GetGlobalPath()));
     }
 }
예제 #3
0
 private void CheckDirExists(MountFilePath file)
 {
     if (!file.Mount.Exists(file.Path) || !file.Mount.IsDir(file.Path))
     {
         throw new FileNotFoundException(string.Format("No such directory: {0}", file.GetGlobalPath()));
     }
 }
예제 #4
0
 private void CheckEitherExists(MountFilePath file)
 {
     if (!file.Mount.Exists(file.Path))
     {
         throw new FileNotFoundException(string.Format("No such path: {0}", file.GetGlobalPath()));
     }
 }
예제 #5
0
 private void CheckWritable(MountFilePath file)
 {
     if (file.WritableMount == null)
     {
         throw new IOException(string.Format("Access Denied: Mount {0} is read only", file.Mount.Name));
     }
 }
예제 #6
0
 private void CheckConnected(MountFilePath file)
 {
     if (!file.LuaMount.Connected)
     {
         throw new IOException(string.Format("Access Denied: Mount {0} is disconnected", file.Mount.Name));
     }
 }
예제 #7
0
 private void CheckPathsNotOverlapping(MountFilePath src, MountFilePath dst)
 {
     if (src.Mount == dst.Mount)
     {
         if (src.Path.IsParentOf(dst.Path) || dst.Path.IsParentOf(src.Path))
         {
             throw new IOException(string.Format("Cannot move or copy path {0} inside itself", src.GetGlobalPath()));
         }
     }
 }
예제 #8
0
 private void CopyRecursive(MountFilePath src, MountFilePath dst)
 {
     if (src.Mount.IsDir(src.Path))
     {
         dst.WritableMount.MakeDir(dst.Path);
         foreach (var file in src.Mount.List(src.Path))
         {
             CopyRecursive(
                 new MountFilePath(src.MountInfo, FilePath.Combine(src.Path, file)),
                 new MountFilePath(dst.MountInfo, FilePath.Combine(dst.Path, file))
                 );
         }
     }
     else
     {
         using (var reader = src.Mount.OpenForBinaryRead(src.Path))
         {
             using (var writer = dst.WritableMount.OpenForBinaryWrite(dst.Path, false))
             {
                 reader.CopyTo(writer);
             }
         }
     }
 }
예제 #9
0
 private void RecordWrite(MountFilePath file)
 {
     file.MountInfo.LastWriteTime = DateTime.Now;
 }
예제 #10
0
 private void RecordRead(MountFilePath file)
 {
     file.MountInfo.LastReadTime = DateTime.Now;
 }
예제 #11
0
 private void CheckParentDirExists(MountFilePath file)
 {
     CheckDirExists(new MountFilePath(file.MountInfo, file.Path.GetDir()));
 }