File: diritertest.cc

package info (click to toggle)
wvstreams 4.0.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,420 kB
  • ctags: 6,518
  • sloc: cpp: 52,544; sh: 5,770; ansic: 810; makefile: 461; tcl: 114; perl: 18
file content (45 lines) | stat: -rw-r--r-- 1,099 bytes parent folder | download | duplicates (11)
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
/*
 * Worldvisions Weaver Software:
 *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
 *
 * Test program for WvDirIter.  Takes a directory on the command line, and
 * prints everything it sees.
 *
 */

#define __STDC_FORMAT_MACROS

#include <sys/types.h>
#include <inttypes.h>
#include "wvdiriter.h"

int main( int argc, char * argv[] )
/*********************************/
{
    WvString dirname;
    bool     recurse = false;
    bool     skip_mounts = false;

    for( int i=1; i<argc; i++ ) {
        if( !strcmp( argv[i], "-R" ) )
            recurse = true;
        else if ( !strcmp( argv[i], "-S" ) )
            skip_mounts = true;
        else
            dirname = argv[i];
    }

    if( !dirname ) {
        fprintf( stderr, "Usage: %s [-R] [-S] directory\n", argv[0] );
        return( -1 );
    }

    WvDirIter i( dirname, recurse, skip_mounts );
    for( i.rewind(); i.next(); ) {
        printf( "%s -- (filename = [%s]) -- mode %u -- size %" PRIu64 "\n", 
		(const char *) i->fullname, i->name.cstr(), i->st_mode, 
		uint64_t(i->st_size) );
    }

    return( 0 );
}