Esempio n. 1
0
def stat(path):
    fs = FileSystem()
    path = fs.get_absolute_of(path)
    try:
        file_ = fs.metadata[path]
    except KeyError:
        raise OSError('No such file "%s"' % path)

    return stat_result(file_['mode'], file_['size'])
Esempio n. 2
0
def listdir(path):
    fs = FileSystem()
    if not os.path.isdir(path):
        raise OSError('Not a directory: "%s"' % path)
    absolute_target_path = fs.get_absolute_of('%s' % path)
    if not absolute_target_path.endswith('/'):
        absolute_target_path += '/'
    result = [
        path[len(absolute_target_path):]
        for path in FileSystem().metadata
        if path.startswith(absolute_target_path) and
        '/' not in path.split(absolute_target_path, 1)[1] and
        path != absolute_target_path
    ]
    return result
Esempio n. 3
0
def chdir(path):
    fs = FileSystem()
    absolute_path = fs.get_absolute_of('%s' % path)
    if not os.path.isdir(absolute_path):
        raise OSError('Not a directory: "%s"' % path)
    fs.current_dir = absolute_path