Non so se ti è di aiuto, cmq posto il codice di un programmino che fa il tree del "file system":
codice:
//
// DirWalk.C
//
// By Ciro Sisman Pereira
// CiroSP@aol.com
//
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void fDirWalk(char *);
void displayTree(int, char *);
//------------------------------------------------
void main( int pcount, char *ptext[] )
//------------------------------------------------
{
if ( pcount < 2 )
{
printf("\\");
fDirWalk( "\\" );
}
else
{
printf(ptext[1]);
fDirWalk( ptext[1] );
}
}
//------------------------------------------------
void fDirWalk(char *_current)
//------------------------------------------------
{
char DirName[MAX_PATH];
HANDLE Hnd;
WIN32_FIND_DATA WFD;
static int _dlevel = 0;
// Set the new current directory
SetCurrentDirectory( _current );
// Starts the search
Hnd = FindFirstFile( "*.*", &WFD );
// loop to get all inside the current directory
while ( FindNextFile( Hnd, &WFD ) )
{
// If it is a real directory
if (
( WFD.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) &&
( strcmp(WFD.cFileName, "..") && strcmp(WFD.cFileName, ".") )
)
{
// Get the current directory
GetCurrentDirectory( MAX_PATH, DirName );
// Put a "\" if necessary
if ( strncmp( &DirName[strlen(DirName)-1], "\\", 1 ) )
(void) strcat( DirName, "\\" );
// Create a new path
(void) strcat( DirName, WFD.cFileName );
// Add 1 to level counter
_dlevel++;
// Show the new directory
displayTree( _dlevel, WFD.cFileName );
// Make a new call to itself
fDirWalk( DirName );
// Go back one level
SetCurrentDirectory( ".." );
// Subtracts 1 to level counter
_dlevel--;
}
} // End while
// End the search to this call
(void) FindClose( Hnd );
return;
}
//------------------------------------------------
void displayTree(int _dnumber, char *_dname)
//------------------------------------------------
{
char _txt[128];
int _c = 0;
(void) memset( _txt, 0x00, sizeof(_txt) );
(void) memset( _txt, ' ', _dnumber * 3 );
for ( _c = 0; _c < _dnumber * 3; _c+=3 )
_txt[_c] = '|';
_txt[_c-1] = _txt[_c-2] = '_';
printf("\n%s%s", _txt, _dname );
fflush(stdout);
}
Puoi prendere spunto (sebbene sia scritto in c)