mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Add willdcard check in BfpFindFileData_CheckFilter
This commit is contained in:
parent
95bd231444
commit
debcf7eb6c
12 changed files with 81 additions and 16 deletions
|
@ -140,6 +140,7 @@
|
|||
<ClCompile Include="..\..\BeefySysLib\platform\win\CrashCatcher.cpp" />
|
||||
<ClCompile Include="..\..\BeefySysLib\platform\win\Platform.cpp" />
|
||||
<ClCompile Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.c" />
|
||||
<ClCompile Include="..\..\BeefySysLib\third_party\putty\wildcard.c" />
|
||||
<ClCompile Include="..\..\BeefySysLib\util\BeefPerf.cpp" />
|
||||
<ClCompile Include="..\..\BeefySysLib\util\String.cpp" />
|
||||
<ClCompile Include="..\..\BeefySysLib\util\UTF8.cpp" />
|
||||
|
@ -356,6 +357,7 @@
|
|||
<ClInclude Include="..\..\BeefySysLib\platform\win\BFPlatform.h" />
|
||||
<ClInclude Include="..\..\BeefySysLib\platform\win\CrashCatcher.h" />
|
||||
<ClInclude Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.h" />
|
||||
<ClInclude Include="..\..\BeefySysLib\third_party\putty\wildcard.h" />
|
||||
<ClInclude Include="..\..\BeefySysLib\util\BeefPerf.h" />
|
||||
<ClInclude Include="..\..\BeefySysLib\util\String.h" />
|
||||
<ClInclude Include="..\..\BeefySysLib\util\UTF8.h" />
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
<Filter Include="BeefySysLib\third_party\utf8proc">
|
||||
<UniqueIdentifier>{0027c869-120a-44d3-80e6-e2ab12ce83bc}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="BeefySysLib\third_party\putty">
|
||||
<UniqueIdentifier>{59aee039-211d-47df-abb4-ca95d75d2c56}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="BeefySysLib\util">
|
||||
<UniqueIdentifier>{8e5503bc-1b01-46f1-be03-bb504d93f05d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
@ -105,6 +108,9 @@
|
|||
<ClCompile Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.c">
|
||||
<Filter>BeefySysLib\third_party\utf8proc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\BeefySysLib\third_party\putty\wildcard.c">
|
||||
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\BeefySysLib\util\BeefPerf.cpp">
|
||||
<Filter>BeefySysLib\util</Filter>
|
||||
</ClCompile>
|
||||
|
@ -326,6 +332,9 @@
|
|||
<ClInclude Include="..\..\BeefySysLib\third_party\utf8proc\utf8proc.h">
|
||||
<Filter>BeefySysLib\third_party\utf8proc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\BeefySysLib\third_party\putty\wildcard.h">
|
||||
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\BeefySysLib\util\BeefPerf.h">
|
||||
<Filter>BeefySysLib\util</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -252,6 +252,7 @@
|
|||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release Static CStatic|x64'">TurnOffAllWarnings</WarningLevel>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\BeefySysLib\third_party\utf8proc\utf8proc.c" />
|
||||
<ClCompile Include="..\BeefySysLib\third_party\putty\wildcard.c" />
|
||||
<ClCompile Include="..\BeefySysLib\util\AllocDebug.cpp" />
|
||||
<ClCompile Include="..\BeefySysLib\util\BeefPerf.cpp" />
|
||||
<ClCompile Include="..\BeefySysLib\util\String.cpp" />
|
||||
|
@ -271,6 +272,7 @@
|
|||
<ClInclude Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\include\ffi.h" />
|
||||
<ClInclude Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\include\ffitarget.h" />
|
||||
<ClInclude Include="..\BeefySysLib\third_party\utf8proc\utf8proc.h" />
|
||||
<ClInclude Include="..\BeefySysLib\third_party\putty\wildcard.h" />
|
||||
<ClInclude Include="..\BeefySysLib\util\BeefPerf.h" />
|
||||
<ClInclude Include="..\BeefySysLib\util\String.h" />
|
||||
<ClInclude Include="..\BeefySysLib\util\UTF8.h" />
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
<Filter Include="BeefySysLib\third_party\libffi\x86">
|
||||
<UniqueIdentifier>{f94ea9c5-428b-4925-a59e-b7688752d7d7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="BeefySysLib\third_party\putty">
|
||||
<UniqueIdentifier>{e790c845-8b10-4edd-b2c0-71e35b0d80b2}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="rt\Internal.cpp">
|
||||
|
@ -87,6 +90,9 @@
|
|||
<ClCompile Include="..\BeefySysLib\third_party\libffi\src\types.c">
|
||||
<Filter>BeefySysLib\third_party\libffi</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\BeefySysLib\third_party\putty\wildcard.c">
|
||||
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="rt\Chars.cpp">
|
||||
<Filter>rt</Filter>
|
||||
</ClCompile>
|
||||
|
@ -148,6 +154,9 @@
|
|||
<CustomBuild Include="..\BeefySysLib\third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
||||
<Filter>BeefySysLib\third_party\libffi\x86</Filter>
|
||||
</CustomBuild>
|
||||
<ClInclude Include="..\BeefySysLib\third_party\putty\wildcard.h">
|
||||
<Filter>BeefySysLib\third_party\putty</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="BeefRT.def" />
|
||||
|
|
|
@ -221,6 +221,7 @@ file(GLOB SRC_FILES
|
|||
../BeefySysLib/util/UTF8.cpp
|
||||
../BeefySysLib/util/Hash.cpp
|
||||
../BeefySysLib/third_party/utf8proc/utf8proc.c
|
||||
../BeefySysLib/third_party/putty/wildcard.c
|
||||
)
|
||||
|
||||
if (${IOS})
|
||||
|
|
|
@ -1926,6 +1926,7 @@ copy /y "$(OutDir)$(TargetName).lib" "$(SolutionDir)\BeefLibs\Beefy2D\dist\"</Co
|
|||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release Static|x64'">TurnOffAllWarnings</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
|
||||
</ClCompile>
|
||||
<ClCompile Include="third_party\putty\wildcard.c" />
|
||||
<ClCompile Include="util\AllocDebug.cpp" />
|
||||
<ClCompile Include="util\BeefPerf.cpp" />
|
||||
<ClCompile Include="util\BSpline.cpp" />
|
||||
|
@ -2152,6 +2153,7 @@ copy /y "$(OutDir)$(TargetName).lib" "$(SolutionDir)\BeefLibs\Beefy2D\dist\"</Co
|
|||
<ClInclude Include="third_party\zlib\zconf.h" />
|
||||
<ClInclude Include="third_party\zlib\zlib.h" />
|
||||
<ClInclude Include="third_party\zlib\zutil.h" />
|
||||
<ClInclude Include="third_party\putty\wildcard.h" />
|
||||
<ClInclude Include="Util\AllocDebug.h" />
|
||||
<ClInclude Include="util\Array.h" />
|
||||
<ClInclude Include="util\BeefPerf.h" />
|
||||
|
|
|
@ -78,6 +78,9 @@
|
|||
<Filter Include="src\third_party\miniz">
|
||||
<UniqueIdentifier>{a159b9ee-1a71-44f5-a412-1e01e20b70c7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\third_party\putty">
|
||||
<UniqueIdentifier>{0007a912-9292-4e32-8884-0f0cd276e42d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="platform\win\DXRenderDevice.cpp">
|
||||
|
@ -731,6 +734,9 @@
|
|||
<ClCompile Include="util\ZipFile.cpp">
|
||||
<Filter>src\util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="third_party\putty\wildcard.c">
|
||||
<Filter>src\third_party\putty</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Common.h">
|
||||
|
@ -1123,6 +1129,9 @@
|
|||
<ClInclude Include="util\ZipFile.h">
|
||||
<Filter>src\util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="third_party\putty\wildcard.h">
|
||||
<Filter>src\third_party\putty</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
||||
|
|
|
@ -859,6 +859,7 @@
|
|||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Level1</WarningLevel>
|
||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Level1</WarningLevel>
|
||||
</ClCompile>
|
||||
<ClCompile Include="third_party\putty\wildcard.c" />
|
||||
<ClCompile Include="util\AllocDebug.cpp" />
|
||||
<ClCompile Include="util\BeefPerf.cpp" />
|
||||
<ClCompile Include="util\BSpline.cpp" />
|
||||
|
@ -1025,6 +1026,7 @@
|
|||
<ClInclude Include="third_party\zlib\zconf.h" />
|
||||
<ClInclude Include="third_party\zlib\zlib.h" />
|
||||
<ClInclude Include="third_party\zlib\zutil.h" />
|
||||
<ClInclude Include="third_party\putty\wildcard.h" />
|
||||
<ClInclude Include="util\BeefPerf.h" />
|
||||
<ClInclude Include="util\BSpline.h" />
|
||||
<ClInclude Include="util\CabUtil.h" />
|
||||
|
|
|
@ -69,6 +69,9 @@
|
|||
<Filter Include="src\third_party\miniz">
|
||||
<UniqueIdentifier>{d32cb9b0-e79b-49fe-82e2-33302be0baf6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="src\third_party\putty">
|
||||
<UniqueIdentifier>{bec18ceb-a7ca-4150-99ee-60a16944b93c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="platform\win\DXRenderDevice.cpp">
|
||||
|
@ -584,6 +587,9 @@
|
|||
<ClCompile Include="third_party\miniz\miniz.c">
|
||||
<Filter>src\third_party\miniz</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="third_party\putty\wildcard.c">
|
||||
<Filter>src\third_party\putty</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Common.h">
|
||||
|
@ -898,6 +904,9 @@
|
|||
<ClInclude Include="third_party\miniz\miniz.h">
|
||||
<Filter>src\third_party\miniz</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="third_party\putty\wildcard.h">
|
||||
<Filter>src\third_party\putty</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="third_party\libffi\i686-pc-cygwin\src\x86\win32.asm">
|
||||
|
|
|
@ -274,6 +274,7 @@ file(GLOB SRC_FILES
|
|||
third_party/zlib/uncompr.c
|
||||
third_party/zlib/zutil.c
|
||||
third_party/miniz/miniz.c
|
||||
third_party/putty/wildcard.c
|
||||
util/AllocDebug.cpp
|
||||
util/BeefPerf.cpp
|
||||
util/BSpline.cpp
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "../../util/CritSect.h"
|
||||
#include "../../util/Dictionary.h"
|
||||
#include "../../util/Hash.h"
|
||||
#include "../../third_party/putty/wildcard.h"
|
||||
#ifdef BFP_HAS_EXECINFO
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
@ -2380,7 +2381,8 @@ static bool BfpFindFileData_CheckFilter(BfpFindFileData* findData)
|
|||
return false;
|
||||
}
|
||||
|
||||
//TODO: Check actual wildcards.
|
||||
if (!wc_match(findData->mWildcard.c_str(), findData->mDirEnt->d_name))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "../util/CritSect.h"
|
||||
#include "../util/Dictionary.h"
|
||||
#include "../util/HashSet.h"
|
||||
#include "../../third_party/putty/wildcard.h"
|
||||
|
||||
#include "util/AllocDebug.h"
|
||||
|
||||
|
@ -3485,6 +3486,7 @@ struct BfpFindFileData
|
|||
{
|
||||
BfpFindFileFlags mFlags;
|
||||
WIN32_FIND_DATA mFindData;
|
||||
Beefy::String mWildcard;
|
||||
HANDLE mHandle;
|
||||
};
|
||||
|
||||
|
@ -3496,29 +3498,43 @@ static bool BfpFindFileData_CheckFilter(BfpFindFileData* findData)
|
|||
bool isDir = (findData->mFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
if (isDir)
|
||||
{
|
||||
if ((findData->mFlags & BfpFindFileFlag_Directories) != 0)
|
||||
{
|
||||
if ((wcscmp(findData->mFindData.cFileName, L".") == 0) || (wcscmp(findData->mFindData.cFileName, L"..") == 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ((findData->mFlags & BfpFindFileFlag_Directories) == 0)
|
||||
return false;
|
||||
|
||||
if ((wcscmp(findData->mFindData.cFileName, L".") == 0) || (wcscmp(findData->mFindData.cFileName, L"..") == 0))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((findData->mFlags & BfpFindFileFlag_Files) != 0)
|
||||
return true;
|
||||
if ((findData->mFlags & BfpFindFileFlag_Files) == 0)
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
Beefy::String fileName = UTF8Encode(findData->mFindData.cFileName);
|
||||
if (!wc_match(findData->mWildcard.c_str(), fileName.c_str()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BFP_EXPORT BfpFindFileData* BFP_CALLTYPE BfpFindFileData_FindFirstFile(const char* path, BfpFindFileFlags flags, BfpFileResult* outResult)
|
||||
{
|
||||
UTF16String wPath = UTF8Decode(path);
|
||||
Beefy::String findStr = path;
|
||||
Beefy::String wildcard;
|
||||
|
||||
int lastSlashPos = std::max((int)findStr.LastIndexOf('/'), (int)findStr.LastIndexOf('\\'));
|
||||
if (lastSlashPos != -1)
|
||||
{
|
||||
wildcard = findStr.Substring(lastSlashPos + 1);
|
||||
findStr = findStr.Substring(0, lastSlashPos + 1);
|
||||
findStr.Append("*");
|
||||
}
|
||||
if (wildcard == "*.*")
|
||||
wildcard = "*";
|
||||
|
||||
BfpFindFileData* findData = new BfpFindFileData();
|
||||
findData->mFlags = flags;
|
||||
findData->mWildcard = wildcard;
|
||||
|
||||
FINDEX_SEARCH_OPS searchOps;
|
||||
if ((flags & BfpFindFileFlag_Files) == 0)
|
||||
|
@ -3526,6 +3542,7 @@ BFP_EXPORT BfpFindFileData* BFP_CALLTYPE BfpFindFileData_FindFirstFile(const cha
|
|||
else
|
||||
searchOps = FindExSearchNameMatch;
|
||||
|
||||
UTF16String wPath = UTF8Decode(findStr);
|
||||
findData->mHandle = ::FindFirstFileExW(wPath.c_str(), FindExInfoBasic, &findData->mFindData, searchOps, NULL, 0);
|
||||
if (findData->mHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue