C y b e r M a c @ E x M a c h i n a ( M a i l i n g L i s t )
<http://www.cybercafe21.net> & <http://www.cybercafe21.tv>
>Tu rigoles ! :-)
Non, comme tu peux le constater ici (notion de metadata) :
int main(void)
{
OSStatus outStatus;
FSSpec spec;
FSRef folderRef;
printf("begin file iteration!\n");
fflush( stdout );
//
// Get the currently running application's parent folder,
// make it into an FSRef, and iterate it
//
outStatus = FSMakeFSSpec( 0, 0, "\p", &spec );
if( outStatus == noErr )
{
outStatus = FSpMakeFSRef( &spec, &folderRef );
if( outStatus == noErr )
{
outStatus = IterateFolder( &folderRef );
}
}
printf( "final error status is (#%d)\n", outStatus );
return 0;
}
OSStatus IterateFolder( FSRef * inFolder )
{
OSStatus outStatus;
//
// Get permissions and node flags and Finder info
//
// For maximum performance, specify in the catalog
// bitmap only the information you need to know
//
FSCatalogInfoBitmap kCatalogInfoBitmap = ( kFSCatInfoNodeFlags
| kFSCatInfoFinderInfo
);
//
// On each iteration of the do-while loop, retrieve this
// number of catalog infos
//
// We use the number of FSCatalogInfos that will fit in
// exactly four VM pages (#113). This is a good balance
// between the iteration I/O overhead and the risk of
// incurring additional I/O from additional memory
// allocation
//
const size_t kRequestCountPerIteration =
((4096 * 4) /
sizeof(FSCatalogInfo));
FSIterator iterator;
FSCatalogInfo * catalogInfoArray;
//
// Create an iterator
//
outStatus = FSOpenIterator( inFolder, kFSIterateFlat, &iterator );
if( outStatus == noErr )
{
//
// Allocate storage for the returned information
//
catalogInfoArray = (FSCatalogInfo *) malloc( sizeof(FSCatalogInfo)
*
kRequestCountPerIteration );
if( catalogInfoArray == NULL )
{
outStatus = memFullErr;
}
else
{
//
// Request information about files in the given directory,
// until we get a status code back from the File Manager
//
do
{
ItemCount actualCount;
outStatus = FSGetCatalogInfoBulk( iterator,
kRequestCountPerIteration,
&actualCount,
NULL,
kCatalogInfoBitmap,
catalogInfoArray,
NULL,
NULL,
NULL );
//
// Process all items received
//
if( outStatus == noErr || outStatus == errFSNoMoreItems )
{
UInt32 index;
for( index = 0; index < actualCount; index += 1 )
{
//
// Do something interesting with the object found
//
DoSomethingWithThisObject( &catalogInfoArray[
index ] );
}
}
}
while( outStatus == noErr );
//
// errFSNoMoreItems tells us we have successfully processed all
// items in the directory -- not really an error
//
if( outStatus == errFSNoMoreItems )
{
outStatus = noErr;
}
//
// Free the array memory
//
free( (void *) catalogInfoArray );
}
}
return outStatus;
}
void DoSomethingWithThisObject( const FSCatalogInfo * inCatInfo )
{
if( (inCatInfo->nodeFlags & kFSNodeIsDirectoryMask) ==
kFSNodeIsDirectoryMask )
{
printf( "Found a folder\n" );
}
else
{
FInfo * theFinderInfo;
OSType type;
theFinderInfo = (FInfo *)&inCatInfo->finderInfo[0];
type = theFinderInfo->fdType;
printf( "Found a file (type %c%c%c%c)\n",
(char) ((type & 0xFF000000) >> 24),
(char) ((type & 0x00FF0000) >> 16),
(char) ((type & 0x0000FF00) >> 8),
(char) (type & 0x000000FF)
);
}
}
Bonne lecture
FranciscoSan
--
---------------------------------------------------------------------
Francis Vermeire,
Consultant
iSolutions, l'informatique � votre mesure
Rue Richard Heintz 19
B - 4020 LIEGE
+32 4 3442485
+32 475 923652
mailto:[EMAIL PROTECTED]
http://www.iSolutions.be
---------------------------------------------------------------------
Que ceux qui veulent profiter des conditions Salon levent le doigt !
>>> Decouvrez la nouvelle gamme Audi sur http://www.audi.be
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CCMC vous est offert par Emakina <http://www.emakina.com>
Pour vous desabonner: <mailto:[EMAIL PROTECTED]>