Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > File::Path::remove_tree not working

Reply
Thread Tools

File::Path::remove_tree not working

 
 
Allan Herriman
Guest
Posts: n/a
 
      09-18-2012
Hi,

I have a script that creates a temporary directory using

my $tempdir = tempdir( CLEANUP => 1 );

Some readonly files are then created in that directory. All are closed
before the script finishes.

On my development machine (Activestate Perl 5.16.0 on Windows 7) it
worked fine: the directory was removed after the script finished.

On the deployment machines (Cygwin Perl 5.10.1 on Windows Server 2003) it
doesn't remove the directory or any of the files in the directory.



I then added the following line at the end of the script:

remove_tree($tempdir, { safe => 0 });

but that didn't fix anything.

It didn't write anything to STDERR, which I think indicates it didn't
encounter detectable error conditions.

I'm using -w and strict.

I can manually delete the directory in windows explorer without any
warnings or prompts, so it doesn't appear to be a permission problem.


What do I do next?


Thanks,
Allan
 
Reply With Quote
 
 
 
 
ilovelinux
Guest
Posts: n/a
 
      09-20-2012
> my $tempdir = tempdir( CLEANUP => 1 );
> remove_tree($tempdir, { safe => 0 });


Smells like somethnig weird in the Cygwin layer. I once encountered a similar error: the Cygwin perl script removed some files but they stayed visiblefrom an Explorer view in another window, until the perl script finished: only then the removed files disappeared.

Did you try removing the files by hand-crafted code? Something like this:

for (glob("$tempdir/*")) {
print "removing $_: ";
if (unlink($_)) {
print "OK\n";
} else {
print "ERR ($!)\n";
}
}
 
Reply With Quote
 
 
 
 
Allan Herriman
Guest
Posts: n/a
 
      09-21-2012
On Wed, 19 Sep 2012 23:27:55 -0700, ilovelinux wrote:

>> my $tempdir = tempdir( CLEANUP => 1 );
>> remove_tree($tempdir, { safe => 0 });

>
> Smells like somethnig weird in the Cygwin layer. I once encountered a
> similar error: the Cygwin perl script removed some files but they stayed
> visible from an Explorer view in another window, until the perl script
> finished: only then the removed files disappeared.
>
> Did you try removing the files by hand-crafted code? Something like
> this:
>
> for (glob("$tempdir/*")) {
> print "removing $_: ";
> if (unlink($_)) {
> print "OK\n";
> } else {
> print "ERR ($!)\n";
> }
> }



I even tried rm -rf and that didn't work, which I found rather surprising.

> Smells like somethnig weird in the Cygwin layer.


It turns out that in Cygwin paths starting with /tmp/ get magically
redirected to c:/cygwin/tmp/
I cannot imagine a universe where that would be a good idea, but
apparently the Cygwin authors thought it was.

tempdir returns /tmp/something, and this gets interpreted as
c:/tmp/something by some parts of my script and as
c:/cygwin/tmp/something by other parts of my script (including tempdir
itself).

tempdir does in fact clean up its directory, but not the directory I
thought it was using.

My ugly, non-portable and fragile workaround is to chdir to c: then
prepend the temp directory name with c: before I use it.

Regards,
Allan
 
Reply With Quote
 
ilovelinux
Guest
Posts: n/a
 
      09-21-2012
> It turns out that in Cygwin paths starting with /tmp/ get magically
> redirected to c:/cygwin/tmp/


Not if you mount it yourself. My /etc/fstab (Cygwin) contains

c:/temp /tmp some_fs binary 0 0
d:/Users /home some_fs binary 0 0
none / cygdrive binary,posix=0,user 0 0

The top line forces all accesses of /tmp to use the c:/temp directory.

HTH
 
Reply With Quote
 
Kaz Kylheku
Guest
Posts: n/a
 
      09-21-2012
On 2012-09-21, Ben Morrow <> wrote:
>
> Quoth Allan Herriman <>:
>>
>> It turns out that in Cygwin paths starting with /tmp/ get magically
>> redirected to c:/cygwin/tmp/
>> I cannot imagine a universe where that would be a good idea, but
>> apparently the Cygwin authors thought it was.

>
> This is usual Cygwin behaviour: in fact, it's one of the main reasons to
> use Cygwin in the first place.


One of the main reasons for using Cygwin is where it sticks /tmp?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
response.redirect is not working but server.transfer is working gaurav tyagi ASP .Net 14 01-20-2006 04:22 AM
wifi not working on new hp, or not working after live update =?Utf-8?B?RHJhZ29ueA==?= Wireless Networking 1 10-01-2005 11:17 PM
ASP.NET client-side validation working, but button click not working Alan Silver ASP .Net 1 08-02-2005 03:50 PM
Cookies working on intranet but NOT working on Internet Martin Heuckeroth ASP .Net 5 04-01-2005 01:37 AM
Regular Expression validators NOT working, Required Field validators ARE working Ratman ASP .Net 0 09-14-2004 09:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57