Reputation: 7599
How to create a symlink with Haskell? The directory
package to my knowledge does not provide a way to do it.
Upvotes: 5
Views: 885
Reputation: 120741
createFileLink :: FilePath -> FilePath -> IO ()
This is supposed to work even on Windows – only on a suitable file system, of course.
Upvotes: 0
Reputation: 105925
Creating a symbolic link is non-portable. For example, the creation symbolic links on Windows is restricted1. Therefore it does not fit into directory
providing "a basic set of operations for manipulating files and directories in a portable way" (emphasis mine). This affects all platform independent packages.
The platform specific package unix
provides that functionality in System.Posix.Files
with createSymbolicLink
though:
import System.Posix.Files (createSymbolicLink)
main :: IO ()
main = createSymbolicLink "/opt/ghc/7.10.3" "/opt/ghc/active"
1: That's also a reason why unix-compat
does not implement createSymbolicLink
Upvotes: 10