]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/ioncore_wd.lua
Update cfg_kludge_flash for Flash 10
[ion3.git] / ioncore / ioncore_wd.lua
index cdb7a36ed815d316df295080ed52629b1377c24d..b00b18daffcfeacbddb09476403ee9ee7dc28325 100644 (file)
@@ -1,38 +1,30 @@
 --
 -- ion/share/ioncore_wd.lua
 -- 
--- Copyright (c) Tuomo Valkonen 2004-2007.
+-- Copyright (c) Tuomo Valkonen 2004-2009.
 --
 -- 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
@@ -51,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
@@ -87,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
@@ -147,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