equal
deleted
inserted
replaced
41 finally: |
41 finally: |
42 fh.Close() |
42 fh.Close() |
43 |
43 |
44 def nlinks(pathname): |
44 def nlinks(pathname): |
45 """Return number of hardlinks for the given file.""" |
45 """Return number of hardlinks for the given file.""" |
46 links = _getfileinfo(pathname)[7] |
46 return _getfileinfo(pathname)[7] |
47 if links < 2: |
|
48 # Known to be wrong for most network drives |
|
49 dirname = os.path.dirname(pathname) |
|
50 if not dirname: |
|
51 dirname = '.' |
|
52 dt = win32file.GetDriveType(dirname + '\\') |
|
53 if dt == 4 or dt == 1: |
|
54 # Fake hardlink to force COW for network drives |
|
55 links = 2 |
|
56 return links |
|
57 |
47 |
58 def samefile(fpath1, fpath2): |
48 def samefile(fpath1, fpath2): |
59 """Returns whether fpath1 and fpath2 refer to the same file. This is only |
49 """Returns whether fpath1 and fpath2 refer to the same file. This is only |
60 guaranteed to work for files, not directories.""" |
50 guaranteed to work for files, not directories.""" |
61 res1 = _getfileinfo(fpath1) |
51 res1 = _getfileinfo(fpath1) |