Changeset 807
- Timestamp:
- 01/16/10 00:15:46 (8 weeks ago)
- Location:
- trunk/lugre
- Files:
-
- 3 modified
-
lua/lib.util.lua (modified) (1 diff)
-
src/lugre_scripting.general.cpp (modified) (2 diffs)
-
src/lugre_shell.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lugre/lua/lib.util.lua
r795 r807 70 70 fp:write(data) 71 71 fp:close() 72 end 73 74 function CopyFile (src,dst) -- not tested with binary/nontext files, should work, but not sure yet 75 --~ print("CopyFile",src,dst) 76 local data = FileGetContents(src) 77 if (data) then FilePutContents(dst,data) end 78 end 79 function CopyDir (src,dst,bIncludeSpecial) 80 --~ print("CopyDir",src,dst) 81 assert(file_exists(dst)) 82 for k,name in ipairs(dirlist(src,false,true)) do CopyFile(src..name,dst..name) end 83 for k,name in ipairs(dirlist(src,true,false)) do if (name ~= "." and name ~= ".." and (name ~= ".svn" or bIncludeSpecial)) then mkdir(dst..name) CopyDir(src..name.."/",dst..name.."/") end end 84 end 85 function GetHomePath () -- returns /home/username without trailing slash 86 if (WIN32) then return end -- not yet implemented 87 local file = io.popen("echo $HOME") 88 if (not file) then return end -- popen or home dir not available 89 for line in file:lines() do file:close() return string.sub(line,1,-1) end -- remove newline 90 file:close() 72 91 end 73 92 -
trunk/lugre/src/lugre_scripting.general.cpp
r805 r807 262 262 263 263 // lua : int mkdir (path,mode) -- mode is ignored for win, 0x700 as default for linux (restrictive, only owner) 264 //~ d--x--x--x 1+1*8+1*8*8 265 //~ d-wx--x--x 3+3*8+3*8*8 266 //~ drwxr-xr-x 7+7*8+7*8*8 267 //~ drwx------ 7*8*8 = oct: 0700 268 //~ d------r-x 7 264 269 static int l_mkdir (lua_State *L) { PROFILE 265 270 std::string sPath = luaL_checkstring(L,1); 266 int iMode = cLuaBindDirectQuickWrapHelper::ParamIntDefault(L,2,0 x700);271 int iMode = cLuaBindDirectQuickWrapHelper::ParamIntDefault(L,2,0700); 267 272 lua_pushnumber(L,rob_mkdir(sPath.c_str(),iMode)); 268 273 return 1; … … 285 290 for (unsigned int i=0;i<res.size();++i) { 286 291 lua_pushstring( L, res[i].c_str() ); 287 lua_rawseti( L, -2, i );292 lua_rawseti( L, -2, i+1 ); // i+1 : lua indices start at 1 288 293 } 289 294 return 1; -
trunk/lugre/src/lugre_shell.cpp
r806 r807 45 45 46 46 int rob_mkdir (const char* path,int perm) { 47 // found on http://www.devx.com/cplus/10MinuteSolution/26748/1954 48 #ifdef mkdir 49 #ifdef WIN32 50 return mkdir(path); 51 #else 52 return mkdir(path,(mode_t)perm); 53 #endif 47 // found on http://www.devx.com/cplus/10MinuteSolution/26748/1954 // perm ignored for win 48 //~ printf("rob_mkdir(%s,0x%x)\n",path,perm); 49 #ifdef WIN32 50 return mkdir(path); // simply comment out for win if it causes trouble during compile, currently (15.01.2010) only needed for iris install using home path 54 51 #else 55 return -1;52 return mkdir(path,(mode_t)perm); 56 53 #endif 54 return -2; 57 55 } 58 56 59 57 int rob_rmdir (const char* path) { 60 #ifdef rmdir61 return rmdir(path);58 #ifdef WIN32 59 return rmdir(path); // simply comment out for win if it causes trouble during compile, currently (15.01.2010) only needed for iris install using home path 62 60 #else 63 return -1;61 return rmdir(path); 64 62 #endif 63 return -2; 65 64 } 66 65
