X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fioncore_wd.lua;h=b00b18daffcfeacbddb09476403ee9ee7dc28325;hp=84107b81568a3f2012fe388f5f849d4ada2bee98;hb=HEAD;hpb=8366314611bf30a0f31d25bf5f5023186fa87692 diff --git a/ioncore/ioncore_wd.lua b/ioncore/ioncore_wd.lua index 84107b8..b00b18d 100644 --- a/ioncore/ioncore_wd.lua +++ b/ioncore/ioncore_wd.lua @@ -1,41 +1,30 @@ -- -- ion/share/ioncore_wd.lua -- --- Copyright (c) Tuomo Valkonen 2004-2006. +-- Copyright (c) Tuomo Valkonen 2004-2009. -- --- Ion is free software; you can redistribute it and/or modify it under --- the terms of the GNU Lesser General Public License as published by --- the Free Software Foundation; either version 2.1 of the License, or --- (at your option) any later version. +-- See the included file LICENSE for details. -- local savefile="saved_wd" local dirs={} -local px +local lfs -if pcall(function() return require('posix') end) then - px=posix +if pcall(function() return require('lfs') end) then + lfs=_G["lfs"] end local function checkdir(d) - if not px then + if not lfs then return true else - local t, err=px.stat(d, "type") + local t, err=lfs.attributes(d, "mode") if not t then return nil, err - elseif t=="link" then - local d2, err=px.readlink(d) - if not d2 then - return nil, err - else - print('follow') - return checkdir(d2) - end elseif t=="directory" then return true else - return TR("Not a directory.") + return nil, TR("Not a directory.") end end end @@ -54,7 +43,7 @@ end --DOC -- Change default working directory for new programs started in \var{reg}. function ioncore.chdir_for(reg, dir) - assert(type(dir)=="string") + assert(dir==nil or type(dir)=="string") if dir=="" or dir==nil then dirs[reg]=nil return true @@ -90,6 +79,7 @@ end local function lookup_runinxterm_warn(prog, title, wait) local rx=lookup_script_warn("ion-runinxterm") if rx then + rx="exec "..rx if wait then rx=rx.." -w" end @@ -123,8 +113,7 @@ function ioncore.exec_on(reg, cmd, merr_internal) cmd='XTERMCMD='..string.shell_safe(XTERM)..' '..cmd end end - return ioncore.do_exec_rw(reg:rootwin_of(), cmd, - ioncore.get_dir_for(reg), + return ioncore.do_exec_on(reg, cmd, ioncore.get_dir_for(reg), merr_internal) end @@ -151,7 +140,10 @@ end local function save_config() local t={} for r, d in pairs(dirs) do - t[r:name()]=d + local nm=obj_exists(r) and r:name() + if nm then + t[nm]=d + end end ioncore.write_savefile(savefile, t) end