Skip to main content
gamedev.net
🔒 Locked

simple question about files

Started by flutey Jun 18, 2002 at 4:34 AM 1 replies 200+ views
Original Post
flutey
flutey
hi, can any one tell me how to read the files names inside a certain directory? which functions can be used to to that. i want it to create my own file open/save dialog using OpenGL Flutey Shady El Mously Egyptian Game Programmer (there is no knowledge that is not power)
LessBread
LessBread
look up findfirst, findnext, findclose, chdir, rmdir, mkdir, getdcwd - typically found in io.h and direct.h as part of the standard C library.
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
gimp
gimp

  
void CFile::GetDirectoryList(const std::string& a_Path, std::vector<std::string>& a_Files)
{
WIN32_FIND_DATA FileInfo;
HANDLE DirectoryIndex;
std::string SearchPath = a_Path + "\\*.*";

DirectoryIndex = FindFirstFile(SearchPath.c_str(), &FileInfo);

if (DirectoryIndex == (HANDLE)-1)
return;

do
{
if (FileInfo.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY)
a_Files.push_back(FileInfo.cFileName);
}
while(FindNextFile(DirectoryIndex, &FileInfo) != 0);

FindClose(DirectoryIndex);
}


HTH,



Chris Brodie
http:\\fourth.flipcode.com
Chris Brodie

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.