AeFile.h 1.57 KB
#ifndef _AE_FileMgr_h
#define _AE_FileMgr_h


#include "AeErr.h"
#include "AeAsset.h"


template<class T> class GList;
class AeAsset;
class AeAssetBase;


class AeFile
{
  public:

                        AeFile (const char *);
    virtual	       	~AeFile (void);
   
    char *		GetFullName (void) { return fFullName; }
    char *		GetFileName (void) { return fFileName; }
    char *		GetDirName (void)  { return fDirName; }

    void		SetFullName (const char *);
    void		SwapTmpFile (const char *);

    // these routines make useful strings.  caller must deallocate memory.
    char *		MakeBackupName (void);
    char *		MakeFilePrefix (void);
    char *		MakeRelativePath (char * path);

    virtual void       	ReportError (AeErr err);

  protected:
    void		newNames (const char *);
    void		deleteNames (void);

    AeErr		copy (const char * from, const char * to);

    AeErr   	       	getFileData (char * fname, char *& fData, int & fSize);

    static void		parseFileString (const char *, char *& dir,
					 char *& file, char *& suffix);

    char *		fFullName;
    char *		fDirName;
    char *       	fFileName;

#ifndef NDEBUG
  public:
    static Boolean     	Test (void);
#endif
};


class AeAssetFile : public AeFile
{
  public:
    static AeAssetFile * NewAssetFile (char *);

                        AeAssetFile (char *); 
    virtual	       	~AeAssetFile (void);
   
    virtual AeErr      	Read (AeAsset *&);
    virtual AeErr	ReadList (GList<AeAsset *> *&);

    virtual AeErr	Write (AeAssetBase *);

protected:
    static TAssetType  	suffix2type (char *);
    
};


#endif