@@ -687,7 +687,7 @@ int ModApiMainMenu::l_get_texturepath_share(lua_State *L)
687
687
int ModApiMainMenu::l_create_dir (lua_State *L) {
688
688
const char *path = luaL_checkstring (L, 1 );
689
689
690
- if (ModApiMainMenu::isMinetestPath (path)) {
690
+ if (ModApiMainMenu::mayModifyPath (path)) {
691
691
lua_pushboolean (L, fs::CreateAllDirs (path));
692
692
return 1 ;
693
693
}
@@ -703,7 +703,7 @@ int ModApiMainMenu::l_delete_dir(lua_State *L)
703
703
704
704
std::string absolute_path = fs::RemoveRelativePathComponents (path);
705
705
706
- if (ModApiMainMenu::isMinetestPath (absolute_path)) {
706
+ if (ModApiMainMenu::mayModifyPath (absolute_path)) {
707
707
lua_pushboolean (L, fs::RecursiveDelete (absolute_path));
708
708
return 1 ;
709
709
}
@@ -728,7 +728,7 @@ int ModApiMainMenu::l_copy_dir(lua_State *L)
728
728
std::string absolute_destination = fs::RemoveRelativePathComponents (destination);
729
729
std::string absolute_source = fs::RemoveRelativePathComponents (source);
730
730
731
- if ((ModApiMainMenu::isMinetestPath (absolute_destination))) {
731
+ if ((ModApiMainMenu::mayModifyPath (absolute_destination))) {
732
732
bool retval = fs::CopyDir (absolute_source,absolute_destination);
733
733
734
734
if (retval && (!keep_source)) {
@@ -750,7 +750,7 @@ int ModApiMainMenu::l_extract_zip(lua_State *L)
750
750
751
751
std::string absolute_destination = fs::RemoveRelativePathComponents (destination);
752
752
753
- if (ModApiMainMenu::isMinetestPath (absolute_destination)) {
753
+ if (ModApiMainMenu::mayModifyPath (absolute_destination)) {
754
754
fs::CreateAllDirs (absolute_destination);
755
755
756
756
io::IFileSystem *fs = RenderingEngine::get_filesystem ();
@@ -838,28 +838,23 @@ int ModApiMainMenu::l_get_mainmenu_path(lua_State *L)
838
838
}
839
839
840
840
/* *****************************************************************************/
841
- bool ModApiMainMenu::isMinetestPath ( std::string path)
841
+ bool ModApiMainMenu::mayModifyPath ( const std::string & path)
842
842
{
843
- if (fs::PathStartsWith (path,fs::TempPath ()))
843
+ if (fs::PathStartsWith (path, fs::TempPath ()))
844
844
return true ;
845
845
846
- /* games */
847
- if (fs::PathStartsWith (path,fs::RemoveRelativePathComponents (porting::path_share + DIR_DELIM + " games" )))
846
+ if (fs::PathStartsWith (path, fs::RemoveRelativePathComponents (porting::path_user + DIR_DELIM " games" )))
848
847
return true ;
849
848
850
- /* mods */
851
- if (fs::PathStartsWith (path,fs::RemoveRelativePathComponents (porting::path_user + DIR_DELIM + " mods" )))
849
+ if (fs::PathStartsWith (path, fs::RemoveRelativePathComponents (porting::path_user + DIR_DELIM " mods" )))
852
850
return true ;
853
851
854
- /* mods */
855
- if (fs::PathStartsWith (path,fs::RemoveRelativePathComponents (porting::path_user + DIR_DELIM + " textures" )))
852
+ if (fs::PathStartsWith (path, fs::RemoveRelativePathComponents (porting::path_user + DIR_DELIM " textures" )))
856
853
return true ;
857
854
858
- /* worlds */
859
- if (fs::PathStartsWith (path,fs::RemoveRelativePathComponents (porting::path_user + DIR_DELIM + " worlds" )))
855
+ if (fs::PathStartsWith (path, fs::RemoveRelativePathComponents (porting::path_user + DIR_DELIM " worlds" )))
860
856
return true ;
861
857
862
-
863
858
return false ;
864
859
}
865
860
@@ -895,7 +890,7 @@ int ModApiMainMenu::l_download_file(lua_State *L)
895
890
// check path
896
891
std::string absolute_destination = fs::RemoveRelativePathComponents (target);
897
892
898
- if (ModApiMainMenu::isMinetestPath (absolute_destination)) {
893
+ if (ModApiMainMenu::mayModifyPath (absolute_destination)) {
899
894
if (GUIEngine::downloadFile (url,absolute_destination)) {
900
895
lua_pushboolean (L,true );
901
896
return 1 ;
0 commit comments