MCPcopy Create free account
hub / github.com/StrongPC123/Far-Cry-1-Source-Full / ScanDirectory

Method ScanDirectory

CrySystem/ScriptObjectSystem.cpp:769–846  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

767
768/////////////////////////////////////////////////////////////////////////////////
769int CScriptObjectSystem::ScanDirectory(IFunctionHandler *pH)
770{
771 if (pH->GetParamCount()<1)
772 return pH->EndFunctionNull();
773
774 _SmartScriptObject pObj(m_pScriptSystem);
775 int k=0;
776
777 const char *pszFolderName;
778 if (!pH->GetParam(1,pszFolderName))
779 return pH->EndFunction(*pObj);
780
781 int nScanMode=SCANDIR_SUBDIRS;
782 int nInPack = 0;
783 if (pH->GetParamCount()>1)
784 pH->GetParam(2, nScanMode);
785 if (pH->GetParamCount()>2)
786 pH->GetParam(3, nInPack);
787
788 if (!nInPack)
789 {
790#if !defined(XBOX) && !defined(PS2)
791
792 struct __finddata64_t c_file;
793 intptr_t hFile;
794
795 // Find first file in current directory
796#if defined(WIN32)
797 if ((hFile = _findfirst64( (string(pszFolderName) + "\\*.*").c_str(), &c_file )) == -1L)
798#elif defined(LINUX)
799 if ((hFile = _findfirst64( (string(pszFolderName) + "/*").c_str(), &c_file )) == -1)
800#endif
801 {
802 return (pH->EndFunction(*pObj));
803 }
804 else
805 {
806 do
807 {
808 if (Filter (c_file, nScanMode))
809 {
810 pObj->SetAt(k,c_file.name);
811 k++;
812 }
813 }
814 while(_findnext64(hFile, &c_file)==0);
815
816 _findclose(hFile);
817 }
818#endif
819 }
820 else
821 {
822 _finddata_t c_file;
823 intptr_t hFile;
824
825 if ((hFile = m_pSystem->GetIPak()->FindFirst((string(pszFolderName) + "\\*.*").c_str(), &c_file)) == -1L)
826 {

Callers

nothing calls this directly

Calls 12

FilterFunction · 0.85
EndFunctionNullMethod · 0.80
EndFunctionMethod · 0.80
SetAtMethod · 0.80
GetIPakMethod · 0.80
FindCloseMethod · 0.80
stringClass · 0.50
GetParamCountMethod · 0.45
GetParamMethod · 0.45
c_strMethod · 0.45
FindFirstMethod · 0.45
FindNextMethod · 0.45

Tested by

no test coverage detected