Windows symlink

This commit is contained in:
Dmitry Petrov
2017-04-07 17:44:25 -07:00
parent 9d97704ca4
commit 449517c511
2 changed files with 29 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import os
__CSL = None
def win_symlink(source, link_name):
'''symlink(source, link_name) - DVC override for Windows
Creates a symbolic link pointing to source named link_name'''
flags = 0
if source is not None and os.path.isdir(source):
flags = 1
if __CSL(link_name, source, flags) == 0:
raise ctypes.WinError()
def setup():
if os.name == 'nt':
global __CSL
if __CSL is None:
import ctypes
csl = ctypes.windll.kernel32.CreateSymbolicLinkW
csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
csl.restype = ctypes.c_ubyte
__CSL = csl
os.symlink = win_symlink
pass
+1
View File
@@ -89,3 +89,4 @@ class ReproChangedDeepDependency(ReproChangedDependency):
CmdRepro(self.settings).run()
self.assertEqual(open(self.file_name_res).read(), 'Goodbye\nBobby')
self.assertEqual(1, 2)