MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / recurseDumpPath

Function recurseDumpPath

Engine/source/platformWin32/winFileio.cpp:587–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585}
586
587static bool recurseDumpPath(const char *path, const char *pattern, Vector<Platform::FileInfo> &fileVector, S32 recurseDepth )
588{
589 WIN32_FIND_DATA findData;
590
591 TempAlloc< char > fullPath( dStrlen( path ) * 3 + MAX_PATH * 3 + 1 );
592 Platform::makeFullPathName( path, fullPath, fullPath.size );
593
594 U32 lenFullPath = dStrlen( fullPath );
595 TempAlloc< char > buf( lenFullPath + MAX_PATH * 3 + 2 );
596 dSprintf( buf, buf.size, "%s/%s", fullPath.ptr, pattern );
597
598#ifdef UNICODE
599 TempAlloc< WCHAR > searchBuf( buf.size );
600 convertUTF8toUTF16N( buf, searchBuf, searchBuf.size );
601 WCHAR* search = searchBuf;
602#else
603 char *search = buf;
604#endif
605
606 backslash( search );
607
608 HANDLE handle = FindFirstFile(search, &findData);
609 if (handle == INVALID_HANDLE_VALUE)
610 return false;
611
612 do
613 {
614#ifdef UNICODE
615 convertUTF16toUTF8N( findData.cFileName, buf, buf.size );
616 char* fnbuf = buf;
617#else
618 char *fnbuf = findData.cFileName;
619#endif
620
621 if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
622 {
623 // make sure it is a directory
624 if (findData.dwFileAttributes & (FILE_ATTRIBUTE_OFFLINE|FILE_ATTRIBUTE_SYSTEM) )
625 continue;
626
627 // skip . and .. directories
628 if (String::compare( findData.cFileName, TEXT( "." ) ) == 0 || String::compare( findData.cFileName, TEXT( ".." ) ) == 0)
629 continue;
630
631 // Skip excluded directores
632 if(Platform::isExcludedDirectory(fnbuf))
633 continue;
634
635 dSprintf( fullPath, fullPath.size, "%s/%s", path, fnbuf);
636 char* child = fullPath;
637 if( recurseDepth > 0 )
638 recurseDumpPath(child, pattern, fileVector, recurseDepth - 1);
639 else if (recurseDepth == -1)
640 recurseDumpPath(child, pattern, fileVector, -1);
641 }
642 else
643 {
644 // make sure it is the kind of file we're looking for

Callers 1

dumpPathMethod · 0.85

Calls 10

dSprintfFunction · 0.85
convertUTF8toUTF16NFunction · 0.85
backslashFunction · 0.85
convertUTF16toUTF8NFunction · 0.85
compareFunction · 0.85
incrementMethod · 0.80
forwardslashFunction · 0.70
dStrlenFunction · 0.50
lastMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected