Eric
Member
|
File memory copy
Hello,
today I've discovered that it's impossible to copy content of one file created in memory to another file created in memory. Is that true or I've missed something?
|
|
04-12-2014 05:06 PM |
|
Esenthel
Administrator
|
RE: File memory copy
Hi,
Why not?
This should work.
Make sure to set position of the source to 0 before writing.
|
|
04-12-2014 09:43 PM |
|
Eric
Member
|
RE: File memory copy
here's my functions body:
Code:
// files needed to update .pak
Memc<PakFileData> files;
PakFileData &pfd=files.New();
// name
pfd.name=Program::path_records+_srd.title+L".record";
// date
pfd.modify_time_utc.getLocal();
// start writing to memory
pfd.file.writeMem();
// reset the source position to 0
if(!_file.pos(0))
{
if(error) *error=Program::sres_filesave_pos;
return false;
}
// copy from source file to pfd destination without flushing
if(!_file.copy(pfd.file, -1, false))
{
if(error) *error=Program::sres_filesave_copy;
return false;
}
// update .pak
Bool result=_set->getOwner()->_updatePak(error, files);
The result size of pfd file is 0
P.S. Nice! I'm Old License Owner
|
|
04-13-2014 07:22 AM |
|
Esenthel
Administrator
|
RE: File memory copy
Code:
void InitPre()
{
EE_INIT();
File a, b;
a.writeMem();
b.writeMem();
a.putStr("test");
a.pos(0);
a.copy(b);
b.pos(0);
Exit(b.getStr());
}
this works fine
Quote:P.S. Nice! I'm Old License Owner
you can upgrade your recent 2.0 purchase to binary subscription for free
|
|
04-13-2014 08:58 AM |
|
Eric
Member
|
RE: File memory copy
Ok, probably found the cause of my problem. Can this line be called on a second thread? It returns true. The _file is ready to writeMem() and SoundCapture is created. Checked also _half_size - it's fine.
Code:
if(!_file.put(SoundCapture.data(), _half_size))
P.S. I'll write to you PM to upgrade my license.
P.P.S. Just became "Binary Licens EE"
(This post was last modified: 04-13-2014 10:19 AM by Eric.)
|
|
04-13-2014 10:02 AM |
|