How to create symlink with Haskell?

大憨熊 提交于 2019-12-10 14:04:12

问题


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


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/37153638/how-to-create-symlink-with-haskell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!