On 5/27/2009 3:55 PM, Gabriel Smith wrote:
> I was wondering if there was any way to incorporate a file system into source
> so you could theoretically search through files anywhere on your computer. I
> want to know so I can see if making a fps style "desktop" was possible.
>
> Yoda12999
>
#include <windows.h>
#include <stdio.h>
void Directory(FILE *fp, CHAR *path)
{
HANDLE hFile = NULL;
WIN32_FIND_DATA pFindFileData;
CHAR temp_path[_MAX_PATH];
strcpy(temp_path, path);
strcat(temp_path, "\\*");
hFile = FindFirstFile(temp_path, &pFindFileData);
if (hFile == INVALID_HANDLE_VALUE)
return;
int dir_count = 0;
int file_count = 0;
do
{
if ((strcmp(pFindFileData.cFileName, ".") == 0) ||
(strcmp(pFindFileData.cFileName, "..") == 0))
continue; // skip '.' and '..'
if (pFindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
fprintf(fp, "Directory = %s\\%s\n", path,
pFindFileData.cFileName);
strcpy(temp_path, path);
strcat(temp_path, "\\");
strcat(temp_path, pFindFileData.cFileName);
Directory(fp, temp_path);
dir_count++;
}
else
{
fprintf(fp, "%12d %s\n", pFindFileData.nFileSizeLow,
pFindFileData.cFileName);
file_count++;
}
} while( FindNextFile(hFile, &pFindFileData) );
fprintf(fp, "Count for %s = %d directories, %d files.\n", path,
dir_count, file_count);
// Close the find handle.
FindClose( hFile );
}
void main(void)
{
FILE *fp = fopen("Directory.txt", "w");
if (fp != NULL)
Directory(fp, ".");
fclose(fp);
}
--
Jeffrey "botman" Broome
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders