38 posts
Location
Somewhere near keyboard
Posted 25 November 2015 - 07:33 PM
Hello.
I've just started writing new cool thing and suddenly fs.open stopped working:
local h=fs.open("h.txt","w")
local lin=lines("hello\nworld")
print(h==nil)
-- And here, I get "true", so file handle is actually nil
if h then
for _,l in ipairs(lin) do
h.write(l)
end
h.close()
end
Are there any ways to make it work?
Edited on 25 November 2015 - 07:01 PM
3057 posts
Location
United States of America
Posted 25 November 2015 - 07:57 PM
1) Is h.txt an existing file?
2) Why are you opening with fs in read mode & using it as if it's io in write mode?
Edited on 25 November 2015 - 06:57 PM
38 posts
Location
Somewhere near keyboard
Posted 25 November 2015 - 07:59 PM
Whoops, forgot to change some code left after trying "w" mode.
Write mode did not help too.
H.txt doesn't exist when I call fs.open(…)
3057 posts
Location
United States of America
Posted 25 November 2015 - 08:01 PM
Opening a file in write mode should always work, unless one of the following is happening:
1) Something has edited fs.open (delete / move any startup files, reboot computer to fix)
2) You are using an emulator (stop using an emulator to fix)
3) You're opening something that is read-only (eg rom/programs/edit) (Try running edit h.txt from the shell to see if this is the problem)
38 posts
Location
Somewhere near keyboard
Posted 25 November 2015 - 08:05 PM
Well, my "startup" doesn't override fs.open (it replaces only things related to os.loadAPI)
I'm working in MC, so it's not an emulator. Tried to open it using shell: still no luck
7083 posts
Location
Tasmania (AU)
Posted 26 November 2015 - 12:11 AM
4) The computer's drive is full.
38 posts
Location
Somewhere near keyboard
Posted 26 November 2015 - 07:19 AM
Okay, I'll try to increase limit
Edit: Well, that didn't help too
Edited on 26 November 2015 - 06:39 AM
7083 posts
Location
Tasmania (AU)
Posted 26 November 2015 - 01:16 PM
Time to show us the rest of the code, in that case.
38 posts
Location
Somewhere near keyboard
Posted 26 November 2015 - 03:10 PM
Well, if dropbox links are allowed here…
(If not, I'll remove this). Just I have too many files to post here.
The most important code is in /lib/libfstream, /bin/luash and /boot/postInitHooks
https://www.dropbox....200/13.zip?dl=0
38 posts
Location
Somewhere near keyboard
Posted 26 November 2015 - 06:03 PM
Alright, somehow this started working.
(Maybe with _G.fs.open = fs.open, but I don't know if it solved this)
Edited on 26 November 2015 - 05:32 PM