0 votes

What should I place in *p_dst if all I have is the p_length?

uint64_t FileAccess::get_buffer(uint8_t *p_dst, uint64_t p_length) 
Godot version 3.5 beta custom build (working on a module in c++)
in Engine by (198 points)

1 Answer

0 votes

p_dst is a pointer to the buffer in which the data in the file is to be stored as bytes. Create an empty buffer of length p_length and pass it to the function.

by (1,305 points)

I see I think I get it but I'm no sure. I'm trying to replace this series of statements that were written for a GDNative plugin. GDNative plugins have access to File::get_buffer which only requires a p_length. Here is the original code:

/* Read and populate the data */
PoolByteArray arr = p->file->get_buffer(len);
PoolByteArray::Read r = arr.read();
memcpy(zBuf, r.ptr(), len);

Here is what I did, but I'm pretty sure it's wrong:

 /* Read and populate the data */
PoolVector<uint8_t> arr;
PoolVector<uint8_t>::Write arr_w = arr.write();
p->file->get_buffer(arr_w.ptr(), len);
PoolByteArray::Read r = arr.read();
memcpy(zBuf, r.ptr(), iAmt);

What do you think?

Aaaaactually there seems to be _File class in core_bind.h, which I think is the class that is exposed to GDNative and GDscriptright?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.