Exemplo n.º 1
0
 private static void DeleteSingleFile([NotNull] FileEntry file, [NotNull] DirectoryState state)
 {
     if (file.IsOpen())
     {
         string path = file.PathFormatter.GetPath().GetText();
         state.SetError(ErrorFactory.System.FileIsInUse(path));
     }
     else if (file.Attributes.HasFlag(FileAttributes.ReadOnly))
     {
         state.SetError(ErrorFactory.System.UnauthorizedAccess(file.Name));
     }
     else
     {
         file.Parent.DeleteFile(file.Name, true);
         state.MarkHasWritten();
     }
 }
Exemplo n.º 2
0
        private static void DeleteSingleDirectory([NotNull] DirectoryEntry directory, [NotNull] DirectoryState state)
        {
            if (directory.Attributes.HasFlag(FileAttributes.ReadOnly))
            {
                string path = directory.PathFormatter.GetPath().GetText();
                state.SetError(ErrorFactory.System.AccessDenied(path));
            }

            if (state.CanBeDeleted)
            {
                directory.Parent?.DeleteDirectory(directory.Name);
            }
        }