Subversion Repositories svn.Prod repos

Rev

Rev 30 | Rev 37 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30 Rev 31
1
program filefind;
1
program filefind;
2
Uses sysutils;
2
Uses    sysutils;
3
var     directory : string;
3
var     directory : string;
4
 
4
 
-
 
5
// ============================================================================
-
 
6
// Functions
-
 
7
// ============================================================================
-
 
8
 
5
procedure traverse(directory : string);
9
procedure traverse(directory : string);
6
var     curdir1, curdir2 : string;
10
var     curdir1, curdir2 : string;
7
        Info : TSearchRec;
11
        Info : TSearchRec;
8
        pfile : string;
12
        pfile : string;
9
begin
13
begin
10
        curdir1 := GetCurrentDir;
14
        curdir1 := GetCurrentDir;
11
        chdir(directory);
15
        chdir(directory);
12
        curdir2 := GetCurrentDir;
16
        curdir2 := GetCurrentDir;
13
        FindFirst(directory + '/*', faAnyFile or faHidden, Info);
17
        FindFirst(directory + '/*', faAnyFile or faHidden, Info);
14
        repeat
18
        repeat
15
                if ((Info.name <> '..') and (Info.name <> '.'))
19
                if ((Info.name <> '..') and (Info.name <> '.'))
16
                then
20
                then
17
                        begin
21
                        begin
18
                        pfile := curdir2 + '/' + Info.name;
22
                        pfile := curdir2 + '/' + Info.name;
19
                        Writeln(pfile);
23
                        Writeln(pfile);
20
                        if (DirectoryExists(pfile))
24
                        if (DirectoryExists(pfile))
21
                        then
25
                        then
22
                                traverse(pfile)
26
                                traverse(pfile)
23
                        end
27
                        end
24
        until FindNext(Info) <> 0;
28
        until FindNext(Info) <> 0;
25
        chdir(curdir1);
29
        chdir(curdir1);
26
end;
30
end;
27
 
31
 
28
procedure start_traverse(directory : string);
32
procedure start_traverse(directory : string);
29
begin
33
begin
30
        Writeln(directory);
34
        Writeln(directory);
31
        traverse(directory);
35
        traverse(directory);
32
end;
36
end;
-
 
37
 
-
 
38
// ============================================================================
-
 
39
// Main
-
 
40
// ============================================================================
33
 
41
 
34
begin
42
begin
35
        directory := ParamStr(1);
43
        directory := ParamStr(1);
36
        if (ParamCount = 1)
44
        if (ParamCount = 1)
37
        then
45
        then
38
                if DirectoryExists(directory)
46
                if DirectoryExists(directory)
39
                then
47
                then
40
                        start_traverse(directory)
48
                        start_traverse(directory)
41
                else
49
                else
42
                        Writeln ('ERROR: Not a directory : ', directory)
50
                        Writeln ('ERROR: Not a directory : ', directory)
43
        else
51
        else
44
                Writeln('ERROR: Give directory as argument');
52
                Writeln('ERROR: Give directory as argument');
45
end.
53
end.
46
 
54