+2006-05-04 LLuis Sanchez Gual <lluis@novell.com>
+
+ * TempFileCollection.cs: Make sure generated file names
+ are unique. Fixes bug #76125 and #78230.
+
2006-04-20 Gert Driesen <drieseng@users.sourceforge.net>
* CodeGenerator.cs: Output empty line between types if
if (rnd == null)
rnd = new Random ();
- string random = rnd.Next (10000,99999).ToString ();
- basepath = Path.Combine (temp, random);
-
+ // Create a temporary file at the target directory. This ensures
+ // that the generated file name is unique.
+ FileStream f = null;
+ do {
+ int num = rnd.Next ();
+ num++;
+ basepath = Path.Combine (temp, num.ToString("x"));
+ string path = basepath + ".tmp";
+
+ try {
+ f = new FileStream (path, FileMode.CreateNew);
+ }
+ catch (System.IO.IOException) {
+ f = null;
+ continue;
+ }
+ catch {
+ // avoid endless loop
+ throw;
+ }
+ } while (f == null);
+
+ f.Close ();
+
// and you must have discovery access to the combined path
// note: the cache behaviour is tested in the CAS tests
if (SecurityManager.SecurityEnabled) {
filehash.Remove(file);
}
}
+ if (basepath != null) {
+ string tmpFile = basepath + ".tmp";
+ File.Delete (tmpFile);
+ }
}
IEnumerator IEnumerable.GetEnumerator ()