Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 2017 Matthew Fluet. |
2 | * Copyright (C) 2007 Henry Cejtin, Matthew Fluet, Suresh | |
3 | * Jagannathan, and Stephen Weeks. | |
4 | * | |
5 | * MLton is released under a BSD-style license. | |
6 | * See the file MLton-LICENSE for details. | |
7 | *) | |
8 | ||
9 | structure MinGW = | |
10 | struct | |
11 | fun getTempPath () = | |
12 | let | |
13 | fun lp bufSz = | |
14 | let | |
15 | val buf = CharArray.alloc (C_Size.toInt bufSz) | |
16 | val reqSz = PrimitiveFFI.MinGW.getTempPath (bufSz, buf) | |
17 | in | |
18 | if 0w0 = reqSz | |
19 | then NONE | |
20 | else if C_Size.< (reqSz, bufSz) | |
21 | then SOME (CharArraySlice.vector | |
22 | (CharArraySlice.unsafeSlice | |
23 | (buf, 0, SOME (C_Size.toInt reqSz)))) | |
24 | else lp reqSz | |
25 | end | |
26 | in | |
27 | (* Win32 MAX_PATH is 260, but some subsystems allow longer names *) | |
28 | lp 0w261 | |
29 | end | |
30 | end |