X-Git-Url: https://git.jankratochvil.net/?a=blobdiff_plain;f=bin%2Fcvsutil;h=fd833d515aee40326ee732ff823a356322a6a2c3;hb=93df9f0488349fb5e944f8f1a9f5b9ae172c50a5;hp=27a4ab5f54ec79540625fe9018c283fb17971273;hpb=9d45569122b4c86a98c42fee954885f33af27e8d;p=nethome.git diff --git a/bin/cvsutil b/bin/cvsutil index 27a4ab5..fd833d5 100755 --- a/bin/cvsutil +++ b/bin/cvsutil @@ -1,4 +1,6 @@ #! /usr/bin/perl +# +# $Id$ use strict; use warnings; @@ -118,6 +120,17 @@ sub localdircore fordirs \&localdir,@dir_dirs; } +sub filterout +{ +my($from,@what)=@_; + + my %hash=map { $_=>1; } @$from; + for (@what) { + delete $hash{$_}; + } + return keys %hash; +} + sub localreaddir { local *E; @@ -146,6 +159,7 @@ sub localreaddir } } close I; + @dir_ignores=filterout \@dir_ignores,@dir_dirs,@dir_files; } else { mayfatal "File \"".CVSIGNORE."\" cannot be opened" if !$!{ENOENT}; @@ -156,13 +170,8 @@ sub localreaddir mayfatal "Cannot read directory \".\""; return 0; } - @dir_workings=readdir D; + @dir_workings=filterout [readdir D],@dir_dirs,@dir_files,@dir_ignores,@all_ignore,".",".."; closedir D; - my %delworkings=map { $_=>1; } @dir_workings; - for (@dir_dirs,@dir_files,@dir_ignores,@all_ignore,".","..") { - delete $delworkings{$_}; - } - @dir_workings=keys %delworkings; return 1; } @@ -194,11 +203,12 @@ my($filename)=@_; sub localactionrootset { local *R; - if (!open R,'>',ROOT) { + if (!open R,'+<',ROOT) { mayfatal "File \"".ROOT."\" cannot be written"; return; } print R "$opt_root\n"; + truncate R,tell R; close R; }