/// <summary> /// Creates a file in this directory. /// </summary> /// <param name="name">File name.</param> public TempFile CreateFile(string name) { string filePath = System.IO.Path.Combine(_path, name); TempRoot.CreateStream(filePath); return(_root.AddFile(new DisposableFile(filePath))); }
internal TempFile(TempRoot root, string prefix, string extension, string directory, string callerSourcePath, int callerLineNumber) { while (true) { if (prefix == null) { prefix = System.IO.Path.GetFileName(callerSourcePath) + "_" + callerLineNumber.ToString() + "_"; } _path = System.IO.Path.Combine(directory ?? root.Root, prefix + Guid.NewGuid() + (extension ?? ".tmp")); try { TempRoot.CreateStream(_path); break; } catch (PathTooLongException) { throw; } catch (DirectoryNotFoundException) { throw; } catch (IOException) { // retry } } }
private TempDirectory(string path, TempRoot root) { Debug.Assert(path != null); Debug.Assert(root != null); _path = path; _root = root; }
public TempFile CreateFile(TempRoot root, string prefix = null, string extension = null, string directory = null, [CallerFilePath] string callerSourcePath = null, [CallerLineNumber] int callerLineNumber = 0) { return(AddFile(new DisposableFile(root, prefix, extension, directory, callerSourcePath, callerLineNumber))); }
protected TempDirectory(TempRoot root) : this(root.Root, root) { }
public DisposableFile(TempRoot root, string prefix = null, string extension = null, string directory = null, string callerSourcePath = null, int callerLineNumber = 0) : base(root, prefix, extension, directory, callerSourcePath, callerLineNumber) { }
public DisposableDirectory(TempRoot root) : base(root) { }