private string GenerateByInitialName(string filePath, string initialName) { var directory = _pathService.GetParentDirectory(filePath); var newName = GenerateName(initialName, directory); return(_pathService.Combine(directory, newName)); }
public string GenerateFullName(string filePath) { var initialName = _pathService.GetFileName(filePath); var directory = _pathService.GetParentDirectory(filePath); var newName = GenerateName(initialName, directory); return(_pathService.Combine(directory, newName)); }
public override void Activate(OverwriteOptionsNavigationParameter parameter) { var sourceFileModel = _fileService.GetFile(parameter.SourceFilePath); ReplaceWithFileViewModel = CreateFrom(sourceFileModel); var destinationFileModel = _fileService.GetFile(parameter.DestinationFilePath); OriginalFileViewModel = CreateFrom(destinationFileModel); var destinationDirectory = _pathService.GetParentDirectory(destinationFileModel.FullPath); NewFileName = _fileNameGenerationService.GenerateName(sourceFileModel.Name, destinationDirectory); DestinationDirectoryName = _pathService.GetFileName(destinationDirectory); AreMultipleFilesAvailable = parameter.AreMultipleFilesAvailable; }
public ISuggestedPathViewModel Create(string searchText, SuggestionModel model) { var root = _pathService.GetParentDirectory(searchText); var relativePath = _pathService.GetRelativePath(root, model.FullPath); var text = _pathService.LeftTrimPathSeparators(relativePath); var type = CreateFrom(model.Type); return(new SuggestedPathViewModel(model.FullPath, type, text)); }
private void CreateOutputDirectoryIfNeeded(string outputFilePath) { var outputDirectory = _pathService.GetParentDirectory(outputFilePath); if (!_directoryService.CheckIfExists(outputDirectory)) { _directoryService.Create(outputDirectory); } }
private PackOperationSettings GetPackOperationSettings(IReadOnlyList <string> nodes, string outputFilePath, ArchiveType archiveType) { var(files, directories) = Split(nodes); var sourceDirectory = _pathService.GetCommonRootDirectory(nodes); var targetDirectory = _pathService.GetParentDirectory(outputFilePath); return(new PackOperationSettings(directories, files, outputFilePath, sourceDirectory, targetDirectory, archiveType)); }
private void SetupMainTab(FileModel fileModel) { MainNodeInfoTabViewModel.Name = fileModel.Name; MainNodeInfoTabViewModel.Path = _pathService.GetParentDirectory(fileModel.FullPath); MainNodeInfoTabViewModel.Size = fileModel.SizeBytes; MainNodeInfoTabViewModel.CreatedDateTime = fileModel.CreatedDateTime; MainNodeInfoTabViewModel.LastWriteDateTime = fileModel.LastModifiedDateTime; MainNodeInfoTabViewModel.LastAccessDateTime = fileModel.LastAccessDateTime; }
private IEnumerable <string> GetChildDirectories(string substring) { var parentDirectory = _pathService.GetParentDirectory(substring); return(parentDirectory is null || !_directoryService.CheckIfExists(parentDirectory) ? Enumerable.Empty <string>() : _directoryService .GetChildDirectories(parentDirectory) .Select(d => d.FullPath)); }
private void SetupMainTab(DirectoryModel directoryModel) { LoadDirectorySize(directoryModel.FullPath); MainNodeInfoTabViewModel.Name = directoryModel.Name; MainNodeInfoTabViewModel.Path = _pathService.GetParentDirectory(directoryModel.FullPath); MainNodeInfoTabViewModel.CreatedDateTime = directoryModel.CreatedDateTime; MainNodeInfoTabViewModel.LastWriteDateTime = directoryModel.LastModifiedDateTime; MainNodeInfoTabViewModel.LastAccessDateTime = directoryModel.LastAccessDateTime; }
public void Rename(string filePath, string newName) { var parentDirectory = _pathService.GetParentDirectory(filePath); var newFilePath = _pathService.Combine(parentDirectory, newName); if (filePath == newFilePath) { return; } File.Move(filePath, newFilePath); }
public async Task ExtractAsync(string archivePath, string outputDirectory = null) { if (!CheckIfNodeIsArchive(archivePath)) { throw new InvalidOperationException($"{archivePath} is not an archive!"); } outputDirectory ??= _pathService.GetParentDirectory(archivePath); // ReSharper disable once PossibleInvalidOperationException var archiveType = _archiveTypeMapper.GetArchiveTypeFrom(archivePath).Value; await _operationsService.ExtractAsync(archivePath, outputDirectory, archiveType); }
private void CreateOutputDirectoryIfNeeded(string destinationFile) { try { var outputDirectory = _pathService.GetParentDirectory(destinationFile); if (!_directoryService.CheckIfExists(outputDirectory)) { _directoryService.Create(outputDirectory); } } catch { // ignore } }
public bool Rename(string filePath, string newName) { var parentDirectory = _pathService.GetParentDirectory(filePath); var newFilePath = _pathService.Combine(parentDirectory, newName); try { _environmentFileService.Move(filePath, newFilePath); } catch { return(false); } return(true); }
public bool Rename(string filePath, string newName) { var parentDirectory = _pathService.GetParentDirectory(filePath); var newFilePath = _pathService.Combine(parentDirectory, newName); try { _environmentFileService.Move(filePath, newFilePath); } catch (Exception ex) { _logger.LogError($"Failed to rename file {filePath} to {newName} with error {ex}"); return(false); } return(true); }
private string ExtractDirectory(string fullPath) => _directoryService.CheckIfExists(fullPath) ? fullPath : _pathService.GetParentDirectory(fullPath);
public override void Activate(RenameNodeNavigationParameter parameter) { _directory = _pathService.GetParentDirectory(parameter.NodePath); NodeName = _pathService.GetFileName(parameter.NodePath); }