Show More
@@ -23,15 +23,6 b' from win32com.shell import shell, shellc' | |||
|
23 | 23 | def os_link(src, dst): |
|
24 | 24 | try: |
|
25 | 25 | win32file.CreateHardLink(dst, src) |
|
26 | # CreateHardLink sometimes succeeds on mapped drives but | |
|
27 | # following nlinks() returns 1. Check it now and bail out. | |
|
28 | if nlinks(src) < 2: | |
|
29 | try: | |
|
30 | win32file.DeleteFile(dst) | |
|
31 | except: | |
|
32 | pass | |
|
33 | # Fake hardlinking error | |
|
34 | raise OSError(errno.EINVAL, 'Hardlinking not supported') | |
|
35 | 26 | except pywintypes.error: |
|
36 | 27 | raise OSError(errno.EINVAL, 'target implements hardlinks improperly') |
|
37 | 28 | except NotImplementedError: # Another fake error win Win98 |
@@ -54,9 +45,19 b' def nlinks(pathname):' | |||
|
54 | 45 | """Return number of hardlinks for the given file.""" |
|
55 | 46 | res = _getfileinfo(pathname) |
|
56 | 47 | if res is not None: |
|
57 |
|
|
|
48 | links = res[7] | |
|
58 | 49 | else: |
|
59 |
|
|
|
50 | links = os.lstat(pathname).st_nlink | |
|
51 | if links < 2: | |
|
52 | # Known to be wrong for most network drives | |
|
53 | dirname = os.path.dirname(pathname) | |
|
54 | if not dirname: | |
|
55 | dirname = '.' | |
|
56 | dt = win32file.GetDriveType(dirname + '\\') | |
|
57 | if dt == 4 or dt == 1: | |
|
58 | # Fake hardlink to force COW for network drives | |
|
59 | links = 2 | |
|
60 | return links | |
|
60 | 61 | |
|
61 | 62 | def samefile(fpath1, fpath2): |
|
62 | 63 | """Returns whether fpath1 and fpath2 refer to the same file. This is only |
General Comments 0
You need to be logged in to leave comments.
Login now