Page 2 of 3

Re: File System Problem, Cant write save game.

Posted: Sat Jun 13, 2009 5:19 pm
by whitebear

Code: Select all

   mapfile = love.filesystem.newFile("filename.txt", love.file_write)
   love.filesystem.open(mapfile)
   love.filesystem.write(mapfile, "blah")
   love.filesystem.close(mapfile)
Worked just fine for me...
Loading works too.

Re: File System Problem, Cant write save game.

Posted: Sun Jun 14, 2009 5:04 am
by Flesh Gregor
bartbes wrote:No, it actually says love.filesystem.open failed
This doesn't make sense to me because when I ran that same line without the contained assertion stderr.txt didn't give me an error (this could just be some weird case of lua not noticing an error or something).

Thanks for the tip about assert(), though, I was way off. I'll check the code tomorrow night.

Edit: Quick installed Love on this computer and tested it. Works for me, thanks again.

Re: File System Problem, Cant write save game.

Posted: Thu Jul 09, 2009 4:41 pm
by Sparx
doesn't work for me:
If i use the code as is, the file is not edited. If I use a subdirectory the game closes imidiately.
stderr(uses german so I translate):
Error, could not open file: The system could not find the given file.

just found out something very interesting:

Code: Select all

file = io.open ("maps/test.txt","w")
file:write("Hello World\n2nd line")
file:close() 
file = io.open("maps/test.txt","r")
content = file:read("*a")
file:close() 
Working on external files =)

Re: File System Problem, Cant write save game.

Posted: Thu Jul 09, 2009 5:01 pm
by bartbes
I don't understand the problem, what code isn't working, and what's new and interesting about lua's I/O system?

Re: File System Problem, Cant write save game.

Posted: Thu Jul 09, 2009 8:39 pm
by Sparx

Code: Select all

   mapfile = love.filesystem.newFile("filename.txt", love.file_write)
   love.filesystem.open(mapfile)
   love.filesystem.write(mapfile, "blah")
   love.filesystem.close(mapfile)
This didn't work

Interesting is, that i once started a topiv about reading writing external files and answer was: it's not really possible now i found out =)

Re: File System Problem, Cant write save game.

Posted: Thu Jul 09, 2009 9:25 pm
by Robin
That's weird... I copy/pasted it, and it worked right away for me.

Re: File System Problem, Cant write save game.

Posted: Fri Jul 10, 2009 7:14 am
by bartbes
How do you run that code?

Re: File System Problem, Cant write save game.

Posted: Fri Jul 10, 2009 12:36 pm
by Sparx
Just in the load function.
Sparx wrote:If i use the code as is, the file is not edited. If I use a subdirectory the game closes imidiately.

Re: File System Problem, Cant write save game.

Posted: Fri Jul 10, 2009 1:06 pm
by Robin
Now I placed it in load(). If I run "love .", it segfaults, but when I run "love ../Sparx" it works.

EDIT: for subdirectories, löve does indeed crash. This only happens when the subdirectory does not exist. love.filesystem.mkdir() seems do do nothing at all.

EDIT2: in tracker and fixed in SVN, see: http://love2d.org/forum/tracker.php?p=1&t=21

Re: File System Problem, Cant write save game.

Posted: Fri Jul 10, 2009 1:31 pm
by bartbes
That's what I wanted to know, your command line, running "love ." fails, because it thinks your game is called ., and security protects it from creating ~/.love/.