summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/support/latexmk/example_rcfiles/clean_pattern_latexmkrc
blob: 9a5fa3ac527a8569bc593a2d7801a4a3b84ead84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# To allow more general pattern in $clean_ext instead of just an
# extension or something containing %R.
# This is done by overriding latexmk's cleanup1 subroutine.

# Here is an example of a useful application:
$clean_ext = "*-eps-converted-to.pdf";

sub cleanup1 {
    # Usage: cleanup1( directory, pattern_or_ext_without_period, ... )
    #
    # The directory is a fixed name, so I must escape any glob metacharacters
    #   in it:
    print "========= MODIFIED cleanup1 cw latexmk v. 4.39 and earlier\n";
    my $dir = fix_pattern( shift );

    # Change extensions to glob patterns
    foreach (@_) { 
        # If specified pattern is pure extension, without period,
        #   wildcard character (?, *) or %R,
        # then prepend it with directory/root_filename and period to
        #   make a full file specification
        # Else leave the pattern as is, to be used by glob.
        # New feature: pattern is unchanged if it contains ., *, ?
        (my $name = (/%R/ || /[\*\.\?]/) ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/;
        unlink_or_move( glob( "$name" ) );
    }
} #END cleanup1