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

Re: Looking for Asylum



Jorrit Tyberghein wrote:

>> Well, there's an implementation of a customized archive format, designed
>> for speed (e.g. using a hashtable for dir entries) & holding some
[...]

>> Of course this is only really interesting for you if you want to use the
>> VFS system not only internally, but also provide it as a service to the
>> user.
>
>Well we do. VFS is for both in and outside the engine.

Good.

>> PS: Just that you understand me correctly - I don't mind ripping PFile to
>> pieces for this if neccessary (I hope it isn't, though). I surely don't
>> want to say "well, here it is, now let's use that instead of what you have".
>>
>
>Well the thing is that I'm not sure what exactly this involves. I never
>looked at PFile before so I don't know how it is structured. CS places some
>very strict rules on the code inside. i.e. we use an SCF plugin system (VFS is a
>plugin). How easy would it be to fit PFile to that?

The SCF stuff only affects the VFS interface, not its internal code, right?
Well, The only things of PFile exported to public space are (1) the
(procedural) API functions and (2) some structs and typedefs supporting
them. I don't know anything about SCF, so I don't know how it handles
procedural stuff, but we can also move all this stuff into classes more or
less by cutting-and-pasting. Or add some OO API.
The key point here is that the API is only a very thin layer over the
internals, so changing it is very easy.

>I can see the advantages of those extra features you mention but I'm not sure
>what work this involves.
>
>Another issue is that at this moment I'm a bit scared of big rewrites like this.
>I'm working towards another stable release (0.16) in the short term and towards
>the full 1.0 release in a few months (i.e. three to four months I hope). This
>will certainly have to wait until after 0.16.

Ok, I can understand that ;)
It's fine with me, as it gives me some time to (1) care about some of the
more urgent shortcomings of the LGDC site code and (2) get familiar with
your system.

>But can you tell me more about PFile? Maybe a header file or something?

Attached is PenguinFile.h (PFile's only public header apart from
PenguinPlay.h).  

At http://sunsite.auc.dk/penguinplay/libpplay/ there are links to the docs,
both online readable and downloadable tarballs in various formats.

You can access the source files via anoncvs:

CVSROOT: ":pserver:cvs@sunsite.auc.dk:/pack/anoncvs"
Password: "cvs"

You can also browse the repository via the web: http://sunsite.auc.dk/cgi-bin/ppcvsweb 

Or get a "demo release" tarball from
ftp://sunsite.auc.dk/pub/os/linux/penguinplay/

The PFile sources are in src/PenguinFile/
In that dir are also some small doc files (FILES, TODO).

>What about the other modules in PenguinPlay? What's the status of them?

There's only one - PenguinSound. I don't know whether Peter (its author) is
also interested in joining CSpace or prefers to do something else - Peter?


	Christian
-- 
Christian Reiniger
Coordinator/Coder, PenguinPlay (http://sunsite.auc.dk/penguinplay/)
Coordinator,       LGDC        (http://sunsite.auc.dk/lgdc/)

Install once, run forever. Linux.
/** \file PenguinFile.h
 * C API of the PenguinPlay File Access system
 * Part of the PenguinPlay File handling system
 *
 * \author Christian Reiniger <warewolf@mayn.de>
 *
 * License: See the accompanying file LICENSE
 *
 * Last change by $Author: creinig $
 * on             $Date: 2000/02/10 21:33:25 $
 * to             $Revision: 1.9 $
 *
 */

/**
    \defgroup PenguinFile
    \brief    PenguinPlay File Access System.
    \author   Christian Reiniger
*/


#ifndef _PENGUINFILE_H
#define _PENGUINFILE_H 1

#include <PenguinPlay/PenguinPlay.h>

#ifdef PP_CPLUSPLUS
#  include <cstdio>
#  include <cerrno>
#else
#  include <stdio.h>
#  include <errno.h>
#endif


//struct DIR; /* for ppfDirEntry::PosixDir */


/*
 * Some Maximum values -------------------------------------------------------
 */


#define PPF_MAX_FILENAME_LENGTH  255  /* max. length of filenames (w/o '\0') */

#define PPF_MAX_URL_FS_LENGTH     32  /* max. length of fstype specifiers
                                         (w/o '\0') */

#define PPF_MAX_MOUNT_COUNT       64  /* max number of file systems that can
                                         be mounted at the same time */

#define PPF_MAX_PATH_DEPTH        32  /* max. number of elements in a path */




#ifdef PP_CPLUSPLUS
extern "C"
{
#endif



typedef enum
{
	ppfFS_undefined = 0,
	ppfFS_plain,
	ppfFS_pak,
	ppfFS_file,
	ppfFS_virt,
	ppfFS_ftp,      /* not supported yet */
	ppfFS_http,     /* not supported yet */
	ppfFS_numvals   /* how many FSTypes do we know? */
} ppfFSType;



typedef enum
{
	ppfFT_undefined = 0,
	ppfFT_file,
	ppfFT_directory,
	ppfFT_symlink        /* not supported yet */
} ppfFileType;



/* To change without notice. Do *NOT* use numeric values directly. */
typedef enum
{
	ppfFA_none         =  0,
	ppfFA_compressed   =  1,
	ppfFA_encrypted    =  2,
	ppfFA_readable     =  4,
	ppfFA_writeable    =  8,
	ppfFA_executable   = 16,
	ppfFA_searchable   = 16, /* equiv. of "executable" for directories */
	ppfFA_construction = 32  /* for PakFiles being constructed. Means
	                          * that only files/dirs of matching type
				  * may be added, and only via ppfCopy ()
				  * FIX: obsolete*/
} ppfFileAttrib;




typedef enum
{
	ppfMF_none             =  0,
	ppfMF_write            =  1,
	ppfMF_override_files   =  2,
	ppfMF_override_dirs    =  4,
	ppfMF_override_radical =  8,
	ppfMF_force            = 16
} ppfMountFlags;


/* Collection of flags to be used for a great range of functions
 * (right now only ppfCopy () uses them) */
typedef enum
{
	ppfGF_none                 = 0,
	ppfGF_recursive            = 1,
	ppfGF_follow_links         = 2,
	ppfGF_continue_on_problems = 4,
	ppfGF_overwrite            = 8
} ppfGenericFlags;




/* Our custom file handle structure. Do *not* access any internals of it, as
 * they will change for sure - without notice
 *
 * For FS == ppfFS_plain only "Handle" and "LastErr" (and evtl. "Attribs") are
 *                       evaluated
 * For the other cases "Handle" is ignored */
struct ppf_FILE
{
	ppfFSType  FS;      /* What kind of file is it? */
	FILE      *Handle;  /* stdio filehandle of the file itself.
	                       0 for file in virt */
	ppSizeT    Size;    /* its size in bytes */
	ppOffsetT  RPos;    /* reading pos (currently RPos == WPos) */
	ppOffsetT  WPos;    /* writing pos (currently RPos == WPos) */
	pp32       Attribs; /* access flags, subset of ppfFileAttrib */
	int        LastErr; /* Code of last error (-> errno) */
	void      *FileO;   /* Pointer to the respective File object.
	                       Has to be void because we cannot
			       use pointers to classes in a C header */
	struct ppf_FILE *Next; /* Next ppfFILE structure pointing to the
                                * same file in VFS */
};
typedef struct ppf_FILE ppfFILE;




/* All fields in this struct can be used directly (in fact, you *should* do
 * exactly that ;) */
typedef struct
{
	const char  *Name;       /* length <= PP_MAX_FILENAME_LENGTH */
	ppTimeT      CTime;      /* Creation Time */
	ppTimeT      MTime;      /* Modification Time */
	pp32         Attribs;    /* Attributes. Use ppfFileAttrib to
	                          * evaluate */
	ppSizeT      Size;       /* File size */
	ppfFileType  Type;       /* what kind of file is it? */
	ppfFSType    FS;         /* in what kind of file system is it? */
	int          NameIsCopy; /* !0 if Name has to be deallocated again,
                                  * 0 otherwise. For internal use */
} ppfDirEntry;




/* for internal use only */
typedef struct
{
	/* Where is the dir? */
        ppfFSType    FS;

        /* Number of current Entry (for ppfSeekDir etc) */
	ppOffsetT    EntryNo;

	/* Dirname & Path (for stat() calls in ReadDirPlain ())
	 * Set to 0 for operations in virt */
	char        *BasePath;

	/* The struct returned by ReadDir() */
        ppfDirEntry *Entry;

	/* Pointer to the proper DirectoryEntryIterator. It has to be
	 * (void *) because we cannot use pointers to C++ objects in a
	 * C header */
	void        *Iterator;

	/* POSIX DIR structure for "normal" dirs
	 * Declared as void so that we don't have to include POSIX headers
	 * at this level */
	void        *PosixDir;
} ppfDIR;











/*
 * The Procedural API. This part is a 95% stdio clone, so everyone should be
 * familiar with it.
 */


PP_EXPORT ppfFILE  *ppfOpen     (const char *URL, const char *mode);
PP_EXPORT ppfFILE  *ppfReopen   (const char *URL, const char *mode, ppfFILE *stream);
PP_EXPORT int       ppfClose    (ppfFILE *stream);


PP_EXPORT int       ppfFlush    (ppfFILE *stream);
PP_EXPORT void      ppfSetBuf   (ppfFILE *stream, char *buf);
PP_EXPORT int       ppfSetVBuf  (ppfFILE *stream, char *buf, int mode, ppSizeT size);

/* ppfPrintF   */
/* ppfVFPrintF */
/* ppfScanF    */

PP_EXPORT int       ppfGetC     (       ppfFILE *stream);
PP_EXPORT int       ppfPutC     (int c, ppfFILE *stream);
PP_EXPORT int       ppfUngetC   (int c, ppfFILE *stream);
PP_EXPORT char     *ppfGetS     (      char *s, int n, ppfFILE *stream);
PP_EXPORT int       ppfPutS     (const char *s,        ppfFILE *stream);

PP_EXPORT ppSizeT   ppfRead     (      void *ptr, ppSizeT size, ppSizeT nobj, ppfFILE *stream);
PP_EXPORT ppSizeT   ppfWrite    (const void *ptr, ppSizeT size, ppSizeT nobj, ppfFILE *stream);

PP_EXPORT int       ppfSeek     (ppfFILE *stream, ppOffsetT offset, int origin);
PP_EXPORT ppOffsetT ppfTell     (ppfFILE *stream);
PP_EXPORT void      ppfRewind   (ppfFILE *stream);
PP_EXPORT int       ppfGetPos   (ppfFILE *stream,       ppOffsetT *ptr);
PP_EXPORT int       ppfSetPos   (ppfFILE *stream, const ppOffsetT *ptr);


PP_EXPORT void      ppfClearErr (ppfFILE *stream);
PP_EXPORT int       ppfEof      (ppfFILE *stream);
PP_EXPORT int       ppfError    (ppfFILE *stream);
PP_EXPORT void      ppfPError   (const char *s);



/* Directory reading. An almost complete clone of the POSIX directory API */

PP_EXPORT ppfDIR      *ppfOpenDir   (const char *URL);
PP_EXPORT int          ppfCloseDir  (ppfDIR *Dir);
PP_EXPORT ppfDirEntry *ppfReadDir   (ppfDIR *Dir);
PP_EXPORT void         ppfSeekDir   (ppfDIR *Dir, ppOffsetT offset);
PP_EXPORT ppOffsetT    ppfTellDir   (ppfDIR *Dir);
PP_EXPORT void         ppfRewindDir (ppfDIR *Dir);

/* These use the normal ppfDirEntry structure as "stat" replacement
 * (it's completely sufficient for this task) */
PP_EXPORT int          ppfStat      (const char *URL, ppfDirEntry *dire);
PP_EXPORT int          ppfLStat     (const char *URL, ppfDirEntry *dire);


/* Misc. other POSIX clone functions */

PP_EXPORT int          ppfChdir     (const char *Path);
PP_EXPORT int          ppfMkdir     (const char *URL, int Openmode);
PP_EXPORT int          ppfChmod     (const char *URL, int Mode);



/* PenguinFile specific stuff */

/* return 0 on success and != 0 on failure */
PP_EXPORT int          ppfMount     (const char *What, const char *Where, int Flags);
PP_EXPORT int          ppfUmount    (const char *URL, int Flags);
PP_EXPORT int          ppfCreatePak (const char *URL, int Format,
				     const char *GameID, const char *VendorID,
				     pp32 GameVerMajor, pp32 GameVerMinor);

/* Right now this is only a very primitive prototype.
 * Only one file can be copied. The "Flags" parameter is completely ignored.
 * "Src" has to be the URL of the source file.
 * "Dest" has to be the *qualified* (i.e. with fstype specifier) URL of the
 * target *file* (i.e. *not* the destination directory).
 * Only "plain" and "pak" are supported as destination filesystems.
 */
PP_EXPORT int          ppfCopy      (const char *Src, const char *Dest, int Flags);

#ifdef PP_CPLUSPLUS
}
#endif

#endif
---------------------------------------------------------------------
To unsubscribe, e-mail: penguinplay-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: penguinplay-help@sunsite.auc.dk