in opensfm/large/metadataset.py [0:0]
def _create_symlink(self, base_path, file_path):
src = os.path.join(self.data_path, file_path)
dst = os.path.join(base_path, file_path)
if not os.path.exists(src):
return
# Symlinks on Windows require admin privileges,
# so we use hard links instead
if sys.platform == 'win32':
if os.path.isdir(dst):
shutil.rmtree(dst)
elif os.path.isfile(dst):
os.remove(dst)
else:
if os.path.islink(dst):
os.unlink(dst)
subfolders = len(file_path.split(os.path.sep)) - 1
if sys.platform == 'win32':
if os.path.isdir(src):
# Create directory in destination, then make hard links
# to files
os.mkdir(dst)
for f in glob.glob(os.path.join(src, "*")):
filename = os.path.basename(f)
os.link(f, os.path.join(dst, filename))
else:
# Just make hard link
os.link(src, dst)
else:
os.symlink(os.path.join(*[".."] * subfolders, os.path.relpath(src, base_path)), dst)