~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/build/unix/abs2rel.pl

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!env perl
 
2
 
 
3
# The contents of this file are subject to the Mozilla Public
 
4
# License Version 1.1 (the "License"); you may not use this file
 
5
# except in compliance with the License. You may obtain a copy of
 
6
# the License at http://www.mozilla.org/MPL/
 
7
 
 
8
# The Initial Developer of the Original Code is Netscape
 
9
# Communications Corporation.  Portions created by Netscape are
 
10
# Copyright (C) 2002 Netscape Communications Corporation. All
 
11
# Rights Reserved.
 
12
 
 
13
use File::Spec::Unix;
 
14
use strict;
 
15
 
 
16
print "Usage: $0 dest_path start_path\n" if ($#ARGV+1 != 2);
 
17
my $finish = my_canonpath(shift);
 
18
my $start = my_canonpath(shift);
 
19
 
 
20
my $res = File::Spec::Unix->abs2rel($finish, $start);
 
21
 
 
22
#print STDERR "abs2rel($finish,$start) = $res\n";
 
23
print "$res\n";
 
24
 
 
25
sub my_canonpath($) {
 
26
    my ($file) = @_;
 
27
    my (@inlist, @outlist, $dir);
 
28
 
 
29
    # Do what File::Spec::Unix->no_upwards should do
 
30
    my @inlist = split(/\//, File::Spec::Unix->canonpath($file));
 
31
    foreach $dir (@inlist) {
 
32
        if ($dir eq '..') {
 
33
            pop @outlist;
 
34
        } else {
 
35
            push @outlist, $dir;
 
36
        }
 
37
    }
 
38
    $file = join '/',@outlist;
 
39
    return $file;
 
40
}
 
41