About Store Forum Documentation Contact



Post Reply 
.xml into .pak
Author Message
Eric Offline
Member

Post: #1
.xml into .pak
As in subject, how can I add a .xml file into .pak since PakFileData supports only File not FileText and .xml can be saved into FileText only?

Regards,
Eric 'Eri' Przychocki
ourgames.eu
02-11-2014 05:39 PM
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #2
RE: .xml into .pak
Ok. What I've done for now is:
1. Created normal XmlData with XmlNodes
2. Saved XmlData to FileText memory with:
Code:
FileText file_text;
file_text.writeMem();
xml.save(file_text);
3. Buffered FileText to CPtr since FileText File is private with:
Code:
CPtr buffer = AllocZero(file_text.size());
file_text.readMem(buffer, file_text.size());
4. Created PakFileData for PakCreate() with:
Code:
Memb<PakFileData> files;
PakFileData &pfd=files.New();
pfd.name=p.x+" "+p.y+".profile";
pfd.file.writeMem();
pfd.file.put(buffer, file_text.size());
pfd.modify_time_utc.getUTC();
5. Freed the buffer of course wink
6. Created .pak file with PakCreate() method with Memb files and Secure object reference.

It worked. The pfd.file exemple size is 248.

Now it's time to load the data (xml). And here's the problem! In FREPA loop with the searched files I'm trying to load them with:
Code:
static C PakFile &fp = Program::players[i].pak.file(0);
static FileText ft;
if(ft.read(fp.name, Program::players[i].pak))
{
    static XmlData xml;
    if(xml.load(ft))
    {
     ...
and the xml.load() method returns FALSE! When I check the size of 'fp' it returns 248. The size of 'ft' is also 248 but when i try to getAll() (with Log(...); ) from it it returns nothing..

What's the problem?!

Regards,
Eric 'Eri' Przychocki
ourgames.eu
(This post was last modified: 02-12-2014 08:29 PM by Eric.)
02-12-2014 08:24 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #3
RE: .xml into .pak
Do you want to add an existing "xml" file from the disk to your project?
You can do this by drag and dropping the file to the project region
http://www.esenthel.com/?id=doc#Importing_Assets

If not, then please explain more your situation, why do you want to do this?

Thanks
02-13-2014 11:59 PM
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #4
RE: .xml into .pak
Here's what I want to do: I wan't to create in memory (without saving it on a disk) a xml file (*.profile) with informations about player's profile (eg. "nick", "score"). It needs to be in xml because of complexity of stored data, so I cannot use binary file format. Then I need to add (in memory) the xml (*.profile) file into Secured .pak (*.player) file and then save the .pak file on a disk. I did this but when I try to load saved .xml file the xml.load() method returns false.

Regards,
Eric 'Eri' Przychocki
ourgames.eu
(This post was last modified: 02-14-2014 10:26 AM by Eric.)
02-14-2014 10:25 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: .xml into .pak
file_text.readMem(buffer, file_text.size()); <- this reads from the memory and not writes to it

Next release will have this new FileText method:
Bool copy (File &dest, Bool flush=true); // copy the entire contents (from start to end) of this FileText into 'dest' file including byte order mark (BOM) if present, 'flush'=if flush the 'dest' file at the end of the copy and verify that it has succeeded, false on fail
02-14-2014 10:36 PM
Find all posts by this user Quote this message in a reply
Eric Offline
Member

Post: #6
RE: .xml into .pak
Thank you! Waiting for next release.

Regards,
Eric 'Eri' Przychocki
ourgames.eu
02-15-2014 12:57 PM
Find all posts by this user Quote this message in a reply
Post Reply