Skip to content

C++ Struct to get file and folder information in directory.

License

Notifications You must be signed in to change notification settings

oblerion/dirent2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

dirent2

Struct to more easy to use dirent.h.
Same to dirent get file and folder information.
Need dirent.h for work.

some exemple

#include "dirent2.hpp"
// simple
struct dirent2 d2;
d2.scan("."); // scan '.' directory
d2.print(); // print all name in console

// advenced loop
for(int i=0;i<d2.nd;i++)
{
	if(d2.Type_at(i)=='f')
  	{
   		printf("\n%s is file",d2.Name_at(i).c_str());
  	}
  	if(d2.Type_at(i)=='d')
  	{
    		printf("\n%s is directory",d2.Name_at(i).c_str());
  	}
}

fast describle

struct dirent2
{
	int nb=0;// number of all name found
	void scan(std::string pstr);// scan dir path is pstr
	void print();// print all in console
	std::string Name_at(int id);// get string name at id
	char Type_at(int id);// get char type at id --> 'f' file or 'd' dir
};

About

C++ Struct to get file and folder information in directory.

Topics

Resources

License

Stars

Watchers

Forks

Languages