cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/01/18:01:27

Date: Tue, 1 Jul 1997 18:01:50 -0400 (EDT)
From: Timothy Robb <trobb AT neutrino DOT phys DOT laurentian DOT ca>
To: djgpp AT delorie DOT com
Subject: getting a dir listing
Message-ID: <Pine.SGI.3.91.970701175832.14458A-100000@neutrino.phys.laurentian.ca>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019