void CL_ResourceManager::load(const CL_String &fullname, CL_VirtualDirectory directory) { CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_virtual); CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_virtual); CL_VirtualDirectory dir = directory.open_directory(path); load(dir.open_file(filename, CL_File::open_existing, CL_File::access_read, CL_File::share_read), dir); }
CL_ShaderObject CL_ShaderObject::load(CL_GraphicContext &gc, const CL_StringRef &resource_id, CL_ResourceManager *resources) { CL_Resource resource = resources->get_resource(resource_id); CL_String filename = resource.get_element().get_attribute("file"); CL_String type = resource.get_element().get_tag_name(); CL_ShaderType shader_type; if (type == "fragment-shader") shader_type = cl_shadertype_fragment; else if (type == "vertex-shader") shader_type = cl_shadertype_vertex; else throw CL_Exception("CL_ShaderObject: Unknown shader type: " + type); CL_VirtualDirectory directory = resources->get_directory(resource); CL_IODevice file = directory.open_file(filename, CL_File::open_existing, CL_File::access_read, CL_File::share_read); int size = file.get_size(); CL_String8 source(size, 0); file.read(&source[0], size); CL_ShaderObject shader_object(gc, shader_type, CL_StringHelp::local8_to_text(source)); if (resource.get_element().get_attribute("compile", "true") == "true") if(!shader_object.compile()) throw CL_Exception(cl_format("Unable to compiler shader program %1: %2", resource_id, shader_object.get_info_log())); return shader_object; }
CL_SoundProvider_Wave::CL_SoundProvider_Wave( const CL_String &fullname, bool stream) : impl(new CL_SoundProvider_Wave_Impl) { CL_String path = CL_PathHelp::get_fullpath(fullname, CL_PathHelp::path_type_file); CL_String filename = CL_PathHelp::get_filename(fullname, CL_PathHelp::path_type_file); CL_VirtualFileSystem vfs(path); CL_VirtualDirectory dir = vfs.get_root_directory(); CL_IODevice input = dir.open_file(filename, CL_File::open_existing, CL_File::access_read, CL_File::share_all); impl->load(input); }
CL_CollisionOutline::CL_CollisionOutline(const CL_StringRef &filename, const CL_VirtualDirectory &directory, int alpha_limit, CL_OutlineAccuracy accuracy, bool get_insides) { CL_String file_extension = CL_PathHelp::get_extension(filename); CL_IODevice file = directory.open_file_read(filename); *this = CL_CollisionOutline(file, file_extension, alpha_limit, accuracy, get_insides); }
void CL_PNGProvider::save( CL_PixelBuffer buffer, const CL_String &filename, CL_VirtualDirectory &directory) { CL_IODevice file = directory.open_file(filename, CL_File::create_always); save(buffer, file); }
void CL_CSSDocument_Impl::load(const CL_String &filename, const CL_VirtualDirectory &directory) { CL_String path = CL_PathHelp::get_fullpath(filename, CL_PathHelp::path_type_file); // Load document into a buffer: CL_IODevice input = directory.open_file_read(filename); int size = input.get_size(); if (size < 0) throw CL_Exception("IODevice does not support get_size()"); CL_DataBuffer data(size); int bytes_read = input.read(data.get_data(), data.get_size()); data.set_size(bytes_read); // Start parsing: unsigned char *data_ptr = (unsigned char *) data.get_data(); whitespace_comments(data_ptr, bytes_read); int pos = 0; while (pos < bytes_read) { unsigned char ch = data_ptr[pos]; switch (ch) { case ' ': case '\t': case '\r': case '\n': pos++; break; case '@': // import pos = load_import(data_ptr, pos, bytes_read, directory, path); break; default: // ruleset pos = load_ruleset(data_ptr, pos, bytes_read); break; } } }
void CL_GUIComponent::create_components(const CL_StringRef &filename, const CL_VirtualDirectory &dir) { CL_IODevice device; device = dir.open_file_read(filename); create_components(device); }
CL_ShaderObject CL_ShaderObject::load(CL_GraphicContext &gc, CL_ShaderType shader_type, const CL_StringRef &filename, const CL_VirtualDirectory &directory) { CL_IODevice file = directory.open_file_read(filename); return CL_ShaderObject::load(gc, shader_type, file); }
void CL_FontProvider_Freetype::load_font(const CL_FontDescription &desc, const CL_VirtualDirectory &directory) { CL_IODevice file = directory.open_file_read(desc.get_typeface_name()); load_font(desc, file); }
void CL_CollisionOutline::save(const CL_StringRef &filename, CL_VirtualDirectory &directory) const { CL_IODevice file = directory.open_file(filename, CL_File::create_always); impl->save(file); }
void CL_CollisionOutline::load(const CL_StringRef &filename, const CL_VirtualDirectory &directory) { CL_IODevice file = directory.open_file_read(filename); load(file); }
void CL_ResourceManager::save(const CL_String &filename, CL_VirtualDirectory directory) { save(directory.open_file(filename, CL_File::create_always, CL_File::access_read|CL_File::access_write, CL_File::share_read)); }
CL_OutlineProviderFile::CL_OutlineProviderFile(const CL_StringRef &filename, const CL_VirtualDirectory &directory) { CL_IODevice file = directory.open_file_read(filename); impl = CL_SharedPtr<CL_OutlineProviderFile_Generic> (new CL_OutlineProviderFile_Generic( file )); }