{-# LINE 1 "libraries\\Win32\\System\\Win32\\SymbolicLink.hsc" #-}
{-# LANGUAGE CPP #-}
module System.Win32.SymbolicLink
( module System.Win32.SymbolicLink
) where
import Data.Bits ((.|.))
import System.Win32.Types
import System.Win32.File ( failIfFalseWithRetry_ )
#include "windows_cconv.h"
type SymbolicLinkFlags = DWORD
sYMBOLIC_LINK_FLAG_FILE :: SymbolicLinkFlags
sYMBOLIC_LINK_FLAG_FILE = 0
sYMBOLIC_LINK_FLAG_DIRECTORY :: SymbolicLinkFlags
sYMBOLIC_LINK_FLAG_DIRECTORY = 1
sYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE :: SymbolicLinkFlags
sYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 2
{-# LINE 44 "libraries\\Win32\\System\\Win32\\SymbolicLink.hsc" #-}
createSymbolicLink :: FilePath
-> FilePath
-> SymbolicLinkFlags -> IO ()
createSymbolicLink = flip createSymbolicLink'
createSymbolicLinkFile :: FilePath
-> FilePath
-> Bool
-> IO ()
createSymbolicLinkFile target link unprivileged =
createSymbolicLink'
link
target
( if unprivileged
then sYMBOLIC_LINK_FLAG_FILE .|. sYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
else sYMBOLIC_LINK_FLAG_FILE
)
createSymbolicLinkDirectory :: FilePath
-> FilePath
-> Bool
-> IO ()
createSymbolicLinkDirectory target link unprivileged =
createSymbolicLink'
link
target
( if unprivileged
then
sYMBOLIC_LINK_FLAG_DIRECTORY
.|. sYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE
else sYMBOLIC_LINK_FLAG_DIRECTORY
)
createSymbolicLink' :: FilePath
-> FilePath
-> SymbolicLinkFlags -> IO ()
createSymbolicLink' link target flag = do
withTString link $ \c_link ->
withTString target $ \c_target ->
failIfFalseWithRetry_ (unwords ["CreateSymbolicLink",show link,show target]) $
c_CreateSymbolicLink c_link c_target flag
foreign import WINDOWS_CCONV unsafe "windows.h CreateSymbolicLinkW"
c_CreateSymbolicLink :: LPTSTR -> LPTSTR -> SymbolicLinkFlags -> IO BOOL