develooper Front page | perl.perl5.porters | Postings from January 2001

[ID 20010111.021] (builtin)mkdir and File::Path::mkpath problem

Thread Next
January 11, 2001 18:55
[ID 20010111.021] (builtin)mkdir and File::Path::mkpath problem
Message ID:

This is a bug report for perl from,
generated with the help of perlbug 1.28 running under perl v5.6.0.

[Please enter your report here]
There seems to be a problem with the built-in function 'mkdir',
as well as (by consequence) library functions that use it (verified
with File::Path::mkpath.
The problem is that the Perl built-in 'mkdir' does not do the right thing
(compared to the *nix 'mkdir') when there is a trailing slash
in the path name.
I noticed the problem when trying to use the HTML::Latex module.

Example (mkdir):

mkdir "foo"; # works, returns true
mkdir "bar/"; # doesn't work and returns false

Example (mkpath):
mkpath("foo/bar/baz"); # works
mkpath("baz/bar/foo/"); # doesn't work, croaks when trying to create 'foo'

A workaround seems to be to apply the following patch:

*** ../	Wed Oct 11 02:26:47 2000
--- ../	Fri Jan 12 04:43:16 2001
*** 94,99 ****
--- 94,100 ----
  use 5.005_64;
  use Carp;
  use File::Basename ();
+ use File::Spec;
  use Exporter ();
  use strict;
*** 119,124 ****
--- 120,126 ----
      foreach $path (@$paths) {
  	$path .= '/' if $^O eq 'os2' and $path =~ /^\w:\z/s; # feature of CRT 
+         $path = File::Spec->canonpath($path);
  	next if -d $path;
  	# Logic wants Unix paths, so go with the flow.
  	$path = VMS::Filespec::unixify($path) if $Is_VMS;

[Please do not change anything below this line]
Site configuration information for perl v5.6.0:

Configured by feyrer at Wed Oct 11 02:22:07 MEST 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
    osname=netbsd, osvers=1.5_alpha2, archname=i386-netbsd
    uname='netbsd yui 1.5_alpha2 netbsd 1.5_alpha2 (yui) #11: fri oct 6 17:04:19 mest 2000 feyrer@yui:disk1cvssrc-1.5sysarchi386compileyui i386 '
    config_args='-sde -Dprefix=/usr/pkg -Doptimize=-O2 -Darchname=i386-netbsd -Dcc=gcc -Dusemymalloc=false -Duseshrplib=true'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
    cc='gcc', optimize='-O2', gccversion=egcs-2.91.66 19990314 (egcs-1.1.2 release)
    cppflags='-fno-strict-aliasing -I/usr/pkg/include'
    ccflags ='-fno-strict-aliasing -I/usr/pkg/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/pkg/lib'
    libpth=/usr/pkg/lib /lib /usr/lib
    libs=-lm -lcrypt
    libc=/usr/lib/, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-R/usr/pkg/lib  -Wl,-R/usr/pkg/lib/perl5/5.6.0/i386-netbsd/CORE'
    cccdlflags='-DPIC -fPIC ', lddlflags='--whole-archive -shared  -L/usr/pkg/lib'

Locally applied patches:

@INC for perl v5.6.0:

Environment for perl v5.6.0:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About