Mail Archives: djgpp/1997/07/01/18:01:27
Here's some code that is for a c++ class that will give you a directory
listing (should) under Borland C++. It uses STL, btw what does "using
namespace std;" do?
My question is can someone re-write
the member functions such that they will work under djgpp.
Thanks in advance
Timothy Robb
// filelist.h
#include<string>
#include<vector>
#include<iostream>
using namespace std;
class filelist : public vector<string>
{
public:
filelist(const char* afn = "*.*");
void listall(ostream &os = cout, const char *sep = "\n");
};
// filelist.cxx -- member function definitions
#include "filelist.h"
#include <direct.h> // dos directory functions for Borland
filelist::filelist(const char *afn)
{
ffblk fileinfo;
int done = findfirst(afn, &fileinfo, 0);
while(!done)
{
push_back(fileinfo.ff_name);
done = findnext(&fileinfo);
}
}
void filelist::listall(ostream &os, const char *sep)
{
for(iterator i = begin(), i != end(); i++)
os << (*i).c_str() << sep;
}
- Raw text -