Subversion Repositories DevTools

Rev

Rev 7312 | Rev 7320 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7312 Rev 7319
Line 31... Line 31...
31
#                    FileCreate                 - Create a simple text file
31
#                    FileCreate                 - Create a simple text file
32
#                    FileAppend                 - Append to a simple text file
32
#                    FileAppend                 - Append to a simple text file
33
#                    TagFileMatch               - Simple (oneline) file content matcher
33
#                    TagFileMatch               - Simple (oneline) file content matcher
34
#                    TagFileRead                - Return the contents of the tagfile
34
#                    TagFileRead                - Return the contents of the tagfile
35
#                    RmDirTree                  - Remove a directory tree
35
#                    RmDirTree                  - Remove a directory tree
-
 
36
#                    CatPaths                   - Concatenate Paths            
36
#           ReExported
37
#           ReExported
37
#                    catdir                     - Concatenate path elements
38
#                    catdir                     - Concatenate path elements
38
#                    catfile                    - Concatenate path elements and a file
39
#                    catfile                    - Concatenate path elements and a file
39
#
40
#
40
#......................................................................#
41
#......................................................................#
Line 81... Line 82...
81
                FileCreate
82
                FileCreate
82
                FileAppend
83
                FileAppend
83
                TagFileMatch
84
                TagFileMatch
84
                TagFileRead
85
                TagFileRead
85
                RmDirTree
86
                RmDirTree
-
 
87
                CatPaths
86
                catfile
88
                catfile
87
                catdir
89
                catdir
88
 
90
 
89
                $ScmPathSep
91
                $ScmPathSep
90
                $ScmDirSep
92
                $ScmDirSep
Line 274... Line 276...
274
    my $mode = shift @_;
276
    my $mode = shift @_;
275
    my $name = shift @_;
277
    my $name = shift @_;
276
    my $fh;
278
    my $fh;
277
 
279
 
278
    Error ("FileCreate: No file specified") unless ( $name );
280
    Error ("FileCreate: No file specified") unless ( $name );
279
    Error ("FileCreate: Path is directory") if ( -d $name );
281
    Error ("FileCreate: Path is directory", 'Path :' . $name) if ( -d $name );
280
 
282
 
281
    open  ($fh, $mode, $name ) || Error( "Cannot create file: $name", "Reason: $!" );
283
    open  ($fh, $mode, $name ) || Error( "Cannot create file: $name", "Reason: $!" );
282
 
284
 
283
    foreach my $entry ( @_ ) {
285
    foreach my $entry ( @_ ) {
284
        if ( ref ($entry ) eq 'ARRAY'  ) {
286
        if ( ref ($entry ) eq 'ARRAY'  ) {
Line 435... Line 437...
435
# Returns         : Relative path from the current directory to the base directory
437
# Returns         : Relative path from the current directory to the base directory
436
#
438
#
437
sub RelPath
439
sub RelPath
438
{
440
{
439
    my ($base, $here) = @_;
441
    my ($base, $here) = @_;
-
 
442
    unless (defined $base)
-
 
443
    {
-
 
444
        DebugTraceBack ('RelPath');
-
 
445
        Error ("Internal: 'RelPath(). base not defined'");
-
 
446
    }
440
 
447
 
441
    $here = $Cwd unless ( defined $here );
448
    $here = $Cwd unless ( defined $here );
442
    my @base = split ('/', $base );
449
    my @base = split ('/', $base );
443
    my @here = split ('/', $here );
450
    my @here = split ('/', $here );
444
    my $result;
451
    my $result;
Line 492... Line 499...
492
#
499
#
493
sub AbsPath
500
sub AbsPath
494
{
501
{
495
    my ($dpath, $here, $mode) = @_;
502
    my ($dpath, $here, $mode) = @_;
496
    my @result;
503
    my @result;
-
 
504
    unless (defined $dpath)
-
 
505
    {
-
 
506
        DebugTraceBack ();
-
 
507
        Error ("Internal: 'AbsPath(). dpath not defined'");
-
 
508
    }
497
 
509
 
498
    #
510
    #
499
    #   If we have a relative path then prepend the current directory
511
    #   If we have a relative path then prepend the current directory
500
    #   An absolute path is:
512
    #   An absolute path is:
501
    #           /aaa/aa/aa
513
    #           /aaa/aa/aa
Line 534... Line 546...
534
    }
546
    }
535
 
547
 
536
    #
548
    #
537
    #   Create a nice directory name again.
549
    #   Create a nice directory name again.
538
    #
550
    #
539
    return join ( '/', @result );
551
    my $absPath = join ( '/', @result );
-
 
552
    return $absPath;
540
}
553
}
541
 
554
 
542
#-------------------------------------------------------------------------------
555
#-------------------------------------------------------------------------------
543
# Function        : FullPath
556
# Function        : FullPath
544
#
557
#
Line 702... Line 715...
702
    #
715
    #
703
    #   Cleanup the the user input. Remove double delimiters and ensure there
716
    #   Cleanup the the user input. Remove double delimiters and ensure there
704
    #   is no trailing delimiter
717
    #   is no trailing delimiter
705
    #
718
    #
706
    $dpath =~ s~\\~/~g;
719
    $dpath =~ s~\\~/~g;
-
 
720
    $dpath =~ s~^\./~~g;
-
 
721
    $dpath =~ s~/\./~/~g;
707
    $dpath =~ s~/+~/~g;
722
    $dpath =~ s~/+~/~g;
708
    $dpath =~ s~/$~~g;
723
    $dpath =~ s~/$~~g;
709
    $dpath =~ s~/\./~/~g;
-
 
710
 
724
 
711
    #
725
    #
712
    #   Walk the bits and remove "xxx/.." directories
726
    #   Walk the bits and remove "xxx/.." directories
713
    #
727
    #
714
    foreach ( split ( '/', $dpath ) )
728
    foreach ( split ( '/', $dpath ) )
Line 727... Line 741...
727
            }
741
            }
728
        }
742
        }
729
    }
743
    }
730
 
744
 
731
    my $result = join ( '/', @result );
745
    my $result = join ( '/', @result );
-
 
746
    $result = '.' unless $result;
732
    Debug("CleanPath: Result: $result");
747
    Debug("CleanPath: Result: $result");
733
    return $result;
748
    return $result;
734
}
749
}
735
 
750
 
736
#-------------------------------------------------------------------------------
751
#-------------------------------------------------------------------------------
-
 
752
# Function        : CatPaths 
-
 
753
#
-
 
754
# Description     : Join path elemanets together with a '/'
-
 
755
#                   Clean up the result
-
 
756
#
-
 
757
# Inputs          : Patth elemenst to join    
-
 
758
#
-
 
759
# Returns         : Cleaned up path elements
-
 
760
#
-
 
761
sub CatPaths
-
 
762
{
-
 
763
    Debug("CatPaths: @_ ");
-
 
764
    return CleanPath join ('/', @_);
-
 
765
}
-
 
766
 
-
 
767
#-------------------------------------------------------------------------------
737
# Function        : StripDrive
768
# Function        : StripDrive
738
#
769
#
739
# Description     : Strip any leading drive speification
770
# Description     : Strip any leading drive speification
740
#
771
#
741
# Inputs          : $fname          - Path to process
772
# Inputs          : $fname          - Path to process