public string ComposeTargetFileName(Job job) { if (!string.IsNullOrWhiteSpace(job.JobInfo.OutputFileParameter)) { if (_pathUtil.IsValidRootedPath(job.JobInfo.OutputFileParameter)) { return(job.JobInfo.OutputFileParameter); } } var tr = job.TokenReplacer; var outputFolder = ValidName.MakeValidFolderName(tr.ReplaceTokens(job.Profile.TargetDirectory)); var fileName = ComposeOutputFilename(job); var filePath = _pathSafe.Combine(outputFolder, fileName); if (!job.Profile.AutoSave.Enabled) { return(filePath); } try { filePath = _pathUtil.EllipsisForTooLongPath(filePath); _logger.Debug("FilePath after ellipsis: " + filePath); } catch (ArgumentException) { throw new WorkflowException("Filepath is only a directory or the directory itself is already too long to append a usefull filename under the limits of Windows (max " + _pathUtil.MAX_PATH + " characters): " + filePath); } return(filePath); }
public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { var convertedValue = base.Convert(values, targetType, parameter, culture) as string; var validName = new ValidName(); return(validName.MakeValidFolderName(convertedValue)); }
public string ComposeScriptPath(string path, TokenReplacer tokenReplacer) { var validName = new ValidName(); var composedPath = tokenReplacer.ReplaceTokens(path); composedPath = validName.MakeValidFolderName(composedPath); return(composedPath); }
private string CreateTargetDirectory(Job job) { var validName = new ValidName(); var saveDirectory = validName.MakeValidFolderName(job.TokenReplacer.ReplaceTokens(job.Profile.SaveDialog.Folder)); var directoryHelper = new DirectoryHelper(saveDirectory); job.OnJobCompleted += (obj, sender) => directoryHelper.DeleteCreatedDirectories(); if (directoryHelper.CreateDirectory()) { _logger.Debug("Set directory in save file dialog: " + saveDirectory); return(saveDirectory); } _logger.Warn("Could not create directory for save file dialog. It will be opened with default save location."); return(""); }
public string ComposeTargetFileName(Job job) { var tr = job.TokenReplacer; var validName = new ValidName(); var outputFolder = validName.MakeValidFolderName(tr.ReplaceTokens(job.Profile.TargetDirectory)); var filePath = Path.Combine(outputFolder, _outputFilenameComposer.ComposeOutputFilename(job)); try { filePath = _pathUtil.EllipsisForTooLongPath(filePath); _logger.Debug("FilePath after ellipsis: " + filePath); } catch (ArgumentException) { throw new WorkflowException("Autosave filepath is only a directory or the directory itself is already too long to append a filename under the limits of Windows (max " + _pathUtil.MAX_PATH + " characters): " + filePath); } return(filePath); }
private string ComposeOutputFolder(Job job) { var outputFolder = ValidName.MakeValidFolderName(job.TokenReplacer.ReplaceTokens(job.Profile.TargetDirectory)); //Consider LastSaveDirectory if (!job.Profile.AutoSave.Enabled) { outputFolder = ConsiderLastSaveDirectory(outputFolder, job); } // MyDocuments folder as fallback for interactive if (!job.Profile.AutoSave.Enabled && !job.Profile.SaveFileTemporary) { if (string.IsNullOrWhiteSpace(outputFolder)) { outputFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } } return(outputFolder); }
public void MakeValidFolderName_GivenValidFolder_ReturnsSameString() { const string filename = @"C:\Some _ !Folder,"; Assert.AreEqual(filename, ValidName.MakeValidFolderName(filename)); }
public void MakeValidFolderName_GivenMisplacedColon_ReturnsSanitizedString() { Assert.AreEqual(@"C:\Some_Folder", ValidName.MakeValidFolderName(@"C:\Some:Folder")); }
public void MakeValidFolderName_GivenInvalidFolder_ReturnsSanitizedString() { Assert.AreEqual(@"C:\Some _ Folder", ValidName.MakeValidFolderName(@"C:\Some | Folder")); }
private string PreviewForFolder(string s) { var validName = new ValidName(); return(validName.MakeValidFolderName(_tokenReplacer.ReplaceTokens(s))); }
private string PreviewForFolder(string s) { return(ValidName.MakeValidFolderName(_tokenReplacer.ReplaceTokens(s))); }