projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add EXIT_FAILURE, EXIT_SUCCESS to syscall.h,
[pintos-anon]
/
src
/
examples
/
ls.c
diff --git
a/src/examples/ls.c
b/src/examples/ls.c
index d927bc1da696763fae6c2a844d7a4df7c1062eac..fbe27a1e5023312bf0a421969ed8989f9d24b4c6 100644
(file)
--- a/
src/examples/ls.c
+++ b/
src/examples/ls.c
@@
-12,14
+12,14
@@
#include <stdio.h>
#include <string.h>
#include <stdio.h>
#include <string.h>
-static
void
+static
bool
list_dir (const char *dir, bool verbose)
{
int dir_fd = open (dir);
if (dir_fd == -1)
{
printf ("%s: not found\n", dir);
list_dir (const char *dir, bool verbose)
{
int dir_fd = open (dir);
if (dir_fd == -1)
{
printf ("%s: not found\n", dir);
- return
;
+ return
false;
}
if (isdir (dir_fd))
}
if (isdir (dir_fd))
@@
-60,13
+60,16
@@
list_dir (const char *dir, bool verbose)
}
else
printf ("%s: not a directory\n", dir);
}
else
printf ("%s: not a directory\n", dir);
- close (dir_fd);
+ close (dir_fd);
+ return true;
}
int
main (int argc, char *argv[])
{
}
int
main (int argc, char *argv[])
{
+ bool success = true;
bool verbose = false;
bool verbose = false;
+
if (argc > 1 && !strcmp (argv[1], "-l"))
{
verbose = true;
if (argc > 1 && !strcmp (argv[1], "-l"))
{
verbose = true;
@@
-75,12
+78,13
@@
main (int argc, char *argv[])
}
if (argc <= 1)
}
if (argc <= 1)
- list_dir (".", verbose);
+
success =
list_dir (".", verbose);
else
{
int i;
for (i = 1; i < argc; i++)
else
{
int i;
for (i = 1; i < argc; i++)
- list_dir (argv[i], verbose);
+ if (!list_dir (argv[i], verbose))
+ success = false;
}
}
- return
0
;
+ return
success ? EXIT_SUCCESS : EXIT_FAILURE
;
}
}