file_info now returns a string that does not contain the path/filename
(so the string doesn't change when the relative path does)
--- a/src/Pure/POLY.ML Fri Oct 15 12:49:33 1993 +0100
+++ b/src/Pure/POLY.ML Fri Oct 15 12:51:21 1993 +0100
@@ -38,12 +38,24 @@
(*** File information ***)
-(*Get time of last modification.*)
+(*Get a string containing the time of last modification, attributes, owner
+ and size of file (but not the path) *)
fun file_info "" = ""
| file_info name =
- let val (is, os) = ExtendedIO.execute ("ls -l " ^ name)
- val result = ExtendedIO.input_line is;
- val dummy = close_in is;
- val dummy = close_out os;
- in result end;
+ let
+ (*These are functions from library.ML *)
+ fun take_suffix _ [] = ([], [])
+ | take_suffix pred (x :: xs) =
+ (case take_suffix pred xs of
+ ([], sffx) => if pred x then ([], x :: sffx) else ([x], sffx)
+ | (prfx, sffx) => (x :: prfx, sffx));
+ fun apr (f,y) x = f(x,y);
+ val (is, os) = ExtendedIO.execute ("ls -l " ^ name)
+ val (result, _) = take_suffix (apr(op<>," "))
+ (explode (ExtendedIO.input_line is))
+ (*Remove the part after the last " " (i.e. the path/filename) *)
+ in close_in is;
+ close_out os;
+ implode result
+ end;