////////////////////////////////////////////////////////////////////////////
| 767 | |
| 768 | ///////////////////////////////////////////////////////////////////////////////// |
| 769 | int 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 | { |
nothing calls this directly
no test coverage detected