Monday 30 May 2016

Haskell: getTemporaryDirectory: Get the directory for temporary files

System.Directory module provides getTemporaryDirectory function, which returns the directory for temporary files

Prelude System.Directory> :t getTemporaryDirectory
getTemporaryDirectory :: IO FilePath
Prelude System.Directory>
Prelude System.Directory> getTemporaryDirectory
"/var/folders/1x/9q4yr4k15csf564llfcz3c1h7n6wlv/T/"

Note
a.   On Unix kind of systems this function return the value stored in environment variable TMPDIR.

$ echo $TMPDIR
/var/folders/1x/9q4yr4k15csf564llfcz3c1h7n6wlv/T/

If the environment variable don’t exist, it return ‘/tmp’.

b. On Windows, the function checks for the existence of   environment variables in the following order and uses the first path found:

1.   TMP environment variable.
2.   TEMP environment variable.
3.   USERPROFILE environment variable.
4.   The Windows directory




Previous                                                 Next                                                 Home

No comments:

Post a Comment