144 WinError.__init__(self, err) |
144 WinError.__init__(self, err) |
145 OSError.__init__(self, self.winerror_map.get(self.win_errno, 0), |
145 OSError.__init__(self, self.winerror_map.get(self.win_errno, 0), |
146 self.win_strerror) |
146 self.win_strerror) |
147 |
147 |
148 def os_link(src, dst): |
148 def os_link(src, dst): |
149 # NB will only succeed on NTFS |
|
150 try: |
149 try: |
151 win32file.CreateHardLink(dst, src) |
150 win32file.CreateHardLink(dst, src) |
|
151 # CreateHardLink sometimes succeeds on mapped drives but |
|
152 # following nlinks() returns 1. Check it now and bail out. |
|
153 if nlinks(src) < 2: |
|
154 try: |
|
155 win32file.DeleteFile(dst) |
|
156 except: |
|
157 pass |
|
158 # Fake hardlinking error |
|
159 raise WinOSError((18, 'CreateHardLink', 'The system cannot ' |
|
160 'move the file to a different disk drive')) |
152 except pywintypes.error, details: |
161 except pywintypes.error, details: |
153 raise WinOSError(details) |
162 raise WinOSError(details) |
154 |
163 |
155 def nlinks(pathname): |
164 def nlinks(pathname): |
156 """Return number of hardlinks for the given file.""" |
165 """Return number of hardlinks for the given file.""" |