import argparse from os.path import abspath from pykern.filesystem import FileSystem parser = argparse.ArgumentParser() parser.add_argument('source') parser.add_argument('dest') args = parser.parse_args() fs = FileSystem() src = fs.get_superblock(args.source) try: dest = fs.get_superblock(args.dest) except OSError: pass fs.superblocks[abspath(args.dest)] = src.copy() del fs.superblocks[abspath(args.source)] fs.save_superblocks()
def stat(p): fs = FileSystem() p = path.abspath(p) superblock = fs.get_superblock(p) return stat_result(superblock['mode'], superblock['size'])
def chdir(p): fs = FileSystem() absolute_path = path.abspath('%s' % p) fs.get_superblock(absolute_path, mode=fs.DIRECTORY_MODE) fs.current_directory = absolute_path