File System Problem, Cant write save game.

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
whitebear
Citizen
Posts: 86
Joined: Sun Mar 15, 2009 1:50 am

Re: File System Problem, Cant write save game.

Post 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.
User avatar
Flesh Gregor
Prole
Posts: 9
Joined: Thu May 07, 2009 9:30 pm

Re: File System Problem, Cant write save game.

Post 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.
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: File System Problem, Cant write save game.

Post 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 =)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: File System Problem, Cant write save game.

Post 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?
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: File System Problem, Cant write save game.

Post 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 =)
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: File System Problem, Cant write save game.

Post by Robin »

That's weird... I copy/pasted it, and it worked right away for me.
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: File System Problem, Cant write save game.

Post by bartbes »

How do you run that code?
User avatar
Sparx
Party member
Posts: 125
Joined: Thu Apr 02, 2009 9:54 am
Location: Aachen, Germany

Re: File System Problem, Cant write save game.

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: File System Problem, Cant write save game.

Post 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
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: File System Problem, Cant write save game.

Post 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/.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests