def test(self): link = 'junction' contents = 'bar' link_file = os.path.join(link, os.path.relpath(self.DIR_FILE, self.DIR)) create(self.DIR, link) self.assertEqual(os.path.abspath(self.DIR), readlink(link)) with open(link_file, 'r') as fd: self.assertEqual(fd.read(), self.DIR_FILE_CONTENTS) with open(self.DIR_FILE, 'w') as fd: fd.write(contents) with open(link_file, 'r') as fd: self.assertEqual(fd.read(), contents) unlink(link) self.assertFalse(os.path.exists(link))
def _symlink(source, link_name): junction.create(source, link_name)
def link_save(old_path, new_path): print("Linking... {} -> {}".format(old_path, new_path)) junction.create(new_path, old_path)
def _windows_directory_link(self, src, dst): from ntfsutils import junction return junction.create(src, dst)
def new_symlink(source, link_name): if os.path.isdir(source): return junction.create(source, link_name) return hardlink.create(source, link_name)