示例#1
0
        internal TempFile(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 ?? TempRoot.Root, prefix + Guid.NewGuid() + (extension ?? ".tmp"));

                try
                {
                    TempRoot.CreateStream(_path);
                    break;
                }
                catch (PathTooLongException)
                {
                    throw;
                }
                catch (DirectoryNotFoundException)
                {
                    throw;
                }
                catch (IOException)
                {
                    // retry
                }
            }
        }
示例#2
0
        /// <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)));
        }
示例#3
0
        private TempDirectory(string path, TempRoot root)
        {
            NullableDebug.Assert(path != null);
            NullableDebug.Assert(root != null);

            _path = path;
            _root = root;
        }
示例#4
0
 protected TempDirectory(TempRoot root)
     : this(CreateUniqueDirectory(TempRoot.Root), root)
 {
 }
示例#5
0
 public DisposableDirectory(TempRoot root)
     : base(root)
 {
 }