- Jan 29, 2007
- 8,762
- 30
- 91
My program is supposed to read a given directory and lists it's contents into a text file. I can get my program to write one file's attributes to a file but i can't do it recursively.
My code
(*Imports structures that are used by the program*)
open TextIO;
open OS.FileSys;
open Option;
open Date;
fun listdir(filename, directoryname) =
let
val opener = openDir(directoryname)
val filePath = openAppend(filename)
in
(listdirHelper(filePath,opener); flushOut(filePath); closeOut(filePath))
end;
fun listdirHelper(fName,x) =
let
val read = readDir(x)
val vo = valOf(read)
val fTime = modTime(vo)
val size = fileSize(vo)
val timeLocal = fromTimeLocal(fTime)
val modDate = fmt "%d-%B-%Y" (timeLocal)
in
(output(fName,vo ^ " " ^ modDate ^ "" ^ size ^"\n"); listdirHelper(fName,x))
end;
My code
(*Imports structures that are used by the program*)
open TextIO;
open OS.FileSys;
open Option;
open Date;
fun listdir(filename, directoryname) =
let
val opener = openDir(directoryname)
val filePath = openAppend(filename)
in
(listdirHelper(filePath,opener); flushOut(filePath); closeOut(filePath))
end;
fun listdirHelper(fName,x) =
let
val read = readDir(x)
val vo = valOf(read)
val fTime = modTime(vo)
val size = fileSize(vo)
val timeLocal = fromTimeLocal(fTime)
val modDate = fmt "%d-%B-%Y" (timeLocal)
in
(output(fName,vo ^ " " ^ modDate ^ "" ^ size ^"\n"); listdirHelper(fName,x))
end;
