xref: /trunk/main/solenv/bin/modules/installer/pathanalyzer.pm (revision d620b54767df0d2c7d9557af4be4c7303d55d13c)
19780544fSAndrew Rist#**************************************************************
2cdf0e10cSrcweir#
39780544fSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
49780544fSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
59780544fSAndrew Rist#  distributed with this work for additional information
69780544fSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
79780544fSAndrew Rist#  to you under the Apache License, Version 2.0 (the
89780544fSAndrew Rist#  "License"); you may not use this file except in compliance
99780544fSAndrew Rist#  with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir#
119780544fSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir#
139780544fSAndrew Rist#  Unless required by applicable law or agreed to in writing,
149780544fSAndrew Rist#  software distributed under the License is distributed on an
159780544fSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169780544fSAndrew Rist#  KIND, either express or implied.  See the License for the
179780544fSAndrew Rist#  specific language governing permissions and limitations
189780544fSAndrew Rist#  under the License.
19cdf0e10cSrcweir#
209780544fSAndrew Rist#**************************************************************
219780544fSAndrew Rist
229780544fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirpackage installer::pathanalyzer;
25cdf0e10cSrcweir
26cdf0e10cSrcweiruse installer::globals;
27cdf0e10cSrcweir
28cdf0e10cSrcweir###########################################
29cdf0e10cSrcweir# Path analyzer
30cdf0e10cSrcweir###########################################
31cdf0e10cSrcweir
32cdf0e10cSrcweirsub get_path_from_fullqualifiedname
33cdf0e10cSrcweir{
34cdf0e10cSrcweir    my ($longfilenameref) = @_;
35cdf0e10cSrcweir
36cdf0e10cSrcweir    if ( $$longfilenameref =~ /\Q$installer::globals::separator\E/ )    # Is there a separator in the path? Otherwise the path is empty.
37cdf0e10cSrcweir    {
38cdf0e10cSrcweir        if ( $$longfilenameref =~ /^\s*(\S.*\S\Q$installer::globals::separator\E)(\S.+\S?)/ )
39cdf0e10cSrcweir        {
40cdf0e10cSrcweir            $$longfilenameref = $1;
41cdf0e10cSrcweir        }
42cdf0e10cSrcweir    }
43cdf0e10cSrcweir    else
44cdf0e10cSrcweir    {
45cdf0e10cSrcweir        $$longfilenameref = ""; # there is no path
46cdf0e10cSrcweir    }
47cdf0e10cSrcweir}
48cdf0e10cSrcweir
49*dba1a2e4SAndre Fischer
50*dba1a2e4SAndre Fischer
51*dba1a2e4SAndre Fischer
52*dba1a2e4SAndre Fischer=head2
53*dba1a2e4SAndre Fischer
54*dba1a2e4SAndre Fischer    Despite its name, this function seems just to return the basename of the given filename.
55*dba1a2e4SAndre Fischer
56*dba1a2e4SAndre Fischer=cut
57cdf0e10cSrcweirsub make_absolute_filename_to_relative_filename
58cdf0e10cSrcweir{
59cdf0e10cSrcweir    my ($longfilenameref) = @_;
60cdf0e10cSrcweir
61cdf0e10cSrcweir    if ( $installer::globals::isunix )
62cdf0e10cSrcweir    {
63cdf0e10cSrcweir        if ( $$longfilenameref =~ /^.*\/(\S.+\S?)/ )
64cdf0e10cSrcweir        {
65cdf0e10cSrcweir            $$longfilenameref = $1;
66cdf0e10cSrcweir        }
67cdf0e10cSrcweir    }
68cdf0e10cSrcweir
69dfa12748SYuri Dario    if ( $installer::globals::iswin || $installer::globals::isos2 )
70cdf0e10cSrcweir    {
71cdf0e10cSrcweir        # Either '/' or '\'. It would be possible to use $installer::globals::separator.
72cdf0e10cSrcweir        if ( $$longfilenameref =~ /^.*[\/\\](\S.+\S?)/ )
73cdf0e10cSrcweir        {
74cdf0e10cSrcweir            $$longfilenameref = $1;
75cdf0e10cSrcweir        }
76cdf0e10cSrcweir    }
77cdf0e10cSrcweir}
78cdf0e10cSrcweir
79cdf0e10cSrcweir1;
80