value lime_byte_array_read_file (value inFilename) { ByteArray result = ByteArray (val_os_string(inFilename)); return result.mValue; }
value lime_byte_array_overwrite_file (value inFilename, value inBytes) { // file is created if it doesn't exist, // if it exists, it is truncated to zero FILE_HANDLE *file = lime::fopen (val_os_string (inFilename), "wb"); if (!file) { #ifdef ANDROID // [todo] #endif return alloc_null(); } ByteArray array (inBytes); // The function fwrite() writes nitems objects, each size bytes long, to the // stream pointed to by stream, obtaining them from the location given by // ptr. // fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream); lime::fwrite (array.Bytes (), 1, array.Size (), file); lime::fclose (file); return alloc_null (); }
value snow_byte_array_read_file(value inFilename) { ByteArray result = ByteArray::FromFile(val_os_string(inFilename)); return result.mValue; } DEFINE_PRIM(snow_byte_array_read_file,1);
value snow_byte_array_overwrite_file(value inFilename, value inBytes) { ByteArray::ToFile(val_os_string(inFilename), ByteArray(inBytes)); return alloc_null(); } DEFINE_PRIM(snow_byte_array_overwrite_file, 2);
value lime_bytes_read_file (value path) { Bytes data = Bytes (val_os_string (path)); return data.Value (); }