diff --git a/notebook/utils.py b/notebook/utils.py index 92a2410cc..c472367b2 100644 --- a/notebook/utils.py +++ b/notebook/utils.py @@ -141,6 +141,23 @@ def is_hidden(abs_path, abs_root=''): return False +def same_file(path, other_path): + """ + Check if path and other_path are hard links to the same file. This is a + utility implementation of Python's os.path.samefile which is not available + with Python 2.x and Windows. + + Parameters + ----------- + path: String representing a path to a file + other_path: String representing a path to another file + + Returns + ----------- + same: Boolean that is True if both path and other path are the same + """ + return os.stat(path).st_ino == os.stat(other_path).st_ino + def to_os_path(path, root=''): """Convert an API path to a filesystem path