示例#1
0
    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));
    }
示例#2
0
        private bool CheckIfNameIsValid(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(false);
            }

            var newFullPath = _pathService.Combine(_directoryPath, name);

            return(!_fileService.CheckIfExists(newFullPath) && !_directoryService.CheckIfExists(newFullPath));
        }
示例#3
0
 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));
        }
示例#5
0
        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));
        }
示例#6
0
 private void CreateOutputDirectoryIfNeeded(string destinationFile)
 {
     try
     {
         var outputDirectory = _pathService.GetParentDirectory(destinationFile);
         if (!_directoryService.CheckIfExists(outputDirectory))
         {
             _directoryService.Create(outputDirectory);
         }
     }
     catch
     {
         // ignore
     }
 }
示例#7
0
    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));
    }
示例#8
0
        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);
示例#10
0
 private bool CheckIfExists(string nodePath) =>
 _fileService.CheckIfExists(nodePath) || _directoryService.CheckIfExists(nodePath);
示例#11
0
        private bool IsNameAlreadyInUse(string name, string directory)
        {
            var fullPath = _pathService.Combine(directory, name);

            return(_fileService.CheckIfExists(fullPath) || _directoryService.CheckIfExists(fullPath));
        }
示例#12
0
 private bool CheckIfPathIsValid(string path) =>
 !string.IsNullOrWhiteSpace(path) &&
 !_fileService.CheckIfExists(path) &&
 !_directoryService.CheckIfExists(path);