leafnode  1.12.0
About: Leafnode is a store & forward NNTP proxy for small (dialup) sites.
  Fossies Dox: leafnode-1.12.0.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

archivefaq.pl
Go to the documentation of this file.
1#!/usr/bin/perl
2
3# trailing slash!
4$archive = "/var/spool/news/faq.archive/";
5
6chdir("/var/spool/news/news/answers/") || die "can't chdir to FAQ directory";
7
8opendir(FAQ, ".") || die "can't open FAQ directory";
9@faqs = grep(/^\d+$/, readdir(FAQ));
10closedir(FAQ);
11
12undef $/;
13foreach $artno ( @faqs ) {
14 if ( open(I, "< $artno") ) {
15 $_ = <I>;
16 close(I);
17 if ( $_ =~ /\nArchive-name: (\S+)\n/ ) {
18 $name = $archive . $1;
19 $dir = $name;
20 &mkpdir( $name );
21 unlink( $artno ) unless ( link( $artno, $name ) );
22 }
23 }
24}
25
26#
27# make parent directory of argument
28#
29sub mkpdir {
30 local( $dir ) = @_;
31
32 $dir =~ s-/[^/]+$--;
33 unlink $dir if ( -e $dir && ! -d _ );
34 unless ( -d _ ) {
35 &mkpdir( $dir );
36 mkdir $dir, 0775;
37 print "made ", $dir, "\n";
38 }
39}
public method mkpdir()
const char * name
Definition: miscutil.c:126
static void die(const char *tag)
Definition: quickmkdir.c:35