[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PFile update



I did some debugging on PFile and uploaded the results. Here's the changes:


* URLInfo::ProcessPath () didn't satisfy the (*TmpPath == '\0') condition
for normal paths. Fixed.

* FileGlobalData::FileGlobalData () generated a new GenericDir whilt
name="", namelen=0, conflichting with the (NameLen != 0) assertion in
Directory::Directory(). Fixed by renaming the toplevel dir to "/"
(namelen=1). That name isn't queried anyway.

* Directory::GetFile () and Directory::GetDir () just dereferenced the
pointer returned by GetEntry(), which can be 0. Fixed.

* Directory::GetDir () doesn't properly handle dir entries "." (current
dir) and ".." (parent dir). Fixed by adding checks in GetDir () - This
should be changed to adding these two entries to the dir hash at
initialization (?)

* PakFile::Open () didn't create the Pak when neccessary (ppfCreatePak ()
use). Fixed.

* PakFile::CreateHeader () automatically closed the Pak and when Close ()
was called again by ~PakFile () it couldn't handle that. Fixed.


With that, ppfOpen (), ppfRead () and ppfClose () work for normal files and
ppfCreatePak () also works (but produces a partly junky Pak because
PakMWriteLEInt64 () isn't properly implemented yet).
Attached is the tiny test program I used (the paths used in it are
intentionally weird to test the URL code).


	Christian

-- 

Drive A: not responding...Formatting C: instead
#include <PenguinPlay/PenguinPlay.h>
#include <PenguinPlay/PenguinFile.h>

#include <iostream>

int main (void)
{
	char Buffer [8192] = {0};

	cerr << "Hello World" << endl;

	ppFILE *TheFile = ppfOpen ("./testfile", "rb");
	if (TheFile == 0)
	{
		cerr << "Error while opening" << endl;
		return -1;
	}

	if (ppfRead (Buffer+1, 1, 4, TheFile) != 4)
	{
		cerr << "Error reading file data" << endl;
		return -2;
	}

	printf ("%02X %02X %02X %02X %02X %02X\n", Buffer [0], Buffer [1], Buffer [2], Buffer [3], Buffer [4], Buffer [5]);

	ppfClose (TheFile);

	if (ppfCreatePak ("./PenguinFile/../TestPak.cheese",
			  0,
			  "Pizza Lord",
			  "This is a way too long VendorID, you know. The limit is 32 characters and we deliberately exceed it for testing",
			  1,
			  32))
	{
		cerr << "Unable to create Pak File" << endl;
		return -3;
	}



	return 0;
}