我有一个Perl脚本,需要删除包含其所有内容的目录.
有时,此目录包含到另一个目录的联结点.如果我天真地使用rmtree(),rmtree()调用也将删除联结目标文件夹中的所有文件.我正在寻找一种不这样做的方法,而只是删除了交叉点.
有时,此目录包含到另一个目录的联结点.如果我天真地使用rmtree(),rmtree()调用也将删除联结目标文件夹中的所有文件.我正在寻找一种不这样做的方法,而只是删除了交叉点.
非Perl解决方案也将受到赞赏.
解决方法
我只是在Google中键入了“联结点”并找到了我的方式
http://en.wikipedia.org/wiki/NTFS_junction_point
http://en.wikipedia.org/wiki/NTFS_junction_point
Command Prompt (cmd.exe)
- The dir
command in Windows 2000 or later
recognizes junction points,displaying
instead of in
directory listings (use dir with the
/A or /AL command-line switch).- Any
commands that would normally affect
files inside a normal directory will
act the same here. Thus the command
del myjunction should not be used —
this will just delete all the files in
the targeted directory.- The commands
rmdir and move work fine with
junctions,with the caveat that move
won’t let the junction move to another
volume (as opposed to Windows
Explorer,as mentioned above.)- The
rmdir command is safe in that it only
deletes the junction point,not the
targeted files. Whilst walking through
the directory with the command line
interface,files can be deleted,but
unlike explorer,directories can also
be deleted (using rmdir /s dirname for
example.)- Using the linkd command with
the /d switch is a safe way to delete
junction points.
从我所看到的,你可以,例如,使用dir和grep输出< JUNCTION>或使用Windows rmdir.我认为您可以通过系统使用Perl中的任何一个.