tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

coreconf.pl (2422B)


      1 #
      2 # This Source Code Form is subject to the terms of the Mozilla Public
      3 # License, v. 2.0. If a copy of the MPL was not distributed with this
      4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      5 sub recursive_copy {
      6    local($fromdir);
      7    local($todir);
      8    local(@dirlist);
      9    $fromdir = shift;
     10    $todir = shift;
     11  
     12    print STDERR "recursive copy called with $fromdir, $todir\n";
     13 
     14 #remove any trailing slashes.
     15    $fromdir =~ s/\/$//;
     16    $todir =~ s/\/$//;
     17    
     18    opendir(DIR, $fromdir);
     19    @dirlist = readdir DIR;
     20    close DIR;
     21 
     22 
     23    foreach $file (@dirlist) {
     24 if  (! (($file eq "." ) || ($file eq "..") )) {
     25     
     26     if (-d "$fromdir/$file") {
     27 	print STDERR "handling directory $todir/$file\n";
     28 	&rec_mkdir("$todir/$file");
     29 	&recursive_copy("$fromdir/$file","$todir/$file");
     30     }
     31     else {
     32 	print STDERR "handling file $fromdir/$file\n";
     33 	&my_copy("$fromdir/$file","$todir/$file");
     34     }
     35 }
     36    }
     37 }
     38 
     39 sub parse_argv {
     40 
     41 #    print STDERR "Parsing Variables\n";
     42 
     43    foreach $q ( @ARGV ) {
     44 if (! ($q =~ /=/)) {
     45     $var{$lastassigned} .= " $q";
     46 }
     47 else {
     48    $q =~ /^([^=]*)=(.*)/;
     49    $left = $1;
     50    $right = $2;
     51 
     52    $right =~ s/ *$//;
     53    $var{$left} = $right;
     54 
     55    $lastassigned = $left;
     56 
     57    }
     58 print STDERR "Assigned $lastassigned = $var{$lastassigned}\n";
     59    }
     60 }
     61 
     62 
     63 # usage: &my_copy("dir/fromfile","dir2/tofile");
     64 # do a 'copy' - files only, 'to' MUST be a filename, not a directory.
     65 
     66 # fix this to be able to use copy on win nt.
     67 
     68 sub my_copy {
     69    local($from);
     70    local($to);
     71    local($cpcmd);
     72 
     73    $from = shift;
     74    $to = shift;
     75 
     76    if ( ! defined $var{OS_ARCH}) {
     77 die "OS_ARCH not defined!";
     78    }
     79    else {
     80 if ($var{OS_ARCH} eq 'WINNT') {
     81     $cpcmd = 'cp';
     82     	}
     83 else {
     84     $cpcmd = 'cp';
     85     }
     86 print STDERR "COPYING: $cpcmd $from $to\n";
     87 system("$cpcmd $from $to");
     88    }
     89 }
     90 
     91 
     92 sub old_my_copy {
     93    local($from);
     94    local($to);
     95 
     96    $from = shift;
     97    $to = shift;
     98    open(FIN, "<$from") || die("Can't read from file $from\n");
     99    if ( ! open(FOUT,">$to")) {
    100 close FIN;
    101 die "Can't write to file $to\n";
    102    }
    103    while (read(FIN, $buf, 100000)) {
    104 print FOUT $buf;
    105    }
    106    close (FIN);
    107    close (FOUT);
    108 }
    109 
    110 sub rec_mkdir {
    111    local($arg);
    112    local($t);
    113    local($q);
    114 
    115    $arg = shift;
    116    $t = "";
    117    foreach $q (split(/\//,$arg)) {
    118 $t .= $q;
    119 if (! ($t =~ /\.\.$/)) {
    120     if ($t =~ /./) {
    121 	mkdir($t,0775);
    122     }
    123 }
    124 $t.= '/';
    125    }
    126 }
    127 
    128 1;