예제 #1
0
        /// <summary>
        ///     Create a new GhostscriptJob instance
        /// </summary>
        /// <param name="jobInfo">JobInfo of the job to convert</param>
        /// <param name="profile">Profile that determines the conversion process</param>
        /// <param name="tempFolder">
        ///     TempFolderProvider that gives the full Temp path, i.e. C:\Users\Admin\Local
        ///     Settings\Temp\clawPDF
        /// </param>
        /// <param name="jobTranslations">Translations needed for the job</param>
        /// <param name="fileWrap">Only for testing</param>
        /// <param name="directoryWrap">Only for testing</param>
        public GhostscriptJob(IJobInfo jobInfo, ConversionProfile profile, JobTranslations jobTranslations,
                              ITempFolderProvider tempFolder, IFile fileWrap, IDirectory directoryWrap)
            : base(jobInfo, profile, jobTranslations, fileWrap, directoryWrap)
        {
            var gsVersion = new GhostscriptDiscovery().GetBestGhostscriptInstance();

            if (gsVersion == null)
            {
                Logger.Error("No valid Ghostscript version found.");
                throw new InvalidOperationException("No valid Ghostscript version found.");
            }

            Logger.Debug("Ghostscript Version: " + gsVersion.Version + " loaded from " + gsVersion.DllPath);
            _ghostScript = new GhostScript(gsVersion);

            JobTempFolder = PathSafe.Combine(tempFolder.TempFolder,
                                             "Job_" + PathSafe.GetFileNameWithoutExtension(PathSafe.GetRandomFileName()));
            JobTempOutputFolder = PathSafe.Combine(JobTempFolder, "tempoutput");
            DirectoryWrap.CreateDirectory(JobTempFolder);
            DirectoryWrap.CreateDirectory(JobTempOutputFolder);

            // Shorten the temp folder for GS compatibility
            //缩短临时文件夹以实现GS兼容性
            JobTempFolder = JobTempFolder;
        }
예제 #2
0
        /// <summary>
        /// Checks for the existence of the given path on the filesystem and attempts to create it if not present.
        /// </summary>
        /// <param name="directoryPath">The path to check</param>
        public void CreateDirectoryIfNotExists(string directoryPath)
        {
            DirectoryWrap directory = new DirectoryWrap();

            if (!directory.Exists(directoryPath))
            {
                directory.CreateDirectory(directoryPath);
            }
        }
예제 #3
0
        public void CreateDirectory_MoveTo()
        {
            //arange
            IDirectory directory = new DirectoryWrap(); // should create this somewhere and inject into you method for later mocking
            var        source    = Path.GetRandomFileName();
            var        target    = Path.GetRandomFileName();

            //act
            IDirectoryInfo info = directory.CreateDirectory(source);

            info.MoveTo(target);

            //assert
            Assert.IsTrue(info.Exists);

            // clean
            info.Delete();
        }