Skip to content

Instantly share code, notes, and snippets.

@MizukiSonoko
Created December 27, 2015 09:41
Show Gist options
  • Save MizukiSonoko/e4a654e8aaf1843b695e to your computer and use it in GitHub Desktop.
Save MizukiSonoko/e4a654e8aaf1843b695e to your computer and use it in GitHub Desktop.
#include <string>
#include <iostream>
#include <vector>
#include <dirent.h>
using namespace std;
vector<string> files;
void load(string directory,string filename){
if(filename == "." || filename == "..") return;
if(filename!="")
directory += "/" + filename;
DIR* dir = opendir(directory.c_str());
if(dir!=NULL){
struct dirent* dent;
dent = readdir(dir);
while(dent!=NULL){
dent = readdir(dir);
if(dent!=NULL)
load(directory, string(dent->d_name));
}
closedir(dir);
}else{
files.push_back(directory);
}
}
int main(int argc, char* argv[]){
load("public","");
for(auto v : files){
cout<< v <<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment