Пример #1
0
def _exists(path, symlink_default, follow_symlinks, **kwargs):
    try:
        stat(path, follow_symlinks=follow_symlinks, **kwargs)
        return True
    except OSError as err:
        if err.errno == errno.ENOENT:
            return False
        raise
    except SMBLinkRedirectionError:
        # Link points to another server or local drive, return false
        return symlink_default
Пример #2
0
def samefile(path1, path2, **kwargs):
    """
    Return True if both pathname arguments refer to the same file or directory. This is determined by the device number
    and i-node number and raises an exception if an os.stat() call on either pathname fails.

    :param path1: The first path to compare.
    :param path2: The second path to compare.
    :param kwargs: Common arguments used to build the SMB Session.
    :return: Bool that indicates whether the 2 files are the same.
    """
    stat1 = stat(path1, **kwargs)
    stat2 = stat(path2, **kwargs)
    return stat1.st_ino == stat2.st_ino and stat1.st_dev == stat2.st_dev
Пример #3
0
def _stat_ismode(path, check, follow, **kwargs):
    try:
        return check(stat(path, follow_symlinks=follow, **kwargs).st_mode)
    except SMBOSError as err:
        if err.errno == errno.ENOENT:
            return False
        raise
Пример #4
0
def getsize(path, **kwargs):
    """
    Return the size, in bytes, of path. Raise OSError if the file does not exist or is inaccessible.

    :param path: The path to get the size for.
    :param kwargs: Common arguments used to build the SMB Session.
    :return: The byte size of the path.
    """
    return stat(path, **kwargs).st_size
Пример #5
0
def getctime(path, **kwargs):
    """
    Return the system’s ctime which is the creation time for path. The return value is a number giving the number of
    seconds since the epoch (see the time module). Raise OSError if the file does not exist or is inaccessible.

    :param path: The path to get the ctime for.
    :param kwargs: Common arguments used to build the SMB Session.
    :return: float that represents the number of seconds since epoch for atime.
    """
    return stat(path, **kwargs).st_ctime
Пример #6
0
def getmtime(path, **kwargs):
    """
    Return the time of last modification of path. The return value is a floating point number giving the number of
    seconds since the epoch (see the time module). Raise OSError if the file does not exist or is inaccessible.

    :param path: The path to get the mtime for.
    :param kwargs: Common arguments used to build the SMB Session.
    :return: float that represents the number of seconds since epoch for atime.
    """
    return stat(path, **kwargs).st_mtime