2 // System.CodeDom.Compiler TempFileCollection Class implementation
5 // Dick Porter (dick@ximian.com)
7 // (C) 2003 Ximian, Inc.
11 using System.Collections;
13 namespace System.CodeDom.Compiler
15 public class TempFileCollection:ICollection, IEnumerable, IDisposable
21 public TempFileCollection(): this(null, false)
25 public TempFileCollection(string tempDir): this(tempDir, false)
29 public TempFileCollection(string tempDir, bool keepFiles)
31 filehash=new Hashtable();
36 private string basepath=null;
38 public string BasePath
43 /* Get the system temp dir */
44 MonoIO.GetTempPath(out tempdir);
47 string random=new Random().Next(10000,99999).ToString();
49 if(tempdir.EndsWith("\\") ||
50 tempdir.EndsWith("/")) {
51 basepath=tempdir+random;
53 basepath=tempdir+"/"+random;
64 return(filehash.Count);
89 public string AddExtension(string fileExtension)
91 return(AddExtension(fileExtension, keepfiles));
94 public string AddExtension(string fileExtension, bool keepFile)
96 string filename=BasePath+"."+fileExtension;
97 AddFile(filename, keepFile);
101 public void AddFile(string fileName, bool keepFile)
103 filehash.Add(fileName, keepFile);
106 public void CopyTo(string[] fileNames, int start)
108 filehash.Keys.CopyTo(fileNames, start);
111 void ICollection.CopyTo(Array array, int start)
113 filehash.Keys.CopyTo(array, start);
116 [MonoTODO("What goes here?")]
117 object ICollection.SyncRoot {
123 bool ICollection.IsSynchronized {
129 void IDisposable.Dispose()
136 string[] filenames=new string[filehash.Count];
137 filehash.Keys.CopyTo(filenames, 0);
139 foreach(string file in filenames) {
140 if((bool)filehash[file]==true) {
142 filehash.Remove(file);
147 public IEnumerator GetEnumerator()
149 return(filehash.Keys.GetEnumerator());
152 protected virtual void Dispose(bool disposing)
157 ~TempFileCollection()