makes locs on desktop
usage: loc path (name)
put code in appdata/system/util/loc.lua
you can change file name to whatever you like, like ln.lua to use as ln
function ext(str) for i=1,#str do if (str:sub(i,i)==".") return i-1 end return #str end local orig=env().argv[1] if (not orig) print("usage: "..env().argv[0].." path (name)") exit(1) if (orig:sub(#orig)=="/") orig=orig:sub(1,#orig-1) if (orig:sub(1,1)!="/") orig=fetch("/ram/system/pwd.pod").."/"..orig if (not fstat(orig)) print("file does not exist ("..orig..")") exit(1) local name=env().argv[2] and #env().argv[2]!=0 and env().argv[2] or orig:basename() name=name:sub(1,ext(name)) local targ="/desktop/"..name..".loc" if (fstat(targ)) print("loc already exists ("..targ..")") exit(1) store(targ,{location=orig}) local orig_meta=fetch_metadata(orig) local targ_meta=fetch_metadata(targ) if (orig_meta and orig_meta.icon) then targ_meta.icon=fetch_metadata(orig).icon store_metadata(targ,targ_meta) end print("-> "..targ.." done") |
[Please log in to post a comment]