From 14a1d9d2abaae400ba233622de0ab532d06b037b Mon Sep 17 00:00:00 2001 From: sheimi Date: Fri, 17 Feb 2012 13:39:12 +0800 Subject: [PATCH] add phl options --- README | 24 +++++++++++++++++++++++- README.md | 24 ++++++++++++++++++++++-- src/filter.c | 19 ++++++++++++++++++- src/parser.c | 3 +++ 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/README b/README index abafb48..7c5777f 100644 --- a/README +++ b/README @@ -18,8 +18,30 @@ make or make DEBUG=1 for debug version ---------------- usage: tinyfind [-H | -L | -P] [-EXdsx] [-f path] path ... [expression] tinyfind [-H | -L | -P] [-EXdsx] -f path [path ...] [expression] + +~~~~~~~ +OPRIONS +~~~~~~~ +-H Cause the file information and file type (see stat(2)) returned + for each symbolic link specified on the command line to be those + of the file referenced by the link, not the link itself. If the + referenced file does not exist, the file information and type + will be for the link itself. File information of all symbolic + links not on the command line is that of the link itself. + +-L Cause the file information and file type (see stat(2)) returned + for each symbolic link to be those of the file referenced by the + link, not the link itself. If the referenced file does not + exist, the file information and type will be for the link itself. + This option is equivalent to the deprecated -follow primary. + +-P Cause the file information and file type (see stat(2)) returned + for each symbolic link to be those of the link itself. This is + the default. + + ~~~~~~~~~~~~~~~~ -Logic Expression +LOGIC EXPRESIONS ~~~~~~~~~~~~~~~~ exps can linked with logic expression and '(', ')' -not diff --git a/README.md b/README.md index 6b5bbc3..8663f3e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ TINY-FIND ============== -Homework -- to fake a command -- find >___fts_path, &status); +#ifdef DEBUG + fprintf(stderr, "file level: %d\n", ent->fts_level); +#endif + switch(options.symbol_handle) { + case S_L: + stat(ent->fts_path, &status); + break; + case S_P: + lstat(ent->fts_path, &status); + break; + case S_H: + if (ent->fts_level <= 1) { + stat(ent->fts_path, &status); + } else { + lstat(ent->fts_path, &status); + } + break; + } cur_ent = ent; bool passed = execute_filter(filter_tree.passed); return passed; diff --git a/src/parser.c b/src/parser.c index f7e271d..3a057c5 100644 --- a/src/parser.c +++ b/src/parser.c @@ -26,6 +26,9 @@ char * ALL_EXP[] = { }; char * OPTIONS[] = { + "-P", + "-H", + "-L", "-exec", "-print0", "-print",