Windows File saving / loading issue

Simon Gust

Member
Hello,
I have run into a problem concerning file loading using
get_save_filename and get_open_filename.

I want to save a buffer using the file type .map
but it doesn't really work. I get the error
Cannot load buffer file
If I use buffer load ext to load the buffer I get
Error! not allowing save with filename ''
upload_2017-9-17_14-13-15.png
actual representation of the symbols.
which is very confusing for me. I know these functions aren't sandboxed and I have tried
using a .txt file type to save, but I get the same results.

buffer saving
Code:
// get file name
fileName = get_save_filename("maps|*.map", "");

// create buffer
fileBuffer = buffer_create(12, buffer_fixed, 4);
buffer_write(fileBuffer, buffer_u32, numLayer);
buffer_write(fileBuffer, buffer_u32, layerWidth);
buffer_write(fileBuffer, buffer_u32, layerHeight);

// save data
buffer_save(fileBuffer, fileName);
buffer loading
Code:
// get file name
fileName = get_open_filename("maps|*.map", "");

// load data
fileBuffer = buffer_load(fileName);
/*
or
fileBuffer = buffer_create(12, buffer_fixed, 4);
buffer_load_ext(fileBuffer, fileName, 0);
*/
numLayer = buffer_read(fileBuffer, buffer_u32);
layerWidth = buffer_read(fileBuffer, buffer_u32);
layerHeight = buffer_read(fileBuffer, buffer_u32);

// free buffer
buffer_delete(fileBuffer);
 
B

brokenjava

Guest
have you verified what the fileName is before trying to "save" it?

maybe you need to seek to the start before your writes?
 

Simon Gust

Member
have you verified what the fileName is before trying to "save" it?

maybe you need to seek to the start before your writes?
I'm not sure what exactly you mean but I can type a name using get_save_filename().
Saving without the function and only loading the exact filename works (only in local folder of course).
 
B

brokenjava

Guest
maybe map is not a supported filter?
fileName = get_save_filename("maps|*.map", "");

check to see if the user hit cancel or has given a valid filename

Code:
//check to see what was returned
 show_debug_message(fileName);

if file != ""
   {
    //do stuff like write to file
}
 

Simon Gust

Member
maybe map is not a supported filter?
fileName = get_save_filename("maps|*.map", "");

check to see if the user hit cancel or has given a valid filename

Code:
//check to see what was returned
 show_debug_message(fileName);

if file != ""
   {
    //do stuff like write to file
}
I do check for a file != "" since yesterday.
Trying with a .txt type doesn't work either (which I've already tried before).
Normal buffer saving likes .map though which is weird to me, why it wouldn't work this way.
 
Top