Subversion Repositories DevTools

Rev

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

Rev 5969 Rev 6133
Line 27... Line 27...
27
#                    TouchFile                  - Touch a file
27
#                    TouchFile                  - Touch a file
28
#                    FileIsNewer                - Test if newer
28
#                    FileIsNewer                - Test if newer
29
#                    DisplayPath                - Generate a Path that can be displayed
29
#                    DisplayPath                - Generate a Path that can be displayed
30
#                    FileCreate                 - Create a simple text file
30
#                    FileCreate                 - Create a simple text file
31
#                    FileAppend                 - Append to a simple text file
31
#                    FileAppend                 - Append to a simple text file
-
 
32
#                    TagFileMatch               - Simple (oneline) file content matcher
-
 
33
#                    TagFileRead                - Return the contents of the tagfile
32
#                    RmDirTree                  - Remove a directory tree
34
#                    RmDirTree                  - Remove a directory tree
33
#           ReExported
35
#           ReExported
34
#                    catdir                     - Concatenate path elements
36
#                    catdir                     - Concatenate path elements
35
#                    catfile                    - Concatenate path elements and a file
37
#                    catfile                    - Concatenate path elements and a file
36
#
38
#
Line 75... Line 77...
75
                FileIsNewer
77
                FileIsNewer
76
                DisplayPath
78
                DisplayPath
77
                TruePath
79
                TruePath
78
                FileCreate
80
                FileCreate
79
                FileAppend
81
                FileAppend
-
 
82
                TagFileMatch
-
 
83
                TagFileRead
80
                RmDirTree
84
                RmDirTree
81
                catfile
85
                catfile
82
                catdir
86
                catdir
83
 
87
 
84
                $ScmPathSep
88
                $ScmPathSep
Line 284... Line 288...
284
    }
288
    }
285
    close $fh;
289
    close $fh;
286
}
290
}
287
 
291
 
288
#-------------------------------------------------------------------------------
292
#-------------------------------------------------------------------------------
-
 
293
# Function        : TagFileMatch 
-
 
294
#
-
 
295
# Description     : Test the contents of a simple (one line) file against a string    
-
 
296
#
-
 
297
# Inputs          : $tfile      - Name of the tag file
-
 
298
#                   $tag        - Tag to match 
-
 
299
#
-
 
300
# Returns         : True - is a match
-
 
301
#
-
 
302
sub TagFileMatch
-
 
303
{
-
 
304
    my ($tfile, $tag) = @_;
-
 
305
    return 0 unless -f $tfile;
-
 
306
 
-
 
307
    open( my $file, '<', $tfile) || return 0;
-
 
308
    my $text = <$file>;
-
 
309
    close $file;
-
 
310
 
-
 
311
    $text = '' unless defined ($text);
-
 
312
    # Remove trailing new line and white space
-
 
313
    $text =~ s~\s*$~~;
-
 
314
    Debug("TagFileMatch:'$text':'$tag'", $text eq $tag );
-
 
315
 
-
 
316
    return $text eq $tag;
-
 
317
}
-
 
318
 
-
 
319
#-------------------------------------------------------------------------------
-
 
320
# Function        : TagFileRead
-
 
321
#
-
 
322
# Description     : Read the contents of a simple (one line) file against a string    
-
 
323
#
-
 
324
# Inputs          : $tfile      - Name of the tag file
-
 
325
#
-
 
326
# Returns         : One line of the file
-
 
327
#
-
 
328
sub TagFileRead
-
 
329
{
-
 
330
    my ($tfile) = @_;
-
 
331
    return "" unless -f $tfile;
-
 
332
 
-
 
333
    open( my $file, '<', $tfile) || Error("Cannot open '$tfile'. $!");
-
 
334
    my $text = <$file>;
-
 
335
    close $file;
-
 
336
 
-
 
337
    $text = '' unless defined ($text);
-
 
338
    $text =~ s~\s*$~~;
-
 
339
    return $text;
-
 
340
}
-
 
341
 
-
 
342
#-------------------------------------------------------------------------------
289
# Function        : FileIsNewer
343
# Function        : FileIsNewer
290
#
344
#
291
# Description     : Test two files to see if the files are newer
345
# Description     : Test two files to see if the files are newer
292
#
346
#
293
# Inputs          : file1
347
# Inputs          : file1
Line 390... Line 444...
390
 
444
 
391
    Debug("RelPath: Here  : $here");
445
    Debug("RelPath: Here  : $here");
392
    Debug("RelPath: Source: $base");
446
    Debug("RelPath: Source: $base");
393
 
447
 
394
    # Not absolute - just return it
448
    # Not absolute - just return it
395
    return $base unless ( $base =~ m~^/~ );
449
    return $base unless ( $base =~ m~^/~ || $base =~ m~^\w+:/~ );
396
    
450
 
397
    #
451
    #
398
    #   Remove common bits from the head of both lists
452
    #   Remove common bits from the head of both lists
399
    #
453
    #
400
    while ( $#base >= 0 && $#here >= 0 && $base[0] eq $here[0] )
454
    while ( $#base >= 0 && $#here >= 0 && $base[0] eq $here[0] )
401
    {
455
    {
Line 626... Line 680...
626
#-------------------------------------------------------------------------------
680
#-------------------------------------------------------------------------------
627
# Function        : CleanPath
681
# Function        : CleanPath
628
#
682
#
629
# Description     : Cleanup a path
683
# Description     : Cleanup a path
630
#                   Remove xxx/.. constructs
684
#                   Remove xxx/.. constructs
-
 
685
#                   Replace /./ constructs with /
631
#
686
#
632
# Note            : Will not perform error detection on badly formed
687
# Note            : Will not perform error detection on badly formed
633
#                   absolute paths.
688
#                   absolute paths.
634
#
689
#
635
# Inputs          : Source file path
690
# Inputs          : Source file path
Line 647... Line 702...
647
    #   Cleanup the the user input. Remove double delimiters and ensure there
702
    #   Cleanup the the user input. Remove double delimiters and ensure there
648
    #   is no trailing delemiter
703
    #   is no trailing delemiter
649
    #
704
    #
650
    $dpath =~ s~/+~/~g;
705
    $dpath =~ s~/+~/~g;
651
    $dpath =~ s~/$~~g;
706
    $dpath =~ s~/$~~g;
-
 
707
    $dpath =~ s~/\./~/~g;
652
 
708
 
653
    #
709
    #
654
    #   Walk the bits and remove "xxx/.." directories
710
    #   Walk the bits and remove "xxx/.." directories
655
    #
711
    #
656
    foreach ( split ( '/', $dpath ) )
712
    foreach ( split ( '/', $dpath ) )