- Code: Select all
#include <iostream>
#include <string>
using namespace std;
void usage();
void version();
void version()
{
cout << endl;
cout << "VERSION : 0.1 BETA\n";
cout << "AUTHOR : the0nlyb0ss\n";
cout << "DATE : 10/2/2010\n";
cout << "OS : Windows\n";
cout << endl;
cout << "LS.EXE was created as a 'dir' subsitute for all us UNIX lovers out there.\n";
cout << "It takes a few of the common argv for 'ls' such as '-l' and '-a'.\n";
cout << endl;
}
void usage()
{
cout << endl;
cout << "USAGE: ls <options> <folder>" << endl << endl;
cout << "\t-h : Show this help text" << endl;
cout << "\t-v : Show version and program info" << endl;
cout << "\t-l : Show files with owner information" << endl;
cout << "\t-a : Show only hidden files" << endl;
}
int main(int argc, char* argv[])
{
if(argc < 1 || argc > 3){
usage();
}
if(argc == 1){
system("DIR");
}
if(argv[1] == "-h"){
usage();
}
else if(argv[1] == "-v"){
version();
}
else if(argv[1] == "-l"){
system("DIR /Q");
}
else if(argv[1] == "-a"){
system("DIR /A:H");
}
else if(argv[1] == "-la"){
system("DIR /A:H /Q");
}
return 0;
}
The program works fine when I simply type "ls", and it also gives me the usage() function when I type more than 3 arguments, but when I try typing any valid arguments, whether it's "-h", "-a", "-l", "-v", or "-la", it doesn't do anything at all.




