in reply to Is this directory a subdirectory of another directory?

Hmmm, interesting problem. Please never use real paths in CGI input - that's asking for trouble. Please never use "$foo", because that's (in a way) equal to saying "" . $foo . "". Just use the scalar you want directly: $foo. (Note: except for when a subroutine usually modifies data, but you only want the returned value - using interpolation is a very nice way to cheat in those circumstances.)

As for your problem, you could split the directory names on \ and then compare the two arrays, or use one of the directory names as a regex (\Q!) for the other. Windows doesn't have symlinks and such, so I think a simple minded approach like that might just work.

U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk

  • Comment on Re: Is this directory a subsirectory of another directory?

Replies are listed 'Best First'.
Re: Re: Is this directory a subsirectory of another directory?
by demerphq (Chancellor) on Mar 15, 2002 at 19:21 UTC

      Not for nothing, but it's NTFS that supports hard (not symbolic) links, not NT/2K/XP, per se.

      1. NT's own CLI (CMD.EXE) doesn't even support them directly.
      2. You need a separate console mode program (ln.exe, from the POSIX subsystem -- or MKS Toolkit, Cygwin, U/WIN, et al) to create links.
      3. The standard Windows Explorer is not even (apparently) link aware.

      I think Juerd's point was true if you assume typical Windows users (i.e., not everyone knows how to create multiple links to a file).

        Not for nothing, but it's NTFS that supports hard (...) links, not NT/2K/XP, per se

        True. Sorry... :-)

        supports hard (not symbolic) links,

        Actually thats not correct, DOS has supported SUBST for a long time which is a form of symbolic link (as is indeed the volume naming scheme in general, although granted this is not what one normally thinks of as a symlink) and the Win2k version of NTFS (so I wasnt realy wrong) supports junctions (symbolic links) through reparse points. You are correct however in that like hard links there are no standard tools for creating junctions. However the ever useful trove of MS power tools www.systeminternals.com has the tool junction which can create them. But windows explorer shows them as a standard directory, but cmd.exe does not.

        Both hard and symbolic links (junctions) are illustrated in the following little cmd.exe trace. (D:\Development\test_funky\extra_level\my_symlink junctions D:\Development\test_funky\itsa_symlink)

        D:\Development\test_funky>copy con here.txt Test! ^Z 1 file(s) copied. D:\Development\test_funky>ln here.txt itsa_symlink\howzat.txt D:\Development\test_funky>dir itsa_symlink Volume in drive D is DataStore Volume Serial Number is 2892-9D2C Directory of D:\Development\test_funky\itsa_symlink 18/03/02 13:15 <DIR> . 18/03/02 13:15 <DIR> .. 18/03/02 13:15 7 howzat.txt 1 File(s) 7 bytes 2 Dir(s) 2,915,024,896 bytes free D:\Development\test_funky>dir Volume in drive D is DataStore Volume Serial Number is 2892-9D2C Directory of D:\Development\test_funky 18/03/02 13:15 <DIR> . 18/03/02 13:15 <DIR> .. 18/03/02 12:50 <DIR> extra_level 18/03/02 13:15 7 here.txt 18/03/02 13:07 <JUNCTION> itsa_symlink 1 File(s) 7 bytes 4 Dir(s) 2,915,024,896 bytes free D:\Development\test_funky>type itsa_symlink\howzat.txt Test! D:\Development\test_funky>echo This too >>itsa_symlink\howzat.txt D:\Development\test_funky>type here.txt Test! This too D:\Development\test_funky>tree Folder PATH listing for volume DataStore Volume serial number is 0006FE80 2892:9D2C D:. +---extra_level ¦ +---my_junction ¦ +---my_link +---itsa_symlink D:\Development\test_funky>echo this as well >>extra_level\my_junction\ +howzat.txt D:\Development\test_funky>type here.txt Test! This too this as well D:\Development\test_funky>
        Sorry if this is off topic, but MS gets beaten up enough when they deserve it to be beaten up when they dont. ;-) Also you never know somebody out there might be just dying to know how to do junctions under W2k *even bigger grin*

        Yves / DeMerphq
        --
        When to use Prototypes?
        Advanced Sorting - GRT - Guttman Rosler Transform