sub srcinfo()

in lib/DocUtil.pm [64:90]


sub srcinfo(;$) {
    my ($vol, $dir, $basename) = File::Spec->splitpath(shift or $ARGV[1]);

    die "Call error, CWD must be the doc root directory, stopped"
        if ($rvol ne $vol);
        
    my $docpath = File::Spec->abs2rel(
        File::Spec->catpath($vol, $dir, ''),
        $docroot
    );

    # remove suffix from basename
    $basename =~ s/\Q$ARGV[0]\E$//;

    # use HTTP path separators (/)
    $docpath = join '/' => ('', File::Spec->splitdir($docpath), '');
    1 while ($docpath =~ s,/\./,/,g); # something's bogus on the Mac otherwise
    $docpath =~ y,/,/,s; # squeeze multiple slashes

    # compute relative (HTTP-)path from srcfile to docroot
    my $relative = (join '/' => ('..') x ($docpath =~ y,/,, - 1)) || '.';

    # address metafile
    my $metafile = "$docpath$basename.xml.meta";

    ($docpath, $basename, $relative, $metafile);
}