Skip to content

Commit

Permalink
add phl options
Browse files Browse the repository at this point in the history
  • Loading branch information
sheimi committed Feb 17, 2012
1 parent 36f8d88 commit 14a1d9d
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
24 changes: 23 additions & 1 deletion README
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions README.md
@@ -1,6 +1,6 @@
TINY-FIND
==============
Homework -- to fake a command -- find >_<!~~~
Homework -- to fake a command -- find >_<!~~~

## OVERVIEW
This is my homework of "Linux Programming".
Expand All @@ -12,7 +12,27 @@ Homework -- to fake a command -- find >_<!~~~
## SPECIFICATION
usage: tinyfind [-H | -L | -P] [-EXdsx] [-f path] path ... [expression]
tinyfind [-H | -L | -P] [-EXdsx] -f path [path ...] [expression]
### Logic Expression
### OPTIONS
-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 EXPRESSIONS
exps can linked with logic expression and '(', ')'
-not
-and
Expand Down
19 changes: 18 additions & 1 deletion src/filter.c
Expand Up @@ -100,7 +100,24 @@ int execute_filter(Filter * filter) {
}

bool execute_filter_tree(FTSENT * ent) {
stat(ent->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;
Expand Down
3 changes: 3 additions & 0 deletions src/parser.c
Expand Up @@ -26,6 +26,9 @@ char * ALL_EXP[] = {
};

char * OPTIONS[] = {
"-P",
"-H",
"-L",
"-exec",
"-print0",
"-print",
Expand Down

0 comments on commit 14a1d9d

Please sign in to comment.