- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# FUtils/FUFileManager.h

    00001 /*
    00002     Copyright (C) 2005-2007 Feeling Software Inc.
    00003     Portions of the code are:
    00004     Copyright (C) 2005-2007 Sony Computer Entertainment America
    00005
    00006     MIT License: http://www.opensource.org/licenses/mit-license.php
    00007 */
    00008 /*
    00009     Based on the FS Import classes:
    00010     Copyright (C) 2005-2006 Feeling Software Inc
    00011     Copyright (C) 2005-2006 Autodesk Media Entertainment
    00012     MIT License: http://www.opensource.org/licenses/mit-license.php
    00013 */
    00014
    00015 #ifndef _FU_FILE_MANAGER_H_
    00016 #define _FU_FILE_MANAGER_H_
    00017
    00018 #ifndef _FU_URI_H_
    00019 #include "FUtils/FUUri.h"
    00020 #endif //_FU_URI_H_
    00021
    00022 #ifndef _FM_ARRAY_H_
    00023 #include "FMath/FMArray.h"
    00024 #endif //_FM_ARRAY_H_
    00025
    00026 class FUFile;
    00027
    00031 typedef IFunctor1<const FUUri&, fstring> SchemeLoadCallback;
    00032
    00036 typedef IFunctor1<const FUUri&, bool> SchemeExistsCallback;
    00037
    00043 typedef IFunctor2<const fstring&, fstring&, bool>   SchemePreProcessCallback;
    00044
    00047 typedef IFunctor2<const fstring&, size_t, void> SchemeOnCompleteCallback;
    00048
    00052 typedef IFunctor3<const FUUri&, SchemeOnCompleteCallback*, size_t, void> SchemeRequestFileCallback;
    00053
    00058 struct FCOLLADA_EXPORT SchemeCallbacks
    00059 {
    00060     SchemeLoadCallback* load;
    00061     SchemeExistsCallback* exists;
    00062     fm::vector<SchemePreProcessCallback*> openers;
    00063     SchemeRequestFileCallback* request;
    00064
    00066     SchemeCallbacks();
    00068     SchemeCallbacks(const SchemeCallbacks& copy);
    00070     ~SchemeCallbacks();
    00071 };
    00072
    00075 FCOLLADA_EXPORT SchemeCallbacks* NewSchemeCallbacks();
    00076
    00080 class FCOLLADA_EXPORT FUFileManager
    00081 {
    00082 private:
    00083     typedef fm::map<FUUri::Scheme, SchemeCallbacks*> SchemeCallbackMap;
    00084
    00085     FUUriList pathStack;
    00086     bool forceAbsolute;
    00087
    00088     SchemeCallbackMap schemeCallbackMap;
    00089 public:
    00093     FUFileManager();
    00094
    00096     ~FUFileManager();
    00097
    00101     inline const FUUri& GetCurrentUri() const { return pathStack.back(); }
    00102
    00107     void PushRootPath(const fstring& path);
    00108
    00113     void PushRootFile(const fstring& filename);
    00114
    00116     void PopRootPath();
    00117     void PopRootFile();
    00125     FUFile* OpenFile(const fstring& filename, bool write=false, SchemeOnCompleteCallback* onComplete=NULL, size_t userData = 0);
    00126
    00132     static bool MakeDirectory(const fstring& directory);
    00133
    00137     bool FileExists(const fstring& filename);
    00138
    00142     static fstring StripFileFromPath(const fstring& filename);
    00143
    00147     static fstring GetFileExtension(const fstring& filename);
    00148
    00152     static fstring ExtractNetworkHostname(fstring& filename);
    00153
    00157     void SetForceAbsoluteFlag(bool _forceAbsolute) { forceAbsolute = _forceAbsolute; }
    00158
    00162     fstring CleanUri(const FUUri& uri);
    00163
    00166     static fstring GetApplicationFolderName();
    00167
    00170     static fstring GetModuleFolderName();
    00171
    00177     static void GetFolderFromPath(const fstring& folder, fstring& path);
    00178
    00185     void SetSchemeCallbacks(FUUri::Scheme scheme, SchemeCallbacks* callbacks);
    00186
    00190     void RemoveSchemeCallbacks(FUUri::Scheme scheme);
    00191
    00193     void RemoveAllSchemeCallbacks();
    00194
    00197     void CloneSchemeCallbacks(const FUFileManager* srcFileManager);
    00198 };
    00199
    00200 #endif // _FU_FILE_MANAGER_H_
    00201