forward slashes to backward slashes.
\end{funcdesc}
+\begin{funcdesc}{realpath}{path}
+Return the canonical path of the specified filename, eliminating any
+symbolic links encountered in the path.
+Availability: \UNIX{}.
+\versionadded{2.2}
+\end{funcdesc}
+
\begin{funcdesc}{samefile}{path1, path2}
Return true if both pathname arguments refer to the same file or
directory (as indicated by device number and i-node number).
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)
+
+# realpath is a no-op on systems without islink support
+realpath = abspath
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)
+
+# realpath is a no-op on systems without islink support
+realpath = abspath
else:
path = os.getcwd()
return normpath(path)
+
+# realpath is a no-op on systems without islink support
+realpath = abspath
return normpath(join(os.getcwd(), p))
+# realpath is a no-op on systems without islink support
+realpath = abspath
+
+
# Normalize a path. Only special path element under RISC OS is "^" for "..".
def normpath(p):
if not isabs(path):
path = join(os.getcwd(), path)
return normpath(path)
+
+
+# Return a canonical path (i.e. the absolute location of a file on the
+# filesystem).
+
+def realpath(filename):
+ """Return the canonical path of the specified filename, eliminating any
+symbolic links encountered in the path."""
+ filename = abspath(filename)
+
+ bits = ['/'] + filename.split('/')[1:]
+ for i in range(2, len(bits)+1):
+ component = join(*bits[0:i])
+ if islink(component):
+ resolved = os.readlink(component)
+ (dir, file) = split(component)
+ resolved = normpath(join(dir, resolved))
+ newpath = join(*([resolved] + bits[i:]))
+ return realpath(newpath)
+
+ return filename