1 (* Copyright (C) 2017 Matthew Fluet.
2 * Copyright (C) 2002-2007 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
9 functor MLtonIO (S: MLTON_IO_ARG): MLTON_IO =
14 fun mkstemps {prefix, suffix}: string * outstream =
18 val name = concat [prefix, MLtonRandom.alphaNumString 6, suffix]
22 newOut (createf (name, O_WRONLY, O.flags [O.excl],
24 in flags [irusr, iwusr]
27 end handle e as PosixError.SysErr (_, s) =>
28 if s = SOME Posix.Error.exist
35 fun mkstemp s = mkstemps {prefix = s, suffix = ""}
38 case MLtonPlatform.OS.host of
39 MLtonPlatform.OS.MinGW =>
40 (case MinGW.getTempPath () of
42 | NONE => "C:\\temp\\") ^ file