perl – 如何在不遵循连接点的情况下删除Windows目录?

前端之家收集整理的这篇文章主要介绍了perl – 如何在不遵循连接点的情况下删除Windows目录?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个Perl脚本,需要删除包含其所有内容的目录. @H_404_2@有时,此目录包含到另一个目录的联结点.如果我天真地使用rmtree(),rmtree()调用也将删除联结目标文件夹中的所有文件.我正在寻找一种不这样做的方法,而只是删除了交叉点.

非Perl解决方案也将受到赞赏.

解决方法

我只是在Google中键入了“联结点”并找到了我的方式 @H_404_2@ http://en.wikipedia.org/wiki/NTFS_junction_point

Command Prompt (cmd.exe)

  • The dir@H_404_2@ command in Windows 2000 or later@H_404_2@ recognizes junction points,displaying@H_404_2@ instead of in@H_404_2@ directory listings (use dir with the@H_404_2@ /A or /AL command-line switch).
  • Any@H_404_2@ commands that would normally affect@H_404_2@ files inside a normal directory will@H_404_2@ act the same here. Thus the command@H_404_2@ del myjunction should not be used —@H_404_2@ this will just delete all the files in@H_404_2@ the targeted directory.
  • The commands@H_404_2@ rmdir and move work fine with@H_404_2@ junctions,with the caveat that move@H_404_2@ won’t let the junction move to another@H_404_2@ volume (as opposed to Windows@H_404_2@ Explorer,as mentioned above.)
  • The@H_404_2@ rmdir command is safe in that it only@H_404_2@ deletes the junction point,not the@H_404_2@ targeted files. Whilst walking through@H_404_2@ the directory with the command line@H_404_2@ interface,files can be deleted,but@H_404_2@ unlike explorer,directories can also@H_404_2@ be deleted (using rmdir /s dirname for@H_404_2@ example.)
  • Using the linkd command with@H_404_2@ the /d switch is a safe way to delete@H_404_2@ junction points.

从我所看到的,你可以,例如,使用dir和grep输出< JUNCTION>或使用Windows rmdir.我认为您可以通过系统使用Perl中的任何一个.

原文链接:https://www.f2er.com/Perl/171688.html

猜你在找的Perl相关文章