[m-rev.] diff: C# io.file_modification_time

Peter Wang novalazy at gmail.com
Thu Dec 2 11:22:22 AEDT 2010


Branches: main

library/io.m:
        Fix handling of non-existent files in the C# version of
        io.file_modification_time.

diff --git a/library/io.m b/library/io.m
index c90613e..f0e506a 100644
--- a/library/io.m
+++ b/library/io.m
@@ -2881,10 +2881,16 @@ io.file_modification_time(File, Result, !IO) :-
     [will_not_call_mercury, promise_pure, tabled_for_io, thread_safe],
 "{
     try {
+        if (System.IO.File.Exists(FileName)) {
         System.DateTime t = System.IO.File.GetLastWriteTime(FileName);
         Time = time.ML_construct_time_t(t);
         Msg = """";
         Status = 1;
+        } else {
+            Msg = ""File not found"";
+            Time = null;
+            Status = 0;
+        }
 
     } catch (System.Exception e) {
         Msg = ""GetLastWriteTime() failed: "" + e.Message;

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list