ENIGMA Forums
Contributing to ENIGMA => Proposals => Topic started by: Darkstar2 on June 26, 2014, 04:39:09 pm
-
Now I now this is same behaviour for another known game development software....... but how about making it actually different in ENIGMA, or adding some new file handling ?
writing or reading binary @ 10MB/20MB is slow when today,s hardware can handle 100MB-200MB+++.
IS there a way to implement more optimised faster file I/O in ENIGMA this is one area we don't need to match GMStudio.
-
You can always just use the C++ functions, you know. Aside from that, the functions are slow because you are only buffering tiny chunks of data at a time, and you're casting it to STL strings. I believe Robert wrote buffer functions; do those not work with files? If not, consider using the C functions or writing wrappers around them (they're extremely simple).
FILE *f = fopen("yourfile.bin", "rb");
char buf[512];
while (!feof(f)) { // Until at end of file
size_t read = fread(buf, 1, 512, f); // Read at most 512 bytes
// process bytes here; `read` bytes were read in total
}
fclose(f);
I suppose you'll want the existing convenience functions which do things like read integers for you. In that case, I'd recommend just adding a file_bin_read_buffer() that does what the above does for large chunks.
In the future, we will likely offer memory mapping functions for that.
-
Thanks Josh I was aware of this, these are from the stdio, but didn't know I could integrate these kind of C++ codes into my projects. :D
-
Darkstar2, ENIGMA's current compiler only has problems parsing STL, which is vectors, maps, queue's, and other templates.
Josh, the buffer functions are for networking and have to assume endianess, they are not good for simple read/write operations, and they are also shit. I haven't gotten floats working yet either.