in reply to Re: Finding out whether two directories are the same
in thread Finding out whether two directories are the same

Thanks for filling in those details, Corion. Now I can just skip to the crazy ideas:

my $rand= md5_hash_hex( rand() . $$ . $x . "super secret" ); mkdir( "$x/$rand" ); if( -d "$y/$rand" ) { warn "$x == $y\n"; } rmdir( "$x/$rand" );

I only created a subdirectory instead of a file because it makes for more concise Perl code. Or you could lock a file you find in $x and see if you hold the lock on that file in $y? (But that assumes that all of your file system exporting technologies convey lock information, which is not always the case, of course.) You could create a pipe in one... etc.

- tye        

Replies are listed 'Best First'.
Re^3: Finding out whether two directories are the same (insert)
by rovf (Priest) on Aug 28, 2008 at 09:44 UTC
    Or you could lock a file you find in $x and see if you hold the lock on that file in $y

    Or, then, I could create a tempfile (File::Temp) in one, and see whether the tempfile exists in the other!!!

    -- 
    Ronald Fischer <ynnor@mm.st>

      rovf++ - this may well be the most portable idea of all. There is a very small chance of failure in weird setups like AFS, in which synchronization between the exported and the local dir may happen days apart, but that's a real stretch.

      
      -- 
      Human history becomes more and more a race between education and catastrophe. -- HG Wells
      

      You should not forget to check, if the file creation was successful. If you don't have permission to create the file and you don't check that, your check for existence might lead to a wrong conclusion!

        You should not forget to check, if the file creation was successful.

        If I use File::Temp::tempfile, this throws an exception if it can't create the file, so checking must be done by wrapping it into an eval block and testing $@ afterwards.

        -- 
        Ronald Fischer <ynnor@mm.st>