added EnumFileTest.cpp

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-07-21 11:31:58 +08:00
parent c168b1cab6
commit 295a4e8678
2 changed files with 47 additions and 1 deletions

View File

@ -16,7 +16,7 @@ macro(cm_example_project sub_folder project_name)
set_property(TARGET ${project_name} PROPERTY FOLDER "CM/Examples/${sub_folder}")
endmacro()
####################################################################################################
add_executable(HalfFloatTest datatype/HalfFloatTest.cpp)
cm_example_project("DataType" HalfFloatTest)
@ -43,10 +43,14 @@ cm_example_project("DataType" Size2Test)
add_executable(DataArrayTest datatype/DataArrayTest.cpp)
cm_example_project("DataType" DataArrayTest)
####################################################################################################
add_executable(FixFilenameTest filesystem/FixFilenameTest.cpp)
cm_example_project("File System" FixFilenameTest)
add_executable(EnumFileTest filesystem/EnumFileTest.cpp)
cm_example_project("File System" EnumFileTest)
IF(WIN32)
add_executable(EnumVolumeTest filesystem/EnumVolumeTest.cpp)
@ -54,6 +58,7 @@ IF(WIN32)
ENDIF(WIN32)
####################################################################################################
add_executable(GetCpuInfo GetCpuInfo.cpp)
cm_example_project("Hareware" GetCpuInfo)

View File

@ -0,0 +1,41 @@
#include<hgl/filesystem/EnumFile.h>
#include<iostream>
using namespace hgl;
using namespace hgl::filesystem;
class MyEnumFile:public EnumFile
{
public:
void ProcFolderBegin(struct EnumFileConfig *parent_efc,struct EnumFileConfig *cur_efc,FileInfo &fi) override
{
os_out<<OS_TEXT("[Folder] ")<<fi.fullname<<std::endl;
}
void ProcFile(struct EnumFileConfig *,FileInfo &fi) override
{
os_out<<OS_TEXT("[File] ")<<fi.fullname<<std::endl;
}
};//class EnumFile
int os_main(int argc,os_char **argv)
{
os_out<<OS_TEXT("EnumFile test")<<std::endl<<std::endl;
if(argc!=2)
{
os_out<<OS_TEXT("example: EnumFileTest [path]")<<std::endl;
return(0);
}
os_out<<OS_TEXT("enum folder: ")<<argv[1]<<std::endl;
EnumFileConfig efc(argv[1]);
MyEnumFile ef;
efc.sub_folder=true;
ef.Enum(&efc);
return 0;
}