9 use constant FILENAME=>".cvslinks";
10 use constant ENTRIES=>"CVS/Entries";
13 our($opt_u,$opt_c,$opt_d,$opt_r,$opt_R,$opt_l,$opt_v);
16 die "-u (update), -c (commit) or -d (delete) required" if !$opt_u && !$opt_c && !$opt_d;
17 die "-r (recursive)/-R (recursive w/o CVS) and -l (local) are conflicting"
18 if ($opt_r || $opt_R) && $opt_l;
20 $opt_r=1 if !$opt_r && !$opt_R && !$opt_l; # default
39 print cwd().": $msg\n";
45 opendir D,"." or die "Cannot open directory \".\": $!";
48 verbose "Deleting local link $_";
57 open L,FILENAME or die "File ".FILENAME." cannot be opened: $!";
59 verbose "Creating links from ".FILENAME;
65 next if $cmt || $cmt_old || /^$/; # comment or empty-file (->empty-dir) stub line
66 /^(.+)\t(.+)$/ or warn "Unrecognized line: $_";
67 verbose "Creating link $1";
68 symlink $2,$1 or warn "symlink(\"$2\"->\"$1\"): $!";
76 opendir D,"." or die "Cannot open directory \".\": $!";
77 verbose "Storing links to ".FILENAME;
79 if (open L,FILENAME) {
84 next unless $cmt || $cmt_old; # comment
89 $cmtblock="\n" if !$cmtblock; # empty-file (->empty-dir) stub line
90 open L,">".FILENAME or die "File ".FILENAME." cannot be created: $!";
94 my $target=readlink or die "Cannot read link $_: $!";
95 verbose "Storing link $_";
96 print L "$_\t$target\n";
107 warn "Cannot chdir to $dir: $!";
110 verbose "Descented to child directory";
112 chdir ".." or die "Cannot return back to ..: $!";
113 verbose "Back in parent directory";
119 if (!open C,ENTRIES) {
120 warn "Cannot open file \"".ENTRIES."\": $!";
125 next if !m#^D/([^/]*)/#;
134 opendir D,"." or die "Cannot open directory \".\": $!";
136 # Beware of symlinked-directories !
137 next if -l || ! -d || $_ eq "." || $_ eq "..";