System calls using c++ (unix)

+1 Joe money · February 7, 2015
Hi, I am trying to write my own version of the "ls" command which lists files in a directory. 
1. If no command line arguments are given, the current directory is listed. By default, any file starting whose first character is “.” will not be listed unless the hidden flag is set. // Here is my problem. I keep showing the hidden files when i run my program
2. An optional flag, -h (for hidden), may be specified which will list all files or directories including those that start with a “.” // I am also trying to figure out how to do this.
If anyone can help me hide these hidden files I would very much appreciate it.
my code:







[
#include
#include
#include

using namespace std;

int main(void) {
 struct dirent *ent;
DIR *dir = opendir(".");
   if(dir) {
       struct dirent *ent;
       while((ent = readdir(dir)) != NULL)
       {
           cout d_name) d_name[0]== '.' ))  {

cout d_name)


Post a Reply

Replies

Oldest  Newest  Rating
0 Joe money · February 8, 2015
#include 
#include
#include

using namespace std;

int main(void) {
 struct dirent *ent;
DIR *dir = opendir(".");
   if(dir) {
       struct dirent *ent;
       while((ent = readdir(dir)) != NULL)
       {
           cout d_name) d_name[0]== '.' ))  {

cout d_name)
  • 1

C++

126,400 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator