[Tutor] symlinking dirs with spaces
eryksun
eryksun at gmail.com
Sun Apr 28 04:13:32 CEST 2013
On Sat, Apr 27, 2013 at 2:53 PM, <fomcl at yahoo.com> wrote:
> --- On Friday, April 26, 2013 9:53 PM, eryksun <eryksun at gmail.com> wrote:
>> Your arguments for symlink() are string literals. How about this?
>>
>> LOAD_DIR = "/opt/data/music/load"
>>
>> def link(media):
>> src = os.path.abspath(media)
>> dst = os.path.join(LOAD_DIR, os.path.basename(media))
>> print "Adding %s to %s..." % (src, LOAD_DIR)
>> os.symlink(src, dst)
>
> IIRC, os.symlink is not present in Python on Windows, right? (I'm on vacation
> now so I can't check this). But aren't soft links and shortcuts linux and windows
> terms for the same thing?
Windows shortcuts (.lnk) are roughly equivalent to XDG .desktop files.
Python 3.2+ supports os.link() for files on NT. It also supports
os.symlink() on NT 6+ (Vista and later). Creating a symbolic link will
fail if the process lacks the required privilege.
Background:
Win32 CreateHardLink was added in NT 5 (XP). Win32 CreateSymbolicLink
was added in NT 6 (Vista; Windows 7 is NT 6.1), which also added
"mklink" to the cmd shell. Creating symlinks requires
SeCreateSymbolicLinkPrivilege. The default security settings enable
this for administrators only.
NT also has directory junctions (NTFS reparse points), which work
transparently even if you're connected remotely. In contrast symlinks
are resolved on the client, which means symlinks can work with UNC
network paths (e.g. mklink /d mylink \\server\path). Maybe the
stricter security for symlinks was added because they work across the
network.
More information about the Tutor
mailing list