public void TestReadFromDirectory() { var dir = TempFileManager.GetNewTempDirectory(); CreatePackageJson(Path.Combine(dir.FullName, "package.json"), PkgSimple); CheckPackage(PackageJsonFactory.Create(new DirectoryPackageJsonSource(dir.FullName))); }
public static async Task <Guid> ComputeSubtitle(string text) { FileContainer fileContainer = FileContainer.NewSubtitleContainer(); string outputfilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt"); if (!IsValidVTT(text)) { fileContainer.SubtitleFileItem.IpfsProcess.SetErrorMessage("Not a valid WEBVTT file", "Not a valid WEBVTT file"); return(fileContainer.ProgressToken); } try { await File.WriteAllTextAsync(outputfilePath, text); fileContainer.SubtitleFileItem.SetOutputFilePath(outputfilePath); IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem); } catch (Exception ex) { TempFileManager.SafeDeleteTempFile(outputfilePath); LogManager.AddSubtitleMessage(LogLevel.Critical, "Exception non gérée", "Exception", ex); return(fileContainer.ProgressToken); } return(fileContainer.ProgressToken); }
private static void Start() { daemon = Task.Run(() => { while (true) { Thread.Sleep(1000); FileItem fileItem; if (!queueFileItems.TryDequeue(out fileItem)) { continue; } CurrentPositionInQueue++; // Ipfs add file IpfsAddManager.Add(fileItem); // si tout est terminé, supprimer le fichier source if (!fileItem.FileContainer.WorkInProgress()) { TempFileManager.SafeDeleteTempFile(fileItem.FileContainer.SourceFileItem.FilePath); } if (!fileItem.IsSource) { // Supprimer le fichier attaché TempFileManager.SafeDeleteTempFile(fileItem.FilePath); } } }); }
public static async Task <Guid> ComputeSubtitle(string text) { FileContainer fileContainer = FileContainer.NewSubtitleContainer(); string outputfilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt"); if (!IsValidVTT(text)) { return(fileContainer.ProgressToken); } try { await System.IO.File.WriteAllTextAsync(outputfilePath, text); fileContainer.SubtitleFileItem.SetOutputFilePath(outputfilePath); IpfsDaemon.Instance.Queue(fileContainer.SubtitleFileItem); } catch (Exception ex) { TempFileManager.SafeDeleteTempFile(outputfilePath); LogManager.AddSubtitleMessage(ex.ToString(), "Exception"); return(fileContainer.ProgressToken); } return(fileContainer.ProgressToken); }
private FileItem(FileContainer fileContainer, string sourceFilePath, TypeFile typeFile) { FileContainer = fileContainer; FilesToDelete = new List <string>(); CreationDate = DateTime.UtcNow; SetSourceFilePath(sourceFilePath); TypeFile = typeFile; switch (typeFile) { case TypeFile.EncodedVideo: case TypeFile.SourceVideo: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".mp4")); break; case TypeFile.SpriteVideo: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".jpeg")); break; case TypeFile.SourceImage: case TypeFile.SnapImage: case TypeFile.OverlayImage: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".png")); break; case TypeFile.SubtitleText: SetTempFilePath(Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".vtt")); break; } }
public static string GetCurrentPicturePath() { if (State == NowState.Stop) { throw new VideoSourceDeviceNotWorking(); } else if (State == NowState.LocalCamera) { FormMain fm = FormMain.GetInstance(); TempFileManager _tempFileManager = TempFileManager.GetInstance(); Image tempImage = fm.GetVideoSourcePlayer().GetCurrentVideoFrame(); string tempPath = _tempFileManager.AddTempFile(tempImage); return(tempPath); } else if (State == NowState.TcpIp) { TcpIpFileManager _tcpIpFileManager = TcpIpFileManager.GetInstance(); return(_tcpIpFileManager.TcpIpFilePath); } else { //Never Reach throw new LogicErrorException(); } return(null); }
public static bool AudioVideoCpuEncoding(FileItem fileItem) { try { FileItem sourceFile = fileItem.FileContainer.SourceFileItem; LogManager.AddEncodingMessage("SourceFilePath " + Path.GetFileName(sourceFile.SourceFilePath) + " -> " + fileItem.VideoSize, "Start AudioVideoCpuEncoding"); fileItem.AudioVideoCpuEncodeProcess.StartProcessDateTime(); // Récupérer la durée totale de la vidéo et sa résolution, autorisation encoding if (!VideoSourceManager.SuccessAnalyseSource(sourceFile, false, fileItem.AudioVideoCpuEncodeProcess)) { return(false); } string size = GetSize(fileItem.VideoSize, sourceFile.VideoWidth.Value, sourceFile.VideoHeight.Value); string arguments = $"-y -i {Path.GetFileName(sourceFile.SourceFilePath)} -pixel_format yuv420p -vf scale={size} -vcodec libx264 -acodec aac -strict -2 {Path.GetFileName(fileItem.TempFilePath)}"; //-strict -2 pour forcer aac sur ubuntu var ffmpegProcessManager = new FfmpegProcessManager(fileItem, fileItem.AudioVideoCpuEncodeProcess); ffmpegProcessManager.StartProcess(arguments, VideoSettings.EncodeTimeout); fileItem.SetOutputFilePath(fileItem.TempFilePath); LogManager.AddEncodingMessage("OutputFileName " + Path.GetFileName(fileItem.OutputFilePath) + " / FileSize " + fileItem.FileSize + " / Format " + fileItem.VideoSize, "End AudioVideoCpuEncoding"); fileItem.AudioVideoCpuEncodeProcess.EndProcessDateTime(); return(true); } catch (Exception ex) { LogManager.AddEncodingMessage("Video Duration " + fileItem.VideoDuration + " / FileSize " + fileItem.FileSize + " / Progress " + fileItem.AudioVideoCpuEncodeProcess.Progress + " / Exception : " + ex, "Exception AudioVideoCpuEncoding"); fileItem.AudioVideoCpuEncodeProcess.SetErrorMessage("Exception"); TempFileManager.SafeDeleteTempFile(fileItem.TempFilePath); return(false); } }
public static bool AudioCpuEncoding(FileItem fileItem) { try { LogManager.AddEncodingMessage("SourceFilePath " + Path.GetFileName(fileItem.SourceFilePath), "Start AudioCpuEncoding"); fileItem.AudioCpuEncodeProcess.StartProcessDateTime(); // Récupérer la durée totale de la vidéo et sa résolution, autorisation encoding if (!VideoSourceManager.SuccessAnalyseSource(fileItem.FileContainer.SourceFileItem, false, fileItem.AudioCpuEncodeProcess)) { return(false); } // encoding audio de la source string arguments = $"-y -i {Path.GetFileName(fileItem.SourceFilePath)} -vcodec copy -acodec aac -strict -2 {Path.GetFileName(fileItem.TempFilePath)}"; var ffmpegProcessManager = new FfmpegProcessManager(fileItem, fileItem.AudioCpuEncodeProcess); ffmpegProcessManager.StartProcess(arguments, VideoSettings.EncodeTimeout); fileItem.SetVideoAacTempFilePath(fileItem.TempFilePath); LogManager.AddEncodingMessage("OutputFileName " + Path.GetFileName(fileItem.VideoAacTempFilePath) + " / FileSize " + fileItem.FileSize + " / Format " + fileItem.VideoSize, "End AudioCpuEncoding"); fileItem.AudioCpuEncodeProcess.EndProcessDateTime(); return(true); } catch (Exception ex) { LogManager.AddEncodingMessage("Video Duration " + fileItem.VideoDuration + " / FileSize " + fileItem.FileSize + " / Progress " + fileItem.AudioCpuEncodeProcess.Progress + " / Exception : " + ex, "Exception AudioCpuEncoding"); fileItem.AudioCpuEncodeProcess.SetErrorMessage("Exception"); TempFileManager.SafeDeleteTempFile(fileItem.TempFilePath); return(false); } }
private void OpenAsSqlFile() { var tempFileManager = new TempFileManager(); var tmpSqlFile = tempFileManager.GetTempFile(SqlText, "sql"); Process.Start(tmpSqlFile); }
/// <summary> /// Analizza l'email allegata al WI /// </summary> /// <param name="att"> /// il path del file temporaneo /// </param> /// <param name="wiid"> /// l'id del Work Item per la tracciatura degli errori /// </param> /// <returns> /// I dati della mail allegata al work item /// </returns> private MailReplyData GetMailData(string att, string wiid) { try { var strs = string.Empty; var result = new MailReplyData(); using (var rdr = new StreamReader(att)) { strs = rdr.ReadToEnd(); var rows = strs.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); rows = this.RemoveCodedRows(rows); result.From = this.GetFromAddress(rows, wiid); result.Subject = this.GetMailSubject(rows, wiid); } using (var f = File.OpenRead(att)) { result.Attachment = new byte[f.Length]; f.Read(result.Attachment, 0, result.Attachment.Length); } return(result); } catch (Exception ex) { throw ex; } finally { // faccio pulizia TempFileManager.ClearFile(att); } }
private static FileInfo WriteHumanReadable(IEnumerable <IApiNode> apiNodes, TempFileManager tempFileManager) { var outputFile = tempFileManager.GetNew(); new PublicApiWriter().WriteHumanReadable(apiNodes, outputFile, CancellationToken.None).Wait(); return(outputFile); }
public InstanceDll(string dllPath) { // copy the dll to a temp directory var path = TempFileManager.GetTempFilename(Path.GetFileNameWithoutExtension(dllPath), ".dll", false); File.Copy(dllPath, path, true); // try to locate dlls in the current directory (for libretro cores) // this isn't foolproof but it's a little better than nothing // setting PWD temporarily doesn't work. that'd be ideal since it supposedly gets searched early on, // but i guess not with SetDllDirectory in effect var envpath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process); try { var envpath_new = $"{Path.GetDirectoryName(path)};{envpath}"; Environment.SetEnvironmentVariable("PATH", envpath_new, EnvironmentVariableTarget.Process); HModule = OSTailoredCode.LinkedLibManager.LoadOrThrow(path); // consider using LoadLibraryEx instead of shenanigans? var newfname = TempFileManager.RenameTempFilenameForDelete(path); File.Move(path, newfname); } catch { // ignored } Environment.SetEnvironmentVariable("PATH", envpath, EnvironmentVariableTarget.Process); }
public static bool AudioCpuEncoding(FileItem fileItem) { try { LogManager.AddEncodingMessage(LogLevel.Information, "SourceFilePath " + Path.GetFileName(fileItem.SourceFilePath), "Start AudioCpuEncoding"); fileItem.AudioCpuEncodeProcess.StartProcessDateTime(); if (fileItem.FileContainer.SourceFileItem.AudioCodec == "aac") { fileItem.AudioCpuEncodeProcess.StartProcessDateTime(); File.Copy(fileItem.SourceFilePath, fileItem.TempFilePath); } else { // encoding audio de la source string arguments = $"-y -i {Path.GetFileName(fileItem.SourceFilePath)} -vcodec copy -acodec aac -strict -2 {Path.GetFileName(fileItem.TempFilePath)}"; var ffmpegProcessManager = new FfmpegProcessManager(fileItem, fileItem.AudioCpuEncodeProcess); ffmpegProcessManager.StartProcess(arguments, VideoSettings.Instance.EncodeTimeout); } fileItem.SetVideoAacTempFilePath(fileItem.TempFilePath); LogManager.AddEncodingMessage(LogLevel.Information, "OutputFileName " + Path.GetFileName(fileItem.VideoAacTempFilePath) + " / FileSize " + fileItem.FileSize + " / Format " + fileItem.VideoSize, "End AudioCpuEncoding"); fileItem.AudioCpuEncodeProcess.EndProcessDateTime(); return(true); } catch (Exception ex) { string message = "Exception AudioCpuEncoding : Video Duration " + fileItem.VideoDuration + " / FileSize " + fileItem.FileSize + " / Progress " + fileItem.AudioCpuEncodeProcess.Progress; fileItem.AudioCpuEncodeProcess.SetErrorMessage("Exception non gérée", message, ex); TempFileManager.SafeDeleteTempFile(fileItem.TempFilePath); return(false); } }
public void FilesListTest() { using var tfm = new TempFileManager(); var result = tfm.CreateFiles(10); Assert.IsTrue(tfm.FilesList().Count() == 10); }
public static Guid ComputeOverlay(string sourceFilePath) { FileContainer fileContainer = FileContainer.NewOverlayContainer(sourceFilePath); var processStartInfo = new ProcessStartInfo(); processStartInfo.WorkingDirectory = TempFileManager.GetTempDirectory(); processStartInfo.UseShellExecute = false; processStartInfo.ErrorDialog = false; processStartInfo.CreateNoWindow = true; processStartInfo.WindowStyle = ProcessWindowStyle.Hidden; string oldFilePath = fileContainer.SourceFileItem.FilePath; string outputFilePath = null; try { LogManager.AddOverlayMessage("SourceFileName " + Path.GetFileName(oldFilePath), "Start Crop"); // resize + crop source image outputFilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".png"); processStartInfo.FileName = Path.Combine(FrontSettings.ImageMagickPath, "convert"); processStartInfo.Arguments = $"{Path.GetFileName(fileContainer.SourceFileItem.FilePath)} -resize \"{_finalWidth}x{_finalHeight}^\" -gravity Center -crop {_finalWidth}x{_finalHeight}+0+0 {Path.GetFileName(outputFilePath)}"; StartProcess(processStartInfo, 5000); fileContainer.SourceFileItem.FilePath = outputFilePath; LogManager.AddOverlayMessage("OutputFileName " + Path.GetFileName(outputFilePath), "End Crop"); IpfsDaemon.Queue(fileContainer.SourceFileItem); } catch (Exception ex) { TempFileManager.SafeDeleteTempFile(outputFilePath); LogManager.AddOverlayMessage(ex.ToString(), "Exception"); return(fileContainer.ProgressToken); } finally { TempFileManager.SafeDeleteTempFile(oldFilePath); } try { LogManager.AddOverlayMessage("SourceFileName " + Path.GetFileName(fileContainer.SourceFileItem.FilePath), "Start Overlay"); // watermark source image outputFilePath = Path.ChangeExtension(TempFileManager.GetNewTempFilePath(), ".png"); processStartInfo.FileName = Path.Combine(FrontSettings.ImageMagickPath, "composite"); processStartInfo.Arguments = $"-gravity NorthEast {_overlayImagePath} {Path.GetFileName(fileContainer.SourceFileItem.FilePath)} {Path.GetFileName(outputFilePath)}"; StartProcess(processStartInfo, 5000); fileContainer.OverlayFileItem.FilePath = outputFilePath; LogManager.AddOverlayMessage("OutputFileName " + Path.GetFileName(outputFilePath), "End Overlay"); IpfsDaemon.Queue(fileContainer.OverlayFileItem); } catch (Exception ex) { TempFileManager.SafeDeleteTempFile(outputFilePath); LogManager.AddOverlayMessage(ex.ToString(), "Exception"); return(fileContainer.ProgressToken); } return(fileContainer.ProgressToken); }
public void Initialize() { _fileSystem = new Mock <IFileSystemWrapper>(); _tempFileManager = new TempFileManager(_fileSystem.Object); _fileSystem.Setup(m => m.GetTempPath()).Returns(TempPath); _fileSystem.Setup(m => m.PathCombine(TempPath, Environment.MachineName)).Returns(NewTempPath); }
protected FormMain() { InitializeComponent(); Control.CheckForIllegalCrossThreadCalls = false; _stateManager = StateManager.GetInstance(); _tempFileManager = TempFileManager.GetInstance(); _tcpIpFileManager = TcpIpFileManager.GetInstance(); }
/// <summary> /// Puts the currently configured temp path into the environment for use as actual temp directory /// </summary> public static void RefreshTempPath(this PathEntryCollection collection) { if (!string.IsNullOrWhiteSpace(collection.TempFilesFragment)) { // TODO - BUG - needs to route through PathManager.MakeAbsolutePath or something similar, but how? string target = collection.TempFilesFragment; TempFileManager.HelperSetTempPath(target); } }
/// <summary> /// add a file to the list (managing filename uniqueness) and return a file /// URI to the full path of the added file /// </summary> /// <param name="requestedFileName"></param> /// <param name="fileContents"></param> /// <returns></returns> public string AddFile(string requestedFileName, Stream fileContents) { string fileName = TempFileManager.CreateNewFile(_storageDirectory.FullName, CleanPathForServer(requestedFileName), false); using (FileStream fileStream = new FileStream(fileName, FileMode.Create, FileAccess.Write)) StreamHelper.Transfer(fileContents, fileStream); return(UrlHelper.GetLocalFileUrl(fileName)); }
private static IReadOnlyCollection <IApiNode> RoundTripApi(IReadOnlyCollection <IApiNode> originalApiNodes) { using (var tempFileManager = new TempFileManager()) { var outputFile = tempFileManager.GetNew(); JsonSerialization.WriteJson(originalApiNodes, outputFile); return(JsonSerialization.ReadJson(outputFile)); } }
public void WhenFileDoesNotExistItsContentsIsNull(string applicationArgumentsPropertyName, string errorReportPropertyName) { StorageManager.InTemporaryDirectory(directory => { using (var tempFileManager = new TempFileManager(directory)) { //Given const string reportName = "JEU76-12-95FE"; var errorReportCreator = GetErrorReportCreator(); const string exceptionMessage = reportName + " exception message"; var exception = new Exception(exceptionMessage); var version = new Version(1, 2, 3, 4); var applicationArguments = new ApplicationArguments(); const string ldrContents = "Ldr file contents"; const string highContents = "High file contents"; const string lowContents = "Low file contents"; applicationArguments.DesiredResistance = 8820; applicationArguments.FileType = "bmp"; applicationArguments.High = 20; applicationArguments.Low = 128; applicationArguments.LcdHeight = 1440; applicationArguments.LcdWidth = 2560; applicationArguments.MaskFilePath = @"c:\user\my\dir\mask.bmp"; applicationArguments.OriginalExposureTime = 1540; applicationArguments.MeasurementsNrOfColumns = 7; applicationArguments.MeasurementsNrOfRows = 9; if (applicationArgumentsPropertyName != nameof(ApplicationArguments.LdrCalibrationFilePath)) { applicationArguments.LdrCalibrationFilePath = tempFileManager.GetTempFile(ldrContents); } if (applicationArgumentsPropertyName != nameof(ApplicationArguments.LcdMeasurementsFilePathHigh)) { applicationArguments.LcdMeasurementsFilePathHigh = tempFileManager.GetTempFile(highContents); } if (applicationArgumentsPropertyName != nameof(ApplicationArguments.LcdMeasurementsFilePathLow)) { applicationArguments.LcdMeasurementsFilePathLow = tempFileManager.GetTempFile(lowContents); } //When errorReportCreator.CreateReport(version, exception, applicationArguments, directory, reportName); //Then var filesInDirectory = Directory.GetFiles(directory, reportName + "*").ToList(); filesInDirectory.Count.Should().Be(1); var report = filesInDirectory.Single(); var actualFileContents = File.ReadAllText(report); var actualErrorReport = JsonConvert.DeserializeObject <ErrorReport>(actualFileContents); var propertyInfo = typeof(ErrorReport).GetProperty(errorReportPropertyName); var propertyValue = propertyInfo.GetValue(actualErrorReport); propertyValue.Should().BeNull(); } }); }
public void Dispose(Boolean disposing) { if (disposing) { var frm = new ShutdownProgess(); try { frm.Show(); Logger.Debug("Disposing the Plugin Manager"); List <ControlHostWindow> temp = new List <ControlHostWindow>(_hostWindows); var itemCount = temp.Count + _extensions.Count; frm.progressBar.Maximum = itemCount; frm.progressBar.Value = 0; foreach (ControlHostWindow window in temp) { Logger.Debug("Disposing control host window '{0}'...", window.Title); frm.StatusMessage("Closing window " + window.Title); DoEvents(); try { window.Close(); window.Dispose(); } catch (Exception ex) { Logger.Warn("Exception occured whilst disposing host window '{0}' : {1}", window.Title, ex); } frm.progressBar.Value += 1; DoEvents(); } _extensions.ForEach((ext) => { Logger.Debug("Disposing extension '{0}'", ext); frm.StatusMessage("Unloading extension " + ext.Name); DoEvents(); try { ext.Dispose(); } catch (Exception ex) { Logger.Warn("Exception occured whilst disposing plugin '{0}' : {1}", ext, ex); } frm.progressBar.Value += 1; DoEvents(); }); _extensions.Clear(); frm.StatusMessage("Cleaning up temporary files..."); DoEvents(); Logger.Debug("Cleaning up resource temp files..."); _resourceTempFiles.CleanUp(); // Purge any temporary files that were created during the session Logger.Debug("Cleaning up generic temp files..."); TempFileManager.CleanUp(); TraitCategoryTypeHelper.Reset(); } finally { frm.Close(); } } }
/* * Main goals: * 1. No copies, ever. States are deposited directly to, and read directly from, one giant ring buffer. * As a consequence, there is no multi-threading because there is nothing to thread. * 2. Support for arbitrary and changeable state sizes. Frequency is calculated dynamically. * 3. No delta compression. Keep it simple. If there are cores that benefit heavily from delta compression, we should * maintain a separate rewinder alongside this one that is customized for those cores. */ public ZwinderBuffer(IRewindSettings settings) { if (settings == null) { throw new ArgumentException("ZwinderBuffer's settings cannot be null."); } long targetSize = settings.BufferSize * 1024 * 1024; if (settings.TargetFrameLength < 1) { throw new ArgumentOutOfRangeException(nameof(settings.TargetFrameLength)); } Size = 1L << (int)Math.Floor(Math.Log(targetSize, 2)); _sizeMask = Size - 1; _backingStoreType = settings.BackingStore; switch (settings.BackingStore) { case IRewindSettings.BackingStoreType.Memory: { var buffer = new MemoryBlock((ulong)Size); buffer.Protect(buffer.Start, buffer.Size, MemoryBlock.Protection.RW); _disposables.Add(buffer); _backingStore = new MemoryViewStream(true, true, (long)buffer.Start, (long)buffer.Size); _disposables.Add(_backingStore); break; } case IRewindSettings.BackingStoreType.TempFile: { var filename = TempFileManager.GetTempFilename("ZwinderBuffer"); var filestream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose); filestream.SetLength(Size); _backingStore = filestream; _disposables.Add(filestream); break; } default: throw new ArgumentException("Unsupported store type for ZwinderBuffer."); } if (settings.UseFixedRewindInterval) { _fixedRewindInterval = true; _targetRewindInterval = settings.TargetRewindInterval; } else { _fixedRewindInterval = false; _targetFrameLength = settings.TargetFrameLength; } _allowOutOfOrderStates = settings.AllowOutOfOrderStates; _states = new StateInfo[STATEMASK + 1]; _useCompression = settings.UseCompression; }
static void Main(string[] args) { //When Program Is Ran //Parse ROBLOX JSON int Result = ParseAPI(); if (Result == -1) { return; } //TODO : Open HTTP Server. TempFileManager.Init(); StudioHttpServer.Start(); CustomProperties.Init(); //Begin Accepting Commands. string Command = ""; do { StudioHttpServer.PrintAboutServer(); Console.WriteLine($"RSS Version {VERSION}"); Command = Console.ReadLine(); if (Command == "clear" || Command == "cls") { Console.Clear(); continue; } else if (Command == "quit") { break; } string[] splitCommand = Command.Split(' '); Console.WriteLine(); try { RSSParser.RSSParser.Parse(splitCommand); } catch (ParserException e) { Console.Clear(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine(e.Message); Console.ForegroundColor = ConsoleColor.White; } Console.WriteLine(); } while (Command != "quit"); // TempFileManager.Delete(); }
public static string GenerateTemporaryImageFile(GridLayer layer, string filenamePrefix, Color lowcolor, Color highcolor, Color novaluecolor, double cutoff = 0, int intervals = 256) { var filename = TempFileManager.NewTempFilename("bmp", filenamePrefix); CreateImageFileFromGrid(layer, filename, lowcolor, highcolor, novaluecolor, cutoff, intervals); var image = LayerImageGenerator.GetImageForLayer(layer, lowcolor, highcolor, novaluecolor, cutoff, intervals); TempFileManager.Attach(filename + "w"); return(filename); }
/// <summary> /// Puts the currently configured temp path into the environment for use as actual temp directory /// </summary> public static void RefreshTempPath(this PathEntryCollection collection) { if (string.IsNullOrWhiteSpace(collection.TempFilesFragment)) { return; } var path = collection.AbsolutePathFor(collection.TempFilesFragment, null); TempFileManager.HelperSetTempPath(path); }
public void CreateFilesTest() { using var tfm = new TempFileManager(); var result = tfm.CreateFiles(10); foreach (var file in result) { Assert.IsTrue(File.Exists(file)); } }
public static XmlNode ParsePHPCode(string phpCode, string phpParser) { var fileParser = new FileParser(phpParser); using (var fileManager = new TempFileManager()) { string file = fileManager.WriteContent(phpCode); var xml = fileParser.ParsePHPFile(file); return(xml); } }
/// <summary> /// Create a unique file placeholder. /// </summary> /// <param name="requestedFileName"></param> /// <returns></returns> public string CreateFile(string requestedFileName) { if (!FileHelper.IsValidFileName(requestedFileName)) { requestedFileName = FileHelper.GetPrettyFileName(requestedFileName); } string fileName = TempFileManager.CreateNewFile(_storageDirectory.FullName, requestedFileName, false); return(fileName); }
public override FileInfo GenerateLoanForm(Multimedia template, Loan loan, List <LoanMaterial> material, List <Trait> traits, Contact originator, Contact requestor, Contact receiver) { var user = PluginManager.Instance.User; var bytes = SupportService.GetMultimediaBytes(template.MultimediaID); var templateString = Encoding.ASCII.GetString(bytes); var sb = new StringBuilder(); var reader = new StringReader(templateString); int i; var rtfbuffer = new StringBuilder(); while ((i = reader.Read()) >= 0) { char?ch = (char)i; if (ch == '<') { ch = SkipRTF(reader, rtfbuffer); if (ch == '<') { var placeHolder = ReadPlaceHolder(reader, rtfbuffer); if (!string.IsNullOrEmpty(placeHolder)) { var value = SubstitutePlaceHolder(placeHolder, loan, material, traits, originator, requestor, receiver); if (!string.IsNullOrEmpty(value)) { if (rtfbuffer.Length > 0) { sb.Append(rtfbuffer.ToString()); rtfbuffer.Clear(); } sb.Append(value); } } } else { sb.AppendFormat("<{0}{1}", rtfbuffer, ch); } } else { sb.Append(ch); } } var content = sb.ToString(); var filename = TempFileManager.NewTempFilename(".rtf"); if (!string.IsNullOrWhiteSpace(filename)) { File.WriteAllText(filename, content); return(new FileInfo(filename)); } return(null); }