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 bool CheckIfNameIsValid(string name) { if (string.IsNullOrWhiteSpace(name)) { return(false); } var newFullPath = _pathService.Combine(_directoryPath, name); return(!_fileService.CheckIfExists(newFullPath) && !_directoryService.CheckIfExists(newFullPath)); }
public void Rename(string path, string newName) { if (_fileService.CheckIfExists(path)) { _fileService.Rename(path, newName); } else if (_directoryService.CheckIfExists(path)) { _directoryService.Rename(path, newName); } }
private bool CheckIfNameIsValid(string name) { if (string.IsNullOrWhiteSpace(name)) { return(false); } var fullPath = GetFullPath(); return(!_fileService.CheckIfExists(fullPath) && !_directoryService.CheckIfExists(fullPath)); }
protected override async Task WriteMetaDataAsync(IDictionary <string, string> files, string trashCanLocation) { var infoTrashCanLocation = GetInfoTrashCanLocation(trashCanLocation); if (!_directoryService.CheckIfExists(infoTrashCanLocation)) { _directoryService.Create(infoTrashCanLocation); } var deleteTime = _environmentService.Now; await files.Values.ForEachAsync(f => WriteMetaDataAsync(f, infoTrashCanLocation, deleteTime)); }
private void CreateOutputDirectoryIfNeeded(string destinationFile) { try { var outputDirectory = _pathService.GetParentDirectory(destinationFile); if (!_directoryService.CheckIfExists(outputDirectory)) { _directoryService.Create(outputDirectory); } } catch { // ignore } }
protected override async Task WriteMetaDataAsync(IReadOnlyDictionary <string, string> filePathsDictionary, string trashCanLocation) { var infoTrashCanLocation = GetInfoTrashCanLocation(trashCanLocation); if (!_directoryService.CheckIfExists(infoTrashCanLocation)) { _directoryService.Create(infoTrashCanLocation); } var deleteTime = _dateTimeProvider.Now; await filePathsDictionary.ForEachAsync(kvp => WriteMetaDataAsync(kvp.Key, kvp.Value, infoTrashCanLocation, deleteTime)); }
public IFileSystemNodeViewModel Create(string path) { if (_fileService.CheckIfExists(path)) { var fileModel = _fileService.GetFile(path); return(fileModel is null ? null : Create(fileModel)); } if (_directoryService.CheckIfExists(path)) { var directoryModel = _directoryService.GetDirectory(path); return(directoryModel is null ? null : Create(directoryModel, false)); } return(null); }
private string ExtractDirectory(string fullPath) => _directoryService.CheckIfExists(fullPath) ? fullPath : _pathService.GetParentDirectory(fullPath);
private bool CheckIfExists(string nodePath) => _fileService.CheckIfExists(nodePath) || _directoryService.CheckIfExists(nodePath);
private bool IsNameAlreadyInUse(string name, string directory) { var fullPath = _pathService.Combine(directory, name); return(_fileService.CheckIfExists(fullPath) || _directoryService.CheckIfExists(fullPath)); }
private bool CheckIfPathIsValid(string path) => !string.IsNullOrWhiteSpace(path) && !_fileService.CheckIfExists(path) && !_directoryService.CheckIfExists(path);