#write u8 array to file

1 messages ยท Page 1 of 1 (latest)

calm fable
#

I have the same issue as [here](#1239248126167093309 message), but then the other way around. If I pass a u8[] directly to std::file::write, I get an error about passing an argument of type '???'. Using the converter the other way around, no data is being written to the files.

Discord

Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

lucid sedge
#

Passing arrays around to functions is kinda iffy sadly

#

It should work if you wrap the array in a struct and give it that

calm fable
#
struct ArrayHolder<auto size>
{
    u8 data[size];
};

ArrayHolder<current.compressedSize> holder;
holder.data = fileData;
std::file::write(writeFileHandle, holder);

gives the same error as passing an array

wraith osprey
#

std::file::write only accepts strings afaik

#

however the docs say:

data: String or Pattern to write to the file
#

so it may be a bug

calm fable
wraith osprey
#

maybe a union of u8 and char to create a char array which is internally converted to a string.

#

there's also std::mem::Reinterpreter

wraith osprey
#

reinterpreter is

 union Reinterpreter<From, To> {
        From from;
        To to;
    };