RosettaCodeData/Task/Truncate-a-file/Standard-ML/truncate-a-file.ml
2023-07-01 13:44:08 -04:00

11 lines
263 B
Standard ML

local
open Posix.FileSys
val perm = S.flags [S.irusr, S.iwusr, S.irgrp, S.iwgrp, S.iroth, S.iwoth]
in
fun truncate (path, len) =
let
val fd = createf (path, O_WRONLY, O.noctty, perm)
in
ftruncate (fd, len); Posix.IO.close fd
end
end