CVS tree to NSI

From NSIS Wiki
Jump to navigationJump to search
Author: titoo (talk, contrib)


Description

Recurse through a CVS tree to create the File CreateDirectory SetOutPath directives This is a perl script.

Example

Example to have the results in a text file:

perl listfilesnsi.pl v:/icas/work $INSTDIR\work > test.txt

It gives something like:

CreateDirectory "$INSTDIR\work"
SetOutPath "$INSTDIR\work"
File "v:\icas\work\graf.csv"
File "v:\icas\work\MIX.CSV"
File "v:\icas\work\NAME.CSV"
File "v:\icas\work\PLOT.CSV"
File "v:\icas\work\SURFACE.CSV"
File "v:\icas\work\WATER.CSV"
etc....

It avoids all the CVS folders.

#!/usr/bin/perl
 
use File::Find;
 
(@ARGV<2) && (die "Must specify a start dir and a start dir remplacement\n");
 
$startdir    = $ARGV[0];
$remplace = $ARGV[1];
$currentdir = "";
 
%hash = ();
@fichiers = ();
 
find(\&handleFind, $startdir);
 
exit;
 
sub handleFind {
    my $foundFile = $File::Find::name;
    my $dir = $File::Find::dir;
    if ($dir =~ m/\/CVS$/) { return true; }
    if ($foundFile =~ m/\/CVS$/) { return true; }
    if ($currentdir ne $dir) {
        $currentdir = $dir;
        $dir =~ s/$startdir/$remplace/i;
        $dir =~ s/\//\\/gi;
        print "CreateDirectory \"$dir\"\n";
        print "SetOutPath \"$dir\"\n";
    }
    if (!(-d $foundFile)) {
        $foundFile =~ s/\//\\/gi;
        print "File \"" . $foundFile . "\"\n";
    }
}

Very simple... Enjoy... If you want to give a credit just create a link to xhtml.net on your webpage.