develooper Front page | perl.perl5.porters | Postings from May 2004

[perl #29570] Cwd::realpath doesn't work on files on Windows

andrew @ pimlott . net
May 14, 2004 01:13
[perl #29570] Cwd::realpath doesn't work on files on Windows
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #29570]
# in the subject line of all future correspondence about this issue. 
# <URL: >

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

[Please enter your report here]

I was surprised to find that Cwd::realpath doesn't work for files on
Windows, as it does on Linux.  The problem is that on Windows, it uses
fast_abs_path, which tries to chdir to its argument.

This is a pain to work around.  If you don't want to special-case
Windows, you have to do something like what's in FindBin: manually chase
the file symlink, and then call realpath on the final directory.  If
you're wiling to special-case, you can parse out the directory path and
call realpath on that.  It would be highly useful and much less
error-prone for realpath to handle this case.  

I could try to fix the code, but I'm not sure which approach is best.
Or is there a better solution?


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

Configured by Gerrit at Fri Nov  7 12:03:56     2003.

Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
    osname=cygwin, osvers=1.5.5(0.9432), archname=cygwin-thread-multi-64int
    uname='cygwin_nt-5.0 troubardix 1.5.5(0.9432) 2003-09-20 16:31 i686 unknown unknown cygwin '
    config_args='-de -Dmksymlinks -Duse64bitint -Dusethreads -Doptimize=-O2 -Dman3ext=3pm'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=define use64bitall=undef uselongdouble=undef
    usemymalloc=y, bincompat5005=undef
    cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing',
    cppflags='-DPERL_USE_SAFE_PUTENV -fno-strict-aliasing'
    ccversion='', gccversion='3.3.1 (cygming special)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='ld2', ldflags =' -s -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib /lib
    libs=-lgdbm -ldb -lcrypt -lgdbm_compat
    perllibs=-lcrypt -lgdbm_compat
    libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' -s'
    cccdlflags=' ', lddlflags=' -s -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.2:
    /Documents and Settings/apimlott/nexplan/demo/lib

Environment for perl v5.8.2:
    HOME=/cygdrive/c/Documents and Settings/apimlott
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/cygdrive/c/Perl/bin/:/usr/bin:/cygdrive/c/program files/putty:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/Program Files/Common Files/Network Associates/VirusScan Engine/4.0.xx/:/cygdrive/c/Program Files/Microsoft SQL Server/80/Tools/BINN
    PERL5LIB=c:/Documents and Settings/apimlott/nexplan/demo/lib
    PERL_BADLANG (unset)
    SHELL (unset) Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About