Quote |
it becomes easy to use and not realize the overhead of what is happening, opening and closing files |
Code Sample |
dotmydsl=io.open("/home/dsl/.mydsl") if dotmydsl then mydsl_dir = dotmydsl:read("*line") io.close(dotmydsl) else mydsl_dir = "/" end |
Code Sample |
#!/bin/murgaLua -- (c) 2005, 2006 Robert Shingledecker -- myDSL info display usually called from mydslBrowser dofile("/etc/init.d/functions5.lua") function parseInfo(infofile) local i,j = string.find(infofile,".info") if not i then return nil end local basename=string.sub(infofile,1,i-1) local k,l = string.find(basename,'.dsl') if k then return basename else m,n = string.find(basename,'.uci') if m then return basename else o,p = string.find(basename,'.unc') if o then return basename else return basename .. '.tar.gz' end end end end -- Main if #arg == 2 then library = arg[1] infofile = arg[2] else print("usage: mydslInfo.lua [library_name infofile_name]") os.exit(1) end os.execute("pkill mydslBrowser.lua") mirror = getOption("/opt/.dslrc","Mirror") protocol = getOption("/opt/.dslrc","Protocol") os.execute('wget -q '..protocol..'://'..mirror..'/mydsl/'..library..'/'..infofile) wWidth=500 wHgth=290 w = fltk:Fl_Window(wWidth,wHgth,infofile) browser = fltk:Fl_Browser(0,0,wWidth,wHgth-30) if not browser:load(infofile) then print("can't load ", infofile) os.exit(1) end cancelBtn = fltk:Fl_Button(180,wHgth-28,70,25,"&Cancel") cancelBtn:shortcut('c') cancelBtn:callback( function(cancelBtn) os.remove(infofile) os.exit(0) end) downloadBtn = fltk:Fl_Button(255,wHgth-28,70,25,"&Download") downloadBtn:shortcut('d') downloadBtn:callback( function(downloadBtn) extension = parseInfo(infofile) os.remove(infofile) os.execute('mydslDownload.lua ' .. library .. ' ' .. extension) os.exit(0) end) w:resizable(w) w:show() Fl:run() |