How to create symlink with Haskell?
Asked Answered
T

2

5

How to create a symlink with Haskell? The directory package to my knowledge does not provide a way to do it.

Thrombophlebitis answered 11/5, 2016 at 5:17 Comment(5)
System.Posix.Files.createSymbolicLinkScudo
@n.m. Feel free to post as an answer, unless a duplicate question already exists.Thrombophlebitis
Apparently there's a (near) duplicate here.Scudo
@n.m. I think this question will be easier to find via search engines, I think we should keep this one.Thrombophlebitis
@Mark: Closing as a duplicate won't delete this question. Instead, it will still come up in search engines. (By the way, I knew I answered this question already somewhere :D)Stansbury
S
10

Creating a symbolic link is non-portable. For example, the creation symbolic links on Windows is re­strict­ed1. Therefore it does not fit into directory providing "a basic set of operations for ma­nip­u­lat­ing 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

Stansbury answered 11/5, 2016 at 7:17 Comment(0)
C
0

directory-1.3.1 has

createFileLink :: FilePath -> FilePath -> IO ()

This is supposed to work even on Windows – only on a suitable file system, of course.

Caralie answered 23/10, 2017 at 11:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.