Fix mkTemp, et al. to handle the case where an X appears in the dir part of the template.
This happens quite often on Mac OS X in my experience. $TMPDIR is set to a private location with the name apparently generated by some hashing algorithm. I wouldn't be surprised if it is derived from the username somehow, as my accounts consistently wind up with 'X's in their $TMPDIR, on many systems.
This commit is contained in:
parent
e848b6ea1d
commit
67635f72b8
@ -40,6 +40,7 @@ import Data.List
|
|||||||
import Data.Char ( chr, ord, isDigit )
|
import Data.Char ( chr, ord, isDigit )
|
||||||
import Control.Monad ( liftM )
|
import Control.Monad ( liftM )
|
||||||
import Control.Exception ( handleJust )
|
import Control.Exception ( handleJust )
|
||||||
|
import System.FilePath ( splitFileName, (</>) )
|
||||||
import System.Directory ( doesDirectoryExist, doesFileExist, createDirectory )
|
import System.Directory ( doesDirectoryExist, doesFileExist, createDirectory )
|
||||||
import System.IO
|
import System.IO
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
@ -90,8 +91,9 @@ gettemp path doopen domkdir slen = do
|
|||||||
-- firstly, break up the path and extract the template
|
-- firstly, break up the path and extract the template
|
||||||
--
|
--
|
||||||
let (pref,tmpl,suff) = let (r,s) = splitAt (length path - slen) path
|
let (pref,tmpl,suff) = let (r,s) = splitAt (length path - slen) path
|
||||||
(p,t) = break (== 'X') r
|
(d,f) = splitFileName r
|
||||||
in (p,t,s)
|
(p,t) = break (== 'X') f
|
||||||
|
in (d </> p,t,s)
|
||||||
--
|
--
|
||||||
-- an error if there is only a suffix, it seems
|
-- an error if there is only a suffix, it seems
|
||||||
--
|
--
|
||||||
|
Loading…
x
Reference in New Issue
Block a user