@@ -78,7 +78,6 @@ void LuaStateWrapper::Initialize() {
78
78
.def (" GetFileList" , &LuaStateWrapper::FileList, luabind::adopt (luabind::return_value) + luabind::return_stl_iterator)
79
79
.def (" FileExists" , &LuaStateWrapper::FileExists)
80
80
.def (" DirectoryExists" , &LuaStateWrapper::DirectoryExists)
81
- .def (" IsValidModulePath" , &LuaStateWrapper::IsValidModulePath)
82
81
.def (" FileOpen" , &LuaStateWrapper::FileOpen)
83
82
.def (" FileClose" , &LuaStateWrapper::FileClose)
84
83
.def (" FileRemove" , &LuaStateWrapper::FileRemove)
@@ -278,7 +277,6 @@ const std::vector<std::string>* LuaStateWrapper::DirectoryList(const std::string
278
277
const std::vector<std::string>* LuaStateWrapper::FileList (const std::string& path) { return g_LuaMan.FileList (path); }
279
278
bool LuaStateWrapper::FileExists (const std::string& path) { return g_LuaMan.FileExists (path); }
280
279
bool LuaStateWrapper::DirectoryExists (const std::string& path) { return g_LuaMan.DirectoryExists (path); }
281
- bool LuaStateWrapper::IsValidModulePath (const std::string& path) { return g_LuaMan.IsValidModulePath (path); }
282
280
int LuaStateWrapper::FileOpen (const std::string& path, const std::string& accessMode) { return g_LuaMan.FileOpen (path, accessMode); }
283
281
void LuaStateWrapper::FileClose (int fileIndex) { return g_LuaMan.FileClose (fileIndex); }
284
282
void LuaStateWrapper::FileCloseAll () { return g_LuaMan.FileCloseAll (); }
@@ -885,17 +883,17 @@ LuaMan::~LuaMan() {
885
883
}
886
884
887
885
const std::vector<std::string>* LuaMan::DirectoryList (const std::string& path) {
888
- std::string fullPath = System::GetWorkingDirectory () + g_PresetMan. GetFullModulePath ( path) ;
886
+ std::string fullPath = System::GetWorkingDirectory () + path;
889
887
auto * directoryPaths = new std::vector<std::string>();
890
888
891
- if (IsValidModulePath ( fullPath) ) {
889
+ if (fullPath. find ( " .. " ) == std::string::npos ) {
892
890
#ifndef _WIN32
893
891
fullPath = GetCaseInsensitiveFullPath (fullPath);
894
892
#endif
895
893
if (std::filesystem::exists (fullPath)) {
896
- for (const std::filesystem::directory_entry& directoryEntry : std::filesystem::directory_iterator (fullPath)) {
897
- if (directoryEntry .is_directory ()) {
898
- directoryPaths->emplace_back (directoryEntry .path ().filename ().generic_string ());
894
+ for (const auto & entry : std::filesystem::directory_iterator (fullPath)) {
895
+ if (entry .is_directory ()) {
896
+ directoryPaths->emplace_back (entry .path ().filename ().generic_string ());
899
897
}
900
898
}
901
899
}
@@ -904,17 +902,17 @@ const std::vector<std::string>* LuaMan::DirectoryList(const std::string& path) {
904
902
}
905
903
906
904
const std::vector<std::string>* LuaMan::FileList (const std::string& path) {
907
- std::string fullPath = System::GetWorkingDirectory () + g_PresetMan. GetFullModulePath ( path) ;
905
+ std::string fullPath = System::GetWorkingDirectory () + path;
908
906
auto * filePaths = new std::vector<std::string>();
909
907
910
- if (IsValidModulePath ( fullPath) ) {
908
+ if (fullPath. find ( " .. " ) == std::string::npos ) {
911
909
#ifndef _WIN32
912
910
fullPath = GetCaseInsensitiveFullPath (fullPath);
913
911
#endif
914
912
if (std::filesystem::exists (fullPath)) {
915
- for (const std::filesystem::directory_entry& directoryEntry : std::filesystem::directory_iterator (fullPath)) {
916
- if (directoryEntry .is_regular_file ()) {
917
- filePaths->emplace_back (directoryEntry .path ().filename ().generic_string ());
913
+ for (const auto & entry : std::filesystem::directory_iterator (fullPath)) {
914
+ if (entry .is_regular_file ()) {
915
+ filePaths->emplace_back (entry .path ().filename ().generic_string ());
918
916
}
919
917
}
920
918
}
@@ -924,7 +922,7 @@ const std::vector<std::string>* LuaMan::FileList(const std::string& path) {
924
922
925
923
bool LuaMan::FileExists (const std::string& path) {
926
924
std::string fullPath = System::GetWorkingDirectory () + g_PresetMan.GetFullModulePath (path);
927
- if (IsValidModulePath ( fullPath) ) {
925
+ if (fullPath. find ( " .. " ) == std::string::npos ) {
928
926
#ifndef _WIN32
929
927
fullPath = GetCaseInsensitiveFullPath (fullPath);
930
928
#endif
@@ -935,7 +933,7 @@ bool LuaMan::FileExists(const std::string& path) {
935
933
936
934
bool LuaMan::DirectoryExists (const std::string& path) {
937
935
std::string fullPath = System::GetWorkingDirectory () + g_PresetMan.GetFullModulePath (path);
938
- if (IsValidModulePath ( fullPath) ) {
936
+ if (fullPath. find ( " .. " ) == std::string::npos ) {
939
937
#ifndef _WIN32
940
938
fullPath = GetCaseInsensitiveFullPath (fullPath);
941
939
#endif
@@ -1049,7 +1047,7 @@ bool LuaMan::FileRemove(const std::string& path) {
1049
1047
1050
1048
bool LuaMan::DirectoryCreate (const std::string& path, bool recursive) {
1051
1049
std::string fullPath = System::GetWorkingDirectory () + g_PresetMan.GetFullModulePath (path);
1052
- if (IsValidModulePath ( fullPath) ) {
1050
+ if (fullPath. find ( " .. " ) == std::string::npos ) {
1053
1051
#ifndef _WIN32
1054
1052
fullPath = GetCaseInsensitiveFullPath (fullPath);
1055
1053
#endif
@@ -1067,7 +1065,7 @@ bool LuaMan::DirectoryCreate(const std::string& path, bool recursive) {
1067
1065
1068
1066
bool LuaMan::DirectoryRemove (const std::string& path, bool recursive) {
1069
1067
std::string fullPath = System::GetWorkingDirectory () + g_PresetMan.GetFullModulePath (path);
1070
- if (IsValidModulePath ( fullPath) ) {
1068
+ if (fullPath. find ( " .. " ) == std::string::npos ) {
1071
1069
#ifndef _WIN32
1072
1070
fullPath = GetCaseInsensitiveFullPath (fullPath);
1073
1071
#endif
@@ -1109,7 +1107,7 @@ bool LuaMan::FileRename(const std::string& oldPath, const std::string& newPath)
1109
1107
bool LuaMan::DirectoryRename (const std::string& oldPath, const std::string& newPath) {
1110
1108
std::string fullOldPath = System::GetWorkingDirectory () + g_PresetMan.GetFullModulePath (oldPath);
1111
1109
std::string fullNewPath = System::GetWorkingDirectory () + g_PresetMan.GetFullModulePath (newPath);
1112
- if (IsValidModulePath ( fullOldPath) && IsValidModulePath ( fullNewPath) ) {
1110
+ if (fullOldPath. find ( " .. " ) == std::string::npos && fullNewPath. find ( " .. " ) == std::string::npos ) {
1113
1111
#ifndef _WIN32
1114
1112
fullOldPath = GetCaseInsensitiveFullPath (fullOldPath);
1115
1113
fullNewPath = GetCaseInsensitiveFullPath (fullNewPath);
0 commit comments