 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
Elxx
Joined: 07 Dec 2005 Posts: 16
|
Posted: Thu Feb 09, 2006 9:45 am Post subject: File opening bug...? |
|
|
I'm working on my PSP web server, and it seems there is an interesting bug where it seems that any modifications made to files loaded by io.open (or io.input) will not exactly display right. It seems that it somehow stores the file size in a cache of some sort, and refuses to load anything beyond that. For example, if I have a file with the content:
I load it with LuaPlayer, and it outputs just that. And I then modify it to make it read:
But when loaded in the same program, even if I properly closed the old one and everything, it will output:
The 4 extra bytes added to the middle somehow seem to 'push out' the last 4 bytes at the end.
It seems to all work fine in my PC's Lua interpreter, so I suspect the bug may be somewhere within LuaPlayer. Any ideas?
Here's the code for the portion of the app that loads the file...anything else I make of the sort exhibits the same problem.
| Code: | function parse_lhp(fname)
output = ""
code = ""
res = ""
cp = false
lines = nil
line = nil
file = io.input(fname, "rb")
for line in io.lines() do
if string.find(line, "%<%?") ~= nil then
cp = true
end
if cp == true then
if string.find(line, "%<%?") == nil and string.find(line, "%?%>") == nil then
code = code .. line
end
else
output = output .. line
end
if string.find(line, "%?%>") ~= nil and cp == true then
cp = false
res = run_lua(code)
output = output .. res
end
end
file:close()
return output
end
function run_lua(code)
local result,err = loadstring(code)
if not result then
return "<br />Error: " .. err
else
result, err = pcall(result)
if not result then
return "<br />Error: " .. err
else
return "<br />Parsed."
end
end
end |
|
|
| Back to top |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Thu Feb 09, 2006 1:19 pm Post subject: |
|
|
it's very easy to get corrupt files while using usb mode..
usb should be deactivated before reading or writing any files from within a script. _________________ Chaosmachine Studios: High Quality Homebrew. |
|
| Back to top |
|
 |
modsyn
Joined: 27 Sep 2005 Posts: 28
|
Posted: Fri Feb 10, 2006 1:57 am Post subject: |
|
|
didn't see any USB code in there, and i don't think a web server needs to use it, so i doubt that is the problem at all. i wish i could help, but sadly i can just
suggest this: have you tried:
| Code: | | for line = io.lines(fname) do |
instead of
| Code: | file = io.input(fname, "rb")
for line in io.lines() do
|
however, the reason i'm replying is to ask if you are adding the ability to
run LUA scripted dynamic pages. that would be really neat if you are. i
hope you get it worked out. |
|
| Back to top |
|
 |
Elxx
Joined: 07 Dec 2005 Posts: 16
|
Posted: Fri Feb 10, 2006 7:13 am Post subject: |
|
|
| chaos wrote: | it's very easy to get corrupt files while using usb mode..
usb should be deactivated before reading or writing any files from within a script. |
I thought you just need to deactivate when writing files...hmm.
Modsyn, I have already tried that, but thanks.
| modsyn wrote: | however, the reason i'm replying is to ask if you are adding the ability to
run LUA scripted dynamic pages. that would be really neat if you are. i
hope you get it worked out. |
Yes I am. :)
The one reason I was wanting to look into this bug is because it would make dynamic page testing maybe a bit frustrating if you had to restart the server each time you changed a file. But it's still beta and all, so people will have to live with it. |
|
| Back to top |
|
 |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|