public virtual void TestWithCustomString() { PathIOException pe = new PathIOException(path, error); Assert.Equal(new Path(path), pe.GetPath()); Assert.Equal("`" + path + "': " + error, pe.Message); }
public virtual void TestWithDefaultString() { PathIOException pe = new PathIOException(path); Assert.Equal(new Path(path), pe.GetPath()); Assert.Equal("`" + path + "': Input/output error", pe.Message); }
public virtual void TestWithThrowable() { IOException ioe = new IOException("KABOOM"); PathIOException pe = new PathIOException(path, ioe); Assert.Equal(new Path(path), pe.GetPath()); Assert.Equal("`" + path + "': Input/output error: " + error, pe .Message); }
/// <exception cref="System.IO.IOException"/> protected internal override void PostProcessPath(PathData src) { if (!src.fs.Delete(src.path, false)) { // we have no way to know the actual error... PathIOException e = new PathIOException(src.ToString()); e.SetOperation("remove"); throw e; } }
public virtual void TestRemoteExceptionUnwrap() { PathIOException pe; RemoteException re; IOException ie; pe = new PathIOException(path); re = new RemoteException(typeof(PathIOException).FullName, "test constructor1"); ie = re.UnwrapRemoteException(); Assert.True(ie is PathIOException); ie = re.UnwrapRemoteException(typeof(PathIOException)); Assert.True(ie is PathIOException); pe = new PathIOException(path, "constructor2"); re = new RemoteException(typeof(PathIOException).FullName, "test constructor2"); ie = re.UnwrapRemoteException(); Assert.True(ie is PathIOException); ie = re.UnwrapRemoteException(typeof(PathIOException)); Assert.True(ie is PathIOException); }
/// <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); }
/// <exception cref="System.IO.IOException"/> protected internal override void RecursePath(PathData src) { PathData savedDst = dst; try { // modify dst as we descend to append the basename of the // current directory being processed dst = GetTargetPath(src); bool preserveRawXattrs = CheckPathsForReservedRaw(src.path, dst.path); if (dst.exists) { if (!dst.stat.IsDirectory()) { throw new PathIsNotDirectoryException(dst.ToString()); } } else { if (!dst.fs.Mkdirs(dst.path)) { // too bad we have no clue what failed PathIOException e = new PathIOException(dst.ToString()); e.SetOperation("mkdir"); throw e; } dst.RefreshStatus(); } // need to update stat to know it exists now base.RecursePath(src); if (dst.stat.IsDirectory()) { PreserveAttributes(src, dst, preserveRawXattrs); } } finally { dst = savedDst; } }
/// <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); }
/// <summary>Build an exception from any other Path IO Exception.</summary> /// <remarks> /// Build an exception from any other Path IO Exception. /// This propagates the path of the original exception /// </remarks> /// <param name="message">more specific text</param> /// <param name="cause">cause</param> public RegistryIOException(string message, PathIOException cause) : base(cause.GetPath() != null ? cause.GetPath().ToString() : string.Empty, message , cause) { }
public NoPathPermissionsException(string message, PathIOException cause) : base(message, cause) { }