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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Find;
#********************************************
#* list script variable *********************
#********************************************
my $etest_path; # data
my $size_files = 0;
my $size_dirs = 0;
$etest_path = shift or usage() and die;
# -- check all etest input files in etest directory
# save all files in @files, all folders in @dirs
find( \&push_filename, "$etest_path" );
my(@files, @dirs);
sub push_filename {
push @files, $File::Find::name if -f $_;
push @dirs, $File::Find::name if -d $_;
}
# -- parse two lists
# create text file with all patterns path
open(OUT, ">$etest_path/patterns_path.txt") and print STDERR " o file [patterns_path.txt] created\n" or print STDERR " --> !Cannot open OUTPUT [patterns_path.txt]!\n" and die;
while(exists $files[$size_files]){
print " -- $files[$size_files]\n";
# -- output file : no process
if($files[$size_files] =~ /(.out|.out_|.txt|.cod|.cyc_)$/i){}
# -- save etest input
else{ print OUT "$files[$size_files]\n";
# -- add three words at eof (0x0000, 0x0000, 0xFFFE)
&add_data_at_eof($files[$size_files]); }
$size_files++;
}
while(exists $dirs[$size_dirs]){
print " ** $dirs[$size_dirs]\n";
$size_dirs++;
}
sub add_data_at_eof{
my $file = $_[0];
my @values = (0,0,65534);
# -- open input file
sysopen (FIC ,">>$file",O_RDWR) or print STDERR " --> !Cannot open file [$file]!\n" and die;
# -- write three data at eof
for my $value(@values){
my $temp=pack('S',$value);
syswrite(FIC,$temp,2);
} |
Partager