in reply to Re: File::Path::rmtree on UNC path (updated)
in thread File::Path::rmtree on UNC path (updated)

You are right. I can't chdir in a directory and then delete it. Which leaves me with the original problem: If I do NOT chdir into it, I get consistently the error message ... changed before chdir, expected ..., and nothing gets deleted. If I chdir into it, its content will be deleted, but the directory itself won't.

Of course I can do the following strategy:

  1. chdir $sharedir;
  2. rmtree $sharedir,1,1;
  3. chdir 'c:/';
  4. rmdir $sharedir;
This would indeed remove the directory completely, but I get the nasty error message from rmtree in step (2), so this is not a solution I really like.

Maybe I have to really write my own "rmtree", or - as this is going to run on Windows only - I shell out and do a system('RMDIR'...).

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^3: File::Path::rmtree on UNC path (updated)
by swhl (Initiate) on Jun 10, 2009 at 10:01 UTC
    what if you chdir to the directory above that?
    my ($dir, $subdir) = $sharedir =~ /^(.*)\/(.*)$/; chdir $dir; rmtree $subdir;
      my ($dir, $subdir) = $sharedir =~ /^(.*)\/(.*)$/; chdir $dir;

      Actually, I would write this as

      $chdir "$subdir\\..";
      (should be no peril in this context, isn't it?), but, yes, you are right, this seems to work well!! Great idea!

      -- 
      Ronald Fischer <ynnor@mm.st>