PDF: More conservative solution to #777.

Now, instead of always creating temp dirs in the home
directory on Windows, we only do it if the system tempdir
name contains tildes.  (This will be the case for longer
usernames only.)

Closes #1192.
This commit is contained in:
John MacFarlane 2019-02-02 12:35:27 -08:00
parent 737c0a684e
commit cb1ede5b08

View file

@ -50,7 +50,8 @@ import System.Environment
import System.Exit (ExitCode (..))
import System.FilePath
import System.IO (stdout)
import System.IO.Temp (withSystemTempDirectory, withTempFile)
import System.IO.Temp (withSystemTempDirectory, withTempDirectory,
withTempFile)
#if MIN_VERSION_base(4,8,3)
import System.IO.Error (IOError, isDoesNotExistError)
#else
@ -102,7 +103,15 @@ makePDF program pdfargs writer opts doc = do
baseProg -> do
commonState <- getCommonState
verbosity <- getVerbosity
liftIO $ withSystemTempDirectory "tex2pdf." $ \tmpdir -> do
-- latex has trouble with tildes in paths, which
-- you find in Windows temp dir paths with longer
-- user names (see #777)
let withTempDir templ action = do
tmp <- getTemporaryDirectory
if '~' `elem` tmp
then withTempDirectory "." templ action
else withSystemTempDirectory templ action
liftIO $ withTempDir "tex2pdf." $ \tmpdir -> do
source <- runIOorExplode $ do
putCommonState commonState
doc' <- handleImages tmpdir doc