MCPcopy Create free account
hub / github.com/ddnet/ddnet / FindFile

Method FindFile

src/engine/shared/storage.cpp:706–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

704 }
705
706 bool FindFile(const char *pFilename, const char *pPath, int Type, char *pBuffer, int BufferSize) override
707 {
708 dbg_assert(BufferSize >= 1, "BufferSize invalid");
709
710 pBuffer[0] = 0;
711
712 CFindCBData Data;
713 Data.m_pStorage = this;
714 Data.m_pFilename = pFilename;
715 Data.m_pPath = pPath;
716 Data.m_pBuffer = pBuffer;
717 Data.m_BufferSize = BufferSize;
718
719 char aBuf[IO_MAX_PATH_LENGTH];
720 if(Type == TYPE_ALL)
721 {
722 // search within all available directories
723 for(int i = TYPE_SAVE; i < m_NumPaths; ++i)
724 {
725 fs_listdir(GetPath(i, pPath, aBuf, sizeof(aBuf)), FindFileCallback, i, &Data);
726 if(pBuffer[0])
727 return true;
728 }
729 }
730 else if(Type >= TYPE_SAVE && Type < m_NumPaths)
731 {
732 // search within wanted directory
733 fs_listdir(GetPath(Type, pPath, aBuf, sizeof(aBuf)), FindFileCallback, Type, &Data);
734 }
735 else
736 {
737 dbg_assert_failed("Type invalid");
738 }
739
740 return pBuffer[0] != 0;
741 }
742
743 struct SFindFilesCallbackData
744 {

Callers 2

LoadMapSearchMethod · 0.80
StartMethod · 0.80

Calls 1

fs_listdirFunction · 0.85

Tested by

no test coverage detected