Subversion Repositories svn.Prod repos

Rev

Rev 30 | Rev 37 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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