Mercurial > hg > toybox
comparison toys/realpath.c @ 470:7d4dbde67dfb
Move realpath from loopfiles() to a for loop, so we don't get hung on read permission for file data when we just want to look at directory info.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 17 Feb 2012 05:27:37 -0600 |
parents | 6378ca1da18e |
children |
comparison
equal
deleted
inserted
replaced
469:6378ca1da18e | 470:7d4dbde67dfb |
---|---|
10 | 10 |
11 config REALPATH | 11 config REALPATH |
12 bool "realpath" | 12 bool "realpath" |
13 default y | 13 default y |
14 help | 14 help |
15 usage: realpath FILE... | |
16 | |
15 Display the canonical absolute pathname | 17 Display the canonical absolute pathname |
16 */ | 18 */ |
17 | 19 |
18 #include "toys.h" | 20 #include "toys.h" |
19 | 21 |
20 static void do_realpath(int fd, char *name) | |
21 { | |
22 if (!realpath(name, toybuf)) | |
23 perror_exit("realpath: cannot access %s'", name); | |
24 | |
25 xprintf("%s\n", toybuf); | |
26 } | |
27 | |
28 void realpath_main(void) | 22 void realpath_main(void) |
29 { | 23 { |
30 loopfiles(toys.optargs, do_realpath); | 24 char **s = toys.optargs; |
25 for (s = toys.optargs; *s; s++) { | |
26 if (!realpath(*s, toybuf)) { | |
27 perror_msg("cannot access '%s'", *s); | |
28 toys.exitval = 1; | |
29 } else xputs(toybuf); | |
30 } | |
31 } | 31 } |