/** * @brief Check if any of filefilter rules match to directoryname. * * @param [in] szFileName Directoryname to test. * @return TRUE unless we're suppressing this directory by filter */ BOOL FileFilterHelper::includeDir(LPCTSTR szDirName) { if (m_bUseMask) { // directories have no extension return TRUE; } else { if (!m_fileFilterMgr || !m_currentFilter) return TRUE; // Add a backslash CString strDirName(_T("\\")); strDirName += szDirName; return m_fileFilterMgr->TestDirNameAgainstFilter(m_currentFilter, strDirName); } }
GfTracks::GfTracks() { _pPrivate = new GfTracks::Private; // Get the list of sub-dirs in the "tracks" folder (the track categories). tFList* lstCatFolders = GfDirGetList("tracks"); if (!lstCatFolders) { GfLogFatal("No track category available in the 'tracks' folder\n"); return; } tFList* pCatFolder = lstCatFolders; do { //GfLogDebug("GfTracks::GfTracks() : Examining category %s\n", pCatFolder->name); // Ignore "." and ".." folders. const char* pszCatId = pCatFolder->name; if (pszCatId[0] == '.') continue; // Get the list of sub-dirs in the "tracks" folder (the track categories). std::string strDirName("tracks/"); strDirName += pszCatId; tFList* lstTrackFolders = GfDirGetList(strDirName.c_str()); if (!lstTrackFolders) { GfLogWarning("No track available in the '%s' folder\n", strDirName.c_str()); continue; } // Add new category. _pPrivate->vecCatIds.push_back(pszCatId); // Look at the tracks in this category. tFList* pTrackFolder = lstTrackFolders; do { //GfLogDebug("GfTracks::GfTracks() : Examining track %s\n", pTrackFolder->name); // Determine and check the XML file of the track. const char* pszTrackId = pTrackFolder->name; std::ostringstream ossFileName; ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << pszTrackId << '.' << TRKEXT; const std::string strTrackFileName(ossFileName.str()); if (!GfFileExists(strTrackFileName.c_str())) { GfLogInfo("Ignoring track %s : %s not found\n", pszTrackId, strTrackFileName.c_str()); continue; } // Get 1st level track info (those which don't need to open any file). ossFileName.str(""); ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << pszTrackId << ".jpg"; std::string strPreviewFileName(ossFileName.str()); if (!GfFileExists(strPreviewFileName.c_str())) { ossFileName.str(""); ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << pszTrackId << ".png"; strPreviewFileName = ossFileName.str(); } if (!GfFileExists(strPreviewFileName.c_str())) strPreviewFileName = "data/img/splash-trackselect.jpg"; ossFileName.str(""); ossFileName << "tracks/" << pszCatId << '/' << pszTrackId << '/' << "outline.png"; std::string strOutlineFileName(ossFileName.str()); if (!GfFileExists(strOutlineFileName.c_str())) strOutlineFileName = "data/img/notrackoutline.png"; // Store track info in the GfTrack structure. GfTrack* pTrack = new GfTrack; pTrack->setId(pszTrackId); pTrack->setCategoryId(pszCatId); pTrack->setDescriptorFile(strTrackFileName); pTrack->setPreviewFile(strPreviewFileName); pTrack->setOutlineFile(strOutlineFileName); // Update the GfTracks singleton. _pPrivate->vecTracks.push_back(pTrack); _pPrivate->mapTracksById[pszTrackId] = pTrack; } while ((pTrackFolder = pTrackFolder->next) != lstTrackFolders); GfDirFreeList(lstTrackFolders, NULL, true, true); } while ((pCatFolder = pCatFolder->next) != lstCatFolders); GfDirFreeList(lstCatFolders, NULL, true, true); // Sort the car category ids and driver types vectors. std::sort(_pPrivate->vecCatIds.begin(), _pPrivate->vecCatIds.end()); // Trace what we got. print(false); // No verbose here, otherwise infinite recursion. }