xboxscene.org forums

OG Xbox Forums => Software Forums => Development => Topic started by: razorrifh on January 02, 2004, 07:44:00 AM

Title: Dir Searching
Post by: razorrifh on January 02, 2004, 07:44:00 AM
smile.gif
Title: Dir Searching
Post by: Carcharius on January 04, 2004, 01:09:00 PM
CODE

HANDLE hFind;
WIN32_FIND_DATA oFind;

hFind = FindFirstFile("yourdirpath\*.*", &oFind);

if(hFind != INVALID_HANDLE_VALE)
{
     do
     {
           // you can get filename and attributes of files using the oFind object
           // e.g. filename would be oFind.cFilename
           // so here you can do whatever you need to do with them
     }while(FindNextFile(hFind, &oFind));
}


Some of those parameters/syntax might not be exact. But it'll be along those lines. Checkout those function names in help for more details.

Hope that helps

Carcharius
Title: Dir Searching
Post by: razorrifh on January 05, 2004, 05:08:00 AM
CODE

   WIN32_FIND_DATA wfd;
   HANDLE s = FindFirstFile(argc[0], &wfd);

   if(s == INVALID_HANDLE_VALUE)
   {
 cout << "DIDNT WORK!";
 return 0x01;
   }
   else
   {
 cout << "DID WORK!!";
 return 0x02;
   }
   
   FineClose(s);


and i'd use the findnextfile func to find the rest of the stuff, but i want a way to do it with the standard libs, so i could port it to the xbox, and try to port it to other systems, (and cuz i dont wanna include windows.h  ph34r.gif )

*edit* anyone know some good c++/windows programming forums? i dont wanna post stuff that noone is interested  here.
Title: Dir Searching
Post by: Wishi on January 05, 2004, 05:53:00 AM
The code Carch posted would work on the Xbox and to use it you only need to include xtl.h as usual. Maybe you could do this with SDL I don't know.
Title: Dir Searching
Post by: razorrifh on January 05, 2004, 07:50:00 AM
smile.gif

@ wishi:
ok, thanks for the info. i havent bothered to relocate the xdk after my last hd crash so i was unable to look up this info in the help file. smile.gif

@all:
i'll just stick with this code for now, i'm just trying to get an alpha build to work thats functional so i can always improve it from there. later!
Title: Dir Searching
Post by: Wishi on January 05, 2004, 07:52:00 AM
It is a Win32 function I know, however it's on Xbox also which I mentioned since this is a development forum for Xbox. It obviously would not be portable to other platforms since it uses the structure WIN32_FIND_DATA.
Title: Dir Searching
Post by: Carcharius on January 06, 2004, 04:29:00 AM
Dirent isn't in the XDK.

But I have seen a port of it to Win32 that should work.

I can't remember where I saw it though - am sure google will be able to help.

Carcharius