aboutsummaryrefslogtreecommitdiff
path: root/tests/dir-iterator/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dir-iterator/driver.cxx')
-rw-r--r--tests/dir-iterator/driver.cxx28
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/dir-iterator/driver.cxx b/tests/dir-iterator/driver.cxx
index 9eebb9f..7e4de84 100644
--- a/tests/dir-iterator/driver.cxx
+++ b/tests/dir-iterator/driver.cxx
@@ -30,24 +30,34 @@ operator<< (ostream& os, entry_type e)
int
main (int argc, const char* argv[])
{
- if (argc != 2)
+ if (!(argc == 2 || (argc == 3 && argv[1] == string ("-v"))))
{
- cerr << "usage: " << argv[0] << " <dir>" << endl;
+ cerr << "usage: " << argv[0] << " [-v] <dir>" << endl;
return 1;
}
+ bool v (argc == 3);
+ const char* d (argv[argc - 1]);
+
try
{
- for (const dir_entry& de: dir_iterator (dir_path (argv[1])))
+ for (const dir_entry& de: dir_iterator (dir_path (d)))
{
- cerr << de.ltype () << " ";
+ entry_type lt (de.ltype ());
+ entry_type t (lt == entry_type::symlink ? de.ltype () : lt);
+ const path& p (de.path ());
+
+ if (v)
+ {
+ cerr << lt << " ";
- if (de.ltype () == entry_type::symlink)
- cerr << de.type ();
- else
- cerr << " ";
+ if (lt == entry_type::symlink)
+ cerr << t;
+ else
+ cerr << " ";
- cerr << " " << de.path () << endl;
+ cerr << " " << p << endl;
+ }
}
}
catch (const exception& e)