diff --git a/inc/hgl/filesystem/FileSystem.h b/inc/hgl/filesystem/FileSystem.h index d025124..7daafd7 100644 --- a/inc/hgl/filesystem/FileSystem.h +++ b/inc/hgl/filesystem/FileSystem.h @@ -1,8 +1,7 @@ #ifndef HGL_FILE_SYSTEM_INCLUDE #define HGL_FILE_SYSTEM_INCLUDE -#include -#include +#include namespace hgl { namespace io @@ -12,6 +11,50 @@ namespace hgl namespace filesystem { + template + inline const String ComboFilename(const StringList> &sl,const T spear_char=(T)HGL_DIRECTORY_SEPARATOR_RAWCHAR) + { + T *fullname=nullptr; + + { + int total=0; + + for(auto str:sl) + total+=str->Length(); + + total+=sl.GetCount(); + ++total; + + fullname=new T[total+1]; + } + + T *p=fullname; + const T *tmp; + int len; + bool first=true; + + for(auto str:sl) + { + len=str->Length(); + + tmp=trim(str->c_str(),len,isslash); + + if(first) + { + *p=spear_char; + ++p; + first=false; + } + + hgl_cpy(p,tmp,len); + p+=len; + } + + *p=0; + + return String::newOf(fullname,p-fullname); + } + template inline String MergeFilename(const String &pathname,const String &filename,const T directory_separator_char,const T *directory_separator_str) {