Posted: Fri Dec 28, 2018 5:43 am Post subject: lastmod function relying on shell/command line
Not strictly cheat engine related but probably useful anyways, my problem is I'm trying to get the last modification date of files as part of an effort to make a makefile.lua for unrelated projects and provide some barebone functionality that makefiles normally provide, this here is the code I have:
Code:
local nsys = { isWindows = ((os.getenv"os" or ""):match"^Windows") }
-- bunch of code irrelevant to the problem
if nsys.isWindows then
nsys.lastmod = function(name)
return io.popen('dir /T:M "' .. name .. '"', "r")
end
else
nsys.lastmod = function(name)
return io.popen('stat -c %Y "' .. name .. '"')
end
end
But it returns a file handle instead of the output, I've work to go to now so I'd thought I'd post the problem here and see what is said by the time I return. Things I'm looking for are both the output problem and (if any) suggestions for other systems. _________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
...
Starts program prog in a separated process and returns a file handle that you can use to read data from this program (if mode is "r", the default) or to write data to this program (if mode is "w").
Example:
Code:
local f = io.popen('dir /B')
local dir = {}
for entry in f:lines() do
dir[#dir+1] = entry
end
for i,v in ipairs(dir) do
print(i,v)
end
_________________
I don't know where I'm going, but I'll figure it out when I get there.
Ah, right, that was it, was in rush to close up at that point so didn't give any thought to it. Well I can still wait to see if any other system variants are posted _________________
Those who do not trust in christ to save them from their sins will only experience hell when their soul is released from it's earthly vessel.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum