Ejemplo n.º 1
0
 /// <exception cref="System.IO.IOException"/>
 internal virtual void Rename(PathData src, PathData target)
 {
     // the rename method with an option to delete the target is deprecated
     if (target.exists && !Delete(target.path, false))
     {
         // too bad we don't know why it failed
         PathIOException e = new PathIOException(target.ToString());
         e.SetOperation("delete");
         throw e;
     }
     if (!Rename(src.path, target.path))
     {
         // too bad we don't know why it failed
         PathIOException e = new PathIOException(src.ToString());
         e.SetOperation("rename");
         e.SetTargetPath(target.ToString());
         throw e;
     }
     // cancel delete on exit if rename is successful
     CancelDeleteOnExit(src.path);
 }
Ejemplo n.º 2
0
 /// <exception cref="System.IO.IOException"/>
 protected internal override void ProcessPathArgument(PathData src)
 {
     if (src.stat.IsDirectory() && src.fs.Equals(dst.fs))
     {
         PathData target  = GetTargetPath(src);
         string   srcPath = src.fs.MakeQualified(src.path).ToString();
         string   dstPath = dst.fs.MakeQualified(target.path).ToString();
         if (dstPath.Equals(srcPath))
         {
             PathIOException e = new PathIOException(src.ToString(), "are identical");
             e.SetTargetPath(dstPath.ToString());
             throw e;
         }
         if (dstPath.StartsWith(srcPath + Path.Separator))
         {
             PathIOException e = new PathIOException(src.ToString(), "is a subdirectory of itself"
                                                     );
             e.SetTargetPath(target.ToString());
             throw e;
         }
     }
     base.ProcessPathArgument(src);
 }