Hi all,
I know about os.symlink(src, dst), but is there
a way to overwrite an existing symlink e.g. "ln -sf"?
Short of checking and, if necessary, having to delete
the existing link by hand...
That's what gnu ln does for "ln -sf", though for good measure it stat()s
three times!
$ strace -e stat64,symlink,unlink ln -sf a b
stat64("b", 0xfeee1290) = -1 ENOENT (No such file or directory)
symlink("a", "b") = 0
$ strace -e stat64,symlink,unlink ln -sf a b
stat64("b", 0xfeef69e0) = -1 ENOENT (No such file or directory)
stat64("b", 0xfeef68d0) = -1 ENOENT (No such file or directory)
stat64("a", 0xfeef69d0) = -1 ENOENT (No such file or directory)
unlink("b") = 0
symlink("a", "b") = 0
A single os.lstat() should do nicely in your case, or a catch around the
unlink.
Jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBCDMcJd01MZaTXX0RAry+AJ9eu66f4Xjw6L3Hpq7SRMKqQdOzZgCfWJTv
5AczIY+fOkynz4QjRSjUQD4=
=HvwM
-----END PGP SIGNATURE-----