love.filesystem.mkdir not working

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

love.filesystem.mkdir not working

Post by bartbes »

Mostly @rude
When I try to save a binary file all goes well, strings are as long as they should be, but when I call love.filesystem.write it just stops at the first NULL character ("\0"). Something I can do to prevent this?

EDIT:
SWIG manual wrote: The char * datatype is handled as a NULL-terminated ASCII string. SWIG maps this into a 8-bit character string in the target scripting language. SWIG converts character strings in the target language to NULL terminated strings before passing them into C/C++. The default handling of these strings does not allow them to have embedded NULL bytes. Therefore, the char * datatype is not generally suitable for passing binary data. However, it is possible to change this behavior by defining a SWIG typemap. See the chapter on Typemaps for details about this.
EDIT2: I changed the topic title because I didn't feel it was necessary to start a new thread, first post at: http://love2d.org/forum/viewtopic.php?f ... 4436#p4436 (bottom of the page :P)
Last edited by bartbes on Sat Feb 14, 2009 1:25 pm, edited 2 times in total.
User avatar
Skofo
Party member
Posts: 146
Joined: Mon Dec 22, 2008 10:55 pm

Re: Binary files with love.filesystem

Post by Skofo »

Do you have any backslashes (\) in your strings? That usually does some weird things if you mean for it to show up as a backslash, because particular backslash and character combinations make special characters (i.e. \n makes a new line). If you want to input a backslash, type '\\' instead of just '\'.

Also, here's a list of other special backslash characters if you need them:
\a bell
\b back space
\f form feed
\n newline
\r carriage return
\t horizontal tab
\v vertical tab
\\ backslash
\" double quote
\' single quote
\[ left square bracket
\] right square bracket
Working on: Viator
Need a 64-bit Debian package for LÖVE? Here it is!
User avatar
Merkoth
Party member
Posts: 186
Joined: Mon Feb 04, 2008 11:43 pm
Location: Buenos Aires, Argentina

Re: Binary files with love.filesystem

Post by Merkoth »

Or just use Lua's file.io methods :)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Binary files with love.filesystem

Post by bartbes »

Skofo wrote:Do you have any backslashes (\) in your strings?
No, I come from C/C++ so I know that, but I didn't enter the string, it is read from another source (the mighty internet)
Merkoth wrote:Or just use Lua's file.io methods :)
That really isn't an option, I'll only use it if I really, really have to.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Binary files with love.filesystem

Post by bartbes »

Bump?
User avatar
rude
Administrator
Posts: 1052
Joined: Mon Feb 04, 2008 3:58 pm
Location: Oslo, Norway

Re: Binary files with love.filesystem

Post by rude »

Sorry, I'm not that agressive on the forums these days. (But your bump worked). There's probably nothing you can do about that at this point. I didn't know SWIG did that.

FYI, I checked up on this:
lua.org wrote: lua_tolstring returns a fully aligned pointer to a string inside the Lua state. This string always has a zero ('\0') after its last character (as in C), but can contain other zeros in its body. Because Lua has garbage collection, there is no guarantee that the pointer returned by lua_tolstring will be valid after the corresponding value is removed from the stack.
SWIG has been removed, so I guess this problem is already fixed (in SVN, that is). I'll add it to the "test me"-list. As for a temporary fix: stop needing binary data. :rofl:
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Binary files with love.filesystem

Post by bartbes »

Well.. this renders updater unusable... I'll wait though
User avatar
Skofo
Party member
Posts: 146
Joined: Mon Dec 22, 2008 10:55 pm

Re: Binary files with love.filesystem

Post by Skofo »

bartbes wrote:Well.. this renders updater unusable... I'll wait though
Oh man, I'm sorry braw. :(

I'll wait for it too.
Working on: Viator
Need a 64-bit Debian package for LÖVE? Here it is!
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Binary files with love.filesystem

Post by bartbes »

I guess I'll use io until it is fixed.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: love.filesystem.mkdir not working

Post by bartbes »

Again @rude
love.filesystem.mkdir doesn't work, and because I can't find an mkdir in standard Lua (I could swear I've used something like that), it'd be nice if I knew the correct syntax.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests