/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: include/sgx/filesystem/filesys.hpp

*/

#ifndef SGX_FILESYSTEM_FILESYS_HPP
#define SGX_FILESYSTEM_FILESYS_HPP	1

class CSGXFileSystem
{
    public:
        CSGXFileEntry * makeNewFileEntry(const sgxString &path);

        tBOOL           exists(const sgxString &path) const;
        tBOOL           isFile(const sgxString &path) const;
        tBOOL           isFolder(const sgxString &path) const;		
		sgxString 		getNativePath(const sgxString &path) const;
        CSGXFileEntry * getFileEntry(const sgxString &path) const;
        CSGXFileEntry * getChildEntry(CSGXFileEntry *pCurr, const sgxString &filename) const;
        CSGXFileEntry * createFileEntry(const sgxString &parent, const sgxString &name);
		CSGXFileEntry *	createFileEntry(CSGXFileEntry *pParent, const sgxString &name);
        tBOOL           getParent(sgxString &parent, const sgxString &location) const;
        void            getFullPath(sgxString &fullpath, const sgxString &path) const;
        void            getBaseName(sgxString &basename, const sgxString &path) const;
        tBOOL           mountDirectory(CSGXDevice *pDevice, const sgxString &location, tBOOL recursive=FALSE);
        tDISC_SIZE      getFileSize(const sgxString &path) const;

		tBOOL			copyFile(CSGXFile &outfile, const sgxString &srcFile);
		tBOOL			copyFile(const sgxString &destFile, const sgxString &srcFile);

        CSGXFileEntry * addNewFile(const CSGXFileSysData &FileData);

        CSGXFileEntry * createNewDirectory(const sgxString &PathName, const tBOOL bCreateParents=FALSE);
		CSGXFileEntry * createNewFile(const sgxString &fileName);

		void			recurse(CSGXFileEntry *pCurrRoot, CSGXCallback *pCallback);

        void            showHeirarchy(CSGXFileEntry *pCurr, tMEM_SIZE iDepth);
        void            showHeirarchy();
		
		virtual CSGXDevice *	createDevice(const sgxString &path, const sgxString &access="rw");

        static	CSGXFileSystem * get();

    protected:	// Can not use private, as it prevents derivation
        CSGXFileSystem();
        virtual ~CSGXFileSystem();

        static CSGXFileSystem      *sm_pSingleton;

        CSGXFileEntry              *m_pRoot;
        sgxString                  m_CurrentPath;

};

#endif /* SGX_FILESYSTEM_FILESYS_HPP */
