/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     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: sgx/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;
		sgxString 		getNativePath(const CSGXFile &file) 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;
        tBOOL           mountDirectory(const sgxString &location, tBOOL recursive=FALSE);
        tBOOL           mountDirectory(CSGXDevice *pDevice, const sgxString &location, tBOOL recursive=FALSE);
        tBOOL			umountDirectory(const sgxString &location);
		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);

		tBOOL			refreshFile(const sgxString &fileName);

		// Search paths
		CSGXFileEntry *	getSearchPathFileEntry(const sgxString &filename);
		tUINT32			getSearchPath(sgxVector<sgxString> &searchList) const;
		void			setSearchPath(const sgxVector<sgxString> &searchList);
		void			addSearchPath(const sgxString &nextPath);
		void			clearSearchPath();

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

        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;

		sgxVector<sgxString>		m_SearchPathList;
};

#endif /* SGX_FILESYSTEM_FILESYS_HPP */
