|
|
@ -5,16 +5,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
static void
|
|
|
|
usage(std::ostream& os, const char* name, int code){
|
|
|
|
usage(std::ostream& os, const char* name, int code){
|
|
|
|
os << "usage: " << name << " -h | paths...\n";
|
|
|
|
os << "usage: " << name << " -h | [ -lR ] paths...\n";
|
|
|
|
|
|
|
|
os << " -d: list directories themselves, not their contents\n";
|
|
|
|
|
|
|
|
os << " -l: use a long listing format\n";
|
|
|
|
|
|
|
|
os << " -R: list subdirectories recursively\n";
|
|
|
|
os << " -h: print usage information\n";
|
|
|
|
os << " -h: print usage information\n";
|
|
|
|
os << std::flush;
|
|
|
|
os << std::flush;
|
|
|
|
exit(code);
|
|
|
|
exit(code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv){
|
|
|
|
int main(int argc, char** argv){
|
|
|
|
|
|
|
|
bool longlisting = false;
|
|
|
|
|
|
|
|
bool recursedirs = false;
|
|
|
|
|
|
|
|
bool directories = false;
|
|
|
|
int c;
|
|
|
|
int c;
|
|
|
|
while((c = getopt(argc, argv, "h")) != -1){
|
|
|
|
while((c = getopt(argc, argv, "dhlR")) != -1){
|
|
|
|
switch(c){
|
|
|
|
switch(c){
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
|
|
|
|
directories = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
|
|
|
|
longlisting = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'R':
|
|
|
|
|
|
|
|
recursedirs = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
case 'h':
|
|
|
|
usage(std::cout, argv[0], EXIT_SUCCESS);
|
|
|
|
usage(std::cout, argv[0], EXIT_SUCCESS);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -23,6 +38,7 @@ int main(int argc, char** argv){
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME if argv[optind] == nullptr, pass "."
|
|
|
|
while(argv[optind]){
|
|
|
|
while(argv[optind]){
|
|
|
|
std::cout << "arg: " << argv[optind] << std::endl;
|
|
|
|
std::cout << "arg: " << argv[optind] << std::endl;
|
|
|
|
++optind;
|
|
|
|
++optind;
|
|
|
|