About Store Forum Documentation Contact



Post Reply 
File memory copy
Author Message
Eric Offline
Member

Post: #1
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
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #2
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
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #3
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 smile

P.S. Nice! I'm Old License Owner pfft
04-13-2014 07:22 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #4
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 pfft
you can upgrade your recent 2.0 purchase to binary subscription for free
04-13-2014 08:58 AM
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #5
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 LicensEE" wink
(This post was last modified: 04-13-2014 10:19 AM by Eric.)
04-13-2014 10:02 AM
Find all posts by this user Quote this message in a reply
Post Reply