Opening Multiple files from a directory C++ -


i trying open files directory everytime display files have these 3 dots @ top. example directory open called "my documents" output 3 dots follows . .. names.txt jobs.txt

names.txt , jobs.txt output want achieve, out.

my code

int getdoc(string doc, vector<string> &documents){      dir *dp;     struct dirent *dirp;     if ((dp = opendir(doc.c_str())) == null){         cout << "error(" << errno << ") opening" << doc << endl;         return errno;     }     while ((dirp = readdir(dp)) != null){         documents.push_back(string(dirp->d_name));     }     closedir(dp);     return 0; } 

by way use dirent.h

the 3 dots 2 directories. first 1 named '.' refers current directory. if try open it, lead same directory. example, directory c:\users\daniel equal c:\users\daniel\. second directory '..'. refers parent directory. c:\users directory equivalent c:\users\daniel\..

those 2 directories not real. simulated operating system. if don't want print them, start printing list after skipping first 2 elements. 2 directories listed first.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -