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)); }
protected override async Task WriteMetaDataAsync(IDictionary <string, string> files, string trashCanLocation) { var deleteTime = _environmentService.Now; foreach (var(originalFilePath, trashCanFilePath) in files) { var metadataBytes = GetMetadataBytes(originalFilePath, trashCanFilePath, deleteTime); var metadataFileName = _pathService.GetFileName(trashCanFilePath).Replace(FilePrefix, MetadataPrefix); var metadataPath = _pathService.Combine(trashCanLocation, metadataFileName); await _fileService.WriteBytesAsync(metadataPath, metadataBytes); } }
public async Task DownloadNewPodcasts(string targetDirectoryPath, string fileFormat, DateTime stopDateTime) { _loggerService.Info("Started loading podcasts info"); var podcasts = await _podcastService.GetNewPodcasts(stopDateTime); _loggerService.Info("Finished loading podcasts info"); foreach (var podcast in podcasts) { var fileName = string.Format(fileFormat, podcast.Name, podcast.Date); var filePath = _pathService.Combine(targetDirectoryPath, fileName); if (!_fileService.Exists(filePath)) { var bytes = await _httpClientService.GetByteArrayAsync(podcast.DownloadLink); await _fileService.WriteAllBytes(filePath, bytes); _loggerService.Info($"Downloaded {fileName}"); } } }
private string GetOutputFilePath(string archivePath, string outputDirectory) { var archiveFileName = _pathService.GetFileNameWithoutExtension(archivePath); var outputFilePath = _pathService.Combine(outputDirectory, archiveFileName); return(_fileNameGenerationService.GenerateFullName(outputFilePath)); }
protected override async Task WriteMetaDataAsync(IReadOnlyDictionary <string, string> filePathsDictionary, string trashCanLocation) { var deleteTime = _dateTimeProvider.Now; foreach (var(originalFilePath, trashCanFilePath) in filePathsDictionary) { var fileSize = _fileSizesDictionary.ContainsKey(originalFilePath) ? _fileSizesDictionary[originalFilePath] : 0; var metadataBytes = GetMetadataBytes(originalFilePath, fileSize, deleteTime); var metadataFileName = _pathService .GetFileName(trashCanFilePath) .Replace(FilePrefix, MetadataPrefix); var metadataPath = _pathService.Combine(trashCanLocation, metadataFileName); await _fileService.WriteBytesAsync(metadataPath, metadataBytes); } }
public ITempFile Create(string tempFolder) { if (string.IsNullOrWhiteSpace(tempFolder)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(tempFolder)); } return(new TempFile( _pathService.Combine(tempFolder, _guidFactory.NewAsString()), _fileService)); }
private bool CheckIfNameIsValid(string name) { if (string.IsNullOrWhiteSpace(name)) { return(false); } var newFullPath = _pathService.Combine(_directoryPath, name); return(!_fileService.CheckIfExists(newFullPath) && !_directoryService.CheckIfExists(newFullPath)); }
private void Rename() { var destinationDirectory = _pathService.GetParentDirectory(OriginalFileViewModel.FullPath); var destinationFilePath = _pathService.Combine(destinationDirectory, NewFileName); var options = OperationContinuationOptions.CreateRenamingContinuationOptions( ReplaceWithFileViewModel.FullPath, ShouldApplyToAll, destinationFilePath ); Close(options); }
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); }
protected override string GetUniqueFilePath(string fileName, HashSet <string> filesNamesSet, string directory) { var filePath = _pathService.Combine(directory, fileName); if (!filesNamesSet.Contains(filePath) && !CheckIfExists(filePath)) { return(filePath); } string result; var i = 1; do { var newFileName = $"{fileName} ({i})"; result = _pathService.Combine(directory, newFileName); i++; } while (filesNamesSet.Contains(result) || CheckIfExists(result)); return(result); }
protected override string GetUniqueFilePath(string file, HashSet <string> filesSet, string directory) { // TODO: move to move operation var filePath = _pathService.Combine(directory, _pathService.GetFileName(file)); if (!filesSet.Contains(filePath)) { return(filePath); } var fileName = _pathService.GetFileName(file); string result; var i = 1; do { var newFileName = $"{fileName} ({i})"; result = _pathService.Combine(directory, newFileName); i++; } while (filesSet.Contains(result) || _fileService.CheckIfExists(result)); return(result); }
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 static IList <Package> GetIncludedPackages(Config config) { var packages = config.Packages .Where(x => x.Include == true) .ToList(); foreach (var package in packages) { var packageBasePath = _pathService.Combine(config.SourceBasePath, package.Path); if (Directory.Exists(packageBasePath) == false) { throw new Exception($"Package [{package.Path}] base path [{packageBasePath}] is missing, check your configuration."); } } return(packages); }
public IKernel Load(IKernel kernel) { var executableLocation = _assemblyService.GetEntryAssembly().Location; var additionalPluginsPath = _pathService.Combine(_pathService.GetDirectoryName(executableLocation), "Plugins"); if (!_directoryService.Exists(additionalPluginsPath)) { _directoryService.CreateDirectory(additionalPluginsPath); } kernel.Bind(x => x .FromAssembliesInPath(additionalPluginsPath) .SelectAllClasses() .InheritedFrom <IPlugin>() .BindDefaultInterfaces() .Configure(y => y.InTransientScope())); return(kernel); }
private void bindAdditionalPlugins() { _assemblyService = _kernel.Get <IAssemblyService>(); _directoryService = _kernel.Get <IDirectoryService>(); _pathService = _kernel.Get <IPathService>(); var executableLocation = _assemblyService.GetEntryAssembly().Location; var additionalPluginsPath = _pathService.Combine(_pathService.GetDirectoryName(executableLocation), "Plugins"); if (!_directoryService.Exists(additionalPluginsPath)) { _directoryService.CreateDirectory(additionalPluginsPath); } _kernel.Bind(x => x .FromAssembliesInPath(additionalPluginsPath) .SelectAllClasses() .InheritedFrom <IPlugin>() .BindDefaultInterfaces() .Configure(y => y.InTransientScope())); }
private async Task PackAsync() { var selectedNodes = _nodesSelectionService .SelectedNodes .ToArray(); if (!selectedNodes.Any()) { return; } var defaultPath = _pathService.Combine(_directoryService.SelectedDirectory, selectedNodes.First()); var parameter = new CreateArchiveNavigationParameter(defaultPath, selectedNodes.Length == 1); var dialogResult = await _dialogService.ShowDialogAsync <CreateArchiveDialogResult, CreateArchiveNavigationParameter>( nameof(CreateArchiveDialogViewModel), parameter); if (dialogResult is null) { return; } await _archiveService.PackAsync(selectedNodes, dialogResult.ArchivePath, dialogResult.ArchiveType); }
private string GetFullPath() => _pathService.Combine(_directory, NodeName);
public void CreateDirectory(string sourceDirectory, string directoryName) { var fullPath = _pathService.Combine(sourceDirectory, directoryName); _directoryService.CreateDirectory(fullPath); }
public RolesPermissionsAdminService( DataBaseConnection db, IPathService pathService) : base(db) { RolesSchemaPath = pathService.Combine(PathNames.ResourcesDirName, RolesSchemaFileName); }
public void TestPathCombine() { var path = _pathService.Combine(Directory, File); Assert.Equal(FullPath, path); }
private bool IsNameAlreadyInUse(string name, string directory) { var fullPath = _pathService.Combine(directory, name); return(_fileService.CheckIfExists(fullPath) || _directoryService.CheckIfExists(fullPath)); }
protected override string GetFilesTrashCanLocation(string trashCanLocation) => _pathService.Combine(trashCanLocation, "files");
private string GetDestinationFilePath() { var destinationDirectory = _pathService.GetParentDirectory(OriginalFileViewModel.FullPath); return(_pathService.Combine(destinationDirectory, NewFileName)); }