Changeset 804
- Timestamp:
- 01/14/10 11:36:04 (8 weeks ago)
- Location:
- trunk/lugre/src
- Files:
-
- 2 modified
-
lugre_scripting.general.cpp (modified) (3 diffs)
-
lugre_shell.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lugre/src/lugre_scripting.general.cpp
r756 r804 64 64 65 65 void rob_dirlist (const char* path,std::vector<std::string>& res,const bool bDirs,const bool bFiles); 66 67 int rob_mkdir (const char* path,int perm); 68 int rob_rmdir (const char* path); 66 69 }; 67 70 … … 256 259 } 257 260 261 262 263 // lua : int mkdir (path,mode) -- mode is ignored for win, 0x777 is write 264 static int l_mkdir (lua_State *L) { PROFILE 265 std::string sPath = luaL_checkstring(L,1); 266 int iMode = luaL_checkint(L,2); 267 lua_pushnumber(L,rob_mkdir(sPath.c_str(),iMode)); 268 return 1; 269 } 270 271 272 // lua : int rmdir (path) -- might not work if dir is not empty, but be careful 273 static int l_rmdir (lua_State *L) { PROFILE 274 std::string sPath = luaL_checkstring(L,1); 275 lua_pushnumber(L,rob_rmdir(sPath.c_str())); 276 return 1; 277 } 258 278 259 279 /// table={filename,...} dirlist (dirpath,bDirs,bFiles) … … 476 496 lua_register(L,"file_exists", l_file_exists); 477 497 lua_register(L,"file_size", l_file_size); 498 lua_register(L,"mkdir", l_mkdir); 499 lua_register(L,"rmdir", l_rmdir); 478 500 lua_register(L,"remove_file", l_remove_file); 479 501 lua_register(L,"dirlist", l_dirlist); -
trunk/lugre/src/lugre_shell.cpp
r514 r804 9 9 #include <vector> 10 10 #include <string> 11 #include <unistd.h> // mkdir? 11 12 12 13 … … 19 20 #include <dirent.h> 20 21 #include <sys/time.h> 22 #include <sys/stat.h> // mkdir? 21 23 #endif 22 24 … … 43 45 // ****** ****** ****** cShell 44 46 47 int rob_mkdir (const char* path,int perm) { 48 // found on http://www.devx.com/cplus/10MinuteSolution/26748/1954 49 #ifdef mkdir 50 #ifdef WIN32 51 return mkdir(path); 52 #else 53 return mkdir(path,(mode_t)perm); 54 #endif 55 #else 56 return -1; 57 #endif 58 } 59 60 int rob_rmdir (const char* path) { 61 #ifdef rmdir 62 return rmdir(path); 63 #else 64 return -1; 65 #endif 66 } 45 67 46 68 /// lists files and directories in a given directory (adds them to res)
