00001 /* 00002 ** ClanLib SDK 00003 ** Copyright (c) 1997-2011 The ClanLib Team 00004 ** 00005 ** This software is provided 'as-is', without any express or implied 00006 ** warranty. In no event will the authors be held liable for any damages 00007 ** arising from the use of this software. 00008 ** 00009 ** Permission is granted to anyone to use this software for any purpose, 00010 ** including commercial applications, and to alter it and redistribute it 00011 ** freely, subject to the following restrictions: 00012 ** 00013 ** 1. The origin of this software must not be misrepresented; you must not 00014 ** claim that you wrote the original software. If you use this software 00015 ** in a product, an acknowledgment in the product documentation would be 00016 ** appreciated but is not required. 00017 ** 2. Altered source versions must be plainly marked as such, and must not be 00018 ** misrepresented as being the original software. 00019 ** 3. This notice may not be removed or altered from any source distribution. 00020 ** 00021 ** Note: Some of the libraries ClanLib may link to may have additional 00022 ** requirements or restrictions. 00023 ** 00024 ** File Author(s): 00025 ** 00026 ** Magnus Norddahl 00027 ** Harry Storbacka 00028 */ 00029 00032 00033 #pragma once 00034 00035 #include "../api_core.h" 00036 #include "../System/sharedptr.h" 00037 #include "file.h" 00038 class CL_IODevice; 00039 class CL_VirtualDirectory; 00040 class CL_VirtualFileSystem_Impl; 00041 class CL_VirtualFileSource; 00042 class CL_VirtualDirectoryListing; 00043 00047 class CL_API_CORE CL_VirtualFileSystem 00048 { 00051 00052 public: 00054 CL_VirtualFileSystem(); 00055 00059 CL_VirtualFileSystem(CL_VirtualFileSource *provider); 00060 00065 CL_VirtualFileSystem(const CL_String &path, bool is_zip_file = false); 00066 00067 ~CL_VirtualFileSystem(); 00068 00072 00073 public: 00075 bool is_null() const { return !impl; } 00076 00078 CL_VirtualDirectory get_root_directory(); 00079 00081 bool is_mount(const CL_String &mount_point); 00082 00084 CL_VirtualDirectoryListing get_directory_listing(const CL_String &path_rel); 00085 00087 bool has_file(const CL_String &filename); 00088 00090 bool has_directory(const CL_String &directory); 00091 00093 CL_VirtualFileSource *get_provider(); 00094 00096 CL_String get_path() const; 00097 00102 CL_String get_identifier() const; 00103 00107 00108 public: 00110 CL_VirtualDirectory open_directory(const CL_String &path); 00111 00113 00118 CL_IODevice open_file(const CL_String &filename, 00119 CL_File::OpenMode mode = CL_File::open_existing, 00120 unsigned int access = CL_File::access_read | CL_File::access_write, 00121 unsigned int share = CL_File::share_all, 00122 unsigned int flags = 0) const; 00123 00125 00133 void mount(const CL_String &mount_point, CL_VirtualFileSystem fs); 00134 00136 00141 void mount(const CL_String &mount_point, const CL_String &path, bool is_zip_file); 00142 00144 00145 void unmount(const CL_String &mount_point); 00146 00150 00151 private: 00153 class CL_NullVFS { }; 00154 explicit CL_VirtualFileSystem(class CL_NullVFS null_fs); 00155 00156 CL_SharedPtr<CL_VirtualFileSystem_Impl> impl; 00157 00158 friend class CL_VirtualDirectory_Impl; 00160 }; 00161