[m-rev.] For review: Fix for io.m so it will compmile for GRADE=il
Eric Taucher
gluon at earthlink.net
Tue Jul 31 07:02:07 AEST 2007
Estimated hours taken: 1
Fix C# pragma in io.m for do_make_temp so that io.m will compile for
GRADE=il.
library/io.m:
Modified pragma to define missing variables dir and _sep, and
match description of exported method make_temp.
index: io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.399
diff -u -r1.399 io.m
--- io.m 18 Jul 2007 05:23:30 -0000 1.399
+++ io.m 30 Jul 2007 20:34:12 -0000
@@ -9609,10 +9609,40 @@
Error::out, ErrorMessage::out, _IO0::di, _IO::uo),
[will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
"{
- try {
- FileName = System.IO.Path.GetTempFileName();
- Error = 0;
- ErrorMessage = """";
+ FileName = """";
+ Error = 0;
+ ErrorMessage = """";
+
+ try
+ {
+ bool FileCreated = false;
+ int tryCount = 0;
+ int tryMax = 10;
+ while (!FileCreated && (tryCount < tryMax))
+ {
+ string TempPath = System.IO.Path.GetTempFileName();
+ System.IO.File.Delete(TempPath);
+ string TempFileName = System.IO.Path.GetFileName(TempPath);
+ TempFileName = Prefix + TempFileName;
+ TempPath = Dir + _Sep + TempFileName;
+ if (System.IO.File.Exists(TempPath) == false)
+ {
+ // Used a FileStream so that I would not have to mess with
seperators if
+ // the directory was a root directory.
+ System.IO.FileStream fs = System.IO.File.Open(TempPath,
System.IO.FileMode.CreateNew);
+ FileCreated = true;
+ FileName = fs.Name;
+ }
+ else
+ {
+ tryCount++;
+ }
+ }
+ if (!FileCreated)
+ {
+ Error = -1;
+ ErrorMessage = ""Unable to create temp file after 10 tries."";
+ }
}
catch (System.Exception e)
{
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20070730/a68ead77/attachment.html>
More information about the reviews
mailing list