|
Revision 6, 1.1 kB
(checked in by jcc7, 3 years ago)
|
Made more progress in developing convertToWiki and added some files.
|
| Line | |
|---|
| 1 |
/* |
|---|
| 2 |
|
|---|
| 3 |
File: find_files.d |
|---|
| 4 |
Author: J C Calvarese |
|---|
| 5 |
License: Public Domain |
|---|
| 6 |
Purpose: Use recls to find a file. |
|---|
| 7 |
|
|---|
| 8 |
Description: |
|---|
| 9 |
Lists files that fit a certain pattern (uses the version of std.recls that's built into Phobos) |
|---|
| 10 |
|
|---|
| 11 |
Written: 2005/08/26 (Updated 2005/11/02) |
|---|
| 12 |
|
|---|
| 13 |
*/ |
|---|
| 14 |
|
|---|
| 15 |
import std.recls; /* Search, Entry */ |
|---|
| 16 |
import std.stdio; /* writefln */ |
|---|
| 17 |
|
|---|
| 18 |
char[] searchPath; |
|---|
| 19 |
char[] filePattern; |
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
void main(char[][] args) |
|---|
| 23 |
{ |
|---|
| 24 |
if(args.length < 3) |
|---|
| 25 |
{ |
|---|
| 26 |
writefln("Usage: find_files.exe search_path file_pattern"); |
|---|
| 27 |
return; |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
searchPath = args[1]; |
|---|
| 31 |
if(searchPath[0..1] == "\"") |
|---|
| 32 |
searchPath = searchPath[1..$-2]; |
|---|
| 33 |
|
|---|
| 34 |
filePattern = args[2]; |
|---|
| 35 |
if(filePattern[0..1] == "\"") |
|---|
| 36 |
filePattern = filePattern[1..$-2]; |
|---|
| 37 |
|
|---|
| 38 |
Search search = new Search(searchPath, filePattern, RECLS_FLAG.RECLS_F_RECURSIVE); |
|---|
| 39 |
foreach(Entry entry; search) |
|---|
| 40 |
{ |
|---|
| 41 |
with(entry) |
|---|
| 42 |
{ |
|---|
| 43 |
if(!ShortFile()) |
|---|
| 44 |
printf("%.*s%.*s\n", DirectoryPath(), File()); |
|---|
| 45 |
else |
|---|
| 46 |
printf("%.*s%.*s (%.*s)\n", DirectoryPath(), File(), ShortFile()); |
|---|
| 47 |
} |
|---|
| 48 |
} |
|---|
| 49 |
} |
|---|