protected override void ExecuteAction(IFileActionInfo fileActionInfo) { SourceFileInfo info = (SourceFileInfo)fileActionInfo; Check(info); Directory.CreateDirectory(info.SourceFileName); }
protected override void RollbackAction(IFileActionInfo fileActionInfo) { SourceFileInfo info = (SourceFileInfo)fileActionInfo; if (Directory.Exists(info.SourceFileName)) { Directory.Delete(info.SourceFileName, true); } }
private void onCompletedFile(object sender, ICSharpCode.SharpZipLib.Core.ScanEventArgs e) { string fileName = e.Name; SourceFileInfo file = new SourceFileInfo(System.IO.Path.Combine((_fileActionInfo as SourceTargetFilterFileInfo).TargetPath, fileName.Replace('/', System.IO.Path.DirectorySeparatorChar))); files.Add(file); _isExecuted = true; int pos = fileName.LastIndexOf('/'); string path = ""; if (pos > 0 && pathDepth(fileName) <= 1) { path = fileName.Substring(0, pos + 1); if (!directories.ContainsKey(path)) { directories.Add(path, new SourceFileInfo(System.IO.Path.Combine((_fileActionInfo as SourceTargetFilterFileInfo).TargetPath, path.Replace('/', System.IO.Path.DirectorySeparatorChar)))); } } }
private static void Check(SourceFileInfo info) { // TODO: write normal checking if (File.Exists(info.SourceFileName) || Directory.Exists(info.SourceFileName)) { throw new FileAlreadyExistException(info.SourceFileName); } string rootDirectoryPath = ""; if (info.SourceFileName.Contains(Path.DirectorySeparatorChar.ToString())) { rootDirectoryPath = info.SourceFileName.Substring(0, info.SourceFileName.LastIndexOf(Path.DirectorySeparatorChar)); } UserFileAccessRightsChecker directoryChecker = new UserFileAccessRightsChecker(rootDirectoryPath); if (!directoryChecker.CanCreateDirectories()) { throw new AccessDeniedException(info.SourceFileName); } }
public CreateDirectoryAction(string directoryPath) { _fileActionInfo = new SourceFileInfo(directoryPath); }