Filesystem Hack: Set Identity to Whatever You Want

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
kalle2990
Party member
Posts: 245
Joined: Sat Sep 12, 2009 1:17 pm
Location: Sweden

Re: Filesystem Hack: Set Identity to Whatever You Want

Post by kalle2990 »

Okay, I have tested the new version on Ubuntu now and it seems to be working just fine. It features detection of Linux desktops without gnome and Macs, and opening of files for them ^^

Please tell me how it runs on OSX ;)
Attachments
File Explorer.love
Version 1.2
(1.32 KiB) Downloaded 97 times
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Filesystem Hack: Set Identity to Whatever You Want

Post by BlackBulletIV »

popen isn't supported for me it seems. How about using os.execute with output redirection, like this:

Code: Select all

local file = os.tmpname()
os.execute('uname -s > ' .. file)
local f = io.open(file)
local os = f:read('*a')
f:close()
I haven't tested it, nor did I look at the manual, but I think that's correct.

Man I find Lua's lack of functionality annoying.
User avatar
TsT
Party member
Posts: 161
Joined: Thu Sep 25, 2008 7:04 pm
Location: France
Contact:

Re: Filesystem Hack: Set Identity to Whatever You Want

Post by TsT »

Or use io.popen() instead of os.execute()

Code: Select all

local f = io.popen("pwd") -- runs command
local l = f:read("*a") -- read output of command
print(l)
f:close()

Code: Select all

function execute(cmd)
        local f = io.popen(cmd)
        local str = f:read("*a")
        return str
end

function str2tbl(str, sep)
        sep = sep or "\n"
        local t = {}
        for line in string.gmatch(str, "[^\n]+") do
                table.insert(t, line)
        end
        return t
end

table.foreach(str2tbl(execute("uname -s")), print)
My projects current projects : dragoon-framework (includes lua-newmodule, lua-provide, lovemodular, , classcommons2, and more ...)
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Filesystem Hack: Set Identity to Whatever You Want

Post by thelinx »

BlackBulletIV wrote:popen isn't supported for me it seems.
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Filesystem Hack: Set Identity to Whatever You Want

Post by slime »

io.popen works fine using a regular Lua install but says it's not supported when I run it through LÖVE, oddly enough (OSX).
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Filesystem Hack: Set Identity to Whatever You Want

Post by bartbes »

It is non-portable, and it seems most love distributed lua builds don't support it.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 50 guests