summaryrefslogtreecommitdiffstats
path: root/Lib/posixpath.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1991-11-12 15:37:40 (GMT)
committerGuido van Rossum <guido@python.org>1991-11-12 15:37:40 (GMT)
commitd3778f9f6045bdbe6177ff100125555d3015beb1 (patch)
tree857e5062c2b64ec8e514e2484d62996d73df0427 /Lib/posixpath.py
parentf109f86de5b3652d20d98490c35d9fb0aaf32087 (diff)
downloadcpython-d3778f9f6045bdbe6177ff100125555d3015beb1.zip
cpython-d3778f9f6045bdbe6177ff100125555d3015beb1.tar.gz
cpython-d3778f9f6045bdbe6177ff100125555d3015beb1.tar.bz2
Added samefile() function.
Diffstat (limited to 'Lib/posixpath.py')
-rw-r--r--Lib/posixpath.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 456743c..7c13458 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -100,6 +100,34 @@ def islink(path):
return stat.S_ISLNK(st[stat.ST_MODE])
+# Are two filenames really pointing to the same file?
+#
+def samefile(f1, f2):
+ s1 = posix.stat(f1)
+ s2 = posix.stat(f2)
+ return samestat(s1, s2)
+
+
+# Are two open files really referencing the same file?
+# (Not necessarily the same file descriptor!)
+# XXX Oops, posix.fstat() doesn't exist yet!
+#
+def sameopenfile(fp1, fp2):
+ s1 = posix.fstat(fp1)
+ s2 = posix.fstat(fp2)
+ return samestat(s1, s2)
+
+
+# Are two stat buffers (obtained from stat, fstat or lstat)
+# describing the same file?
+#
+def samestat(s1, s2):
+ return s1[stat.ST_INO] = s2[stat.ST_INO] and \
+ s1[stat.ST_DEV] = s2[stat.STD_DEV]
+
+
+# Subroutine and global data used by ismount().
+
_mounts = []
def _getmounts():