<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://cegui.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Loading_Resources_From_PhysFS</id>
		<title>Loading Resources From PhysFS - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://cegui.org/wiki/index.php?action=history&amp;feed=atom&amp;title=Loading_Resources_From_PhysFS"/>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Loading_Resources_From_PhysFS&amp;action=history"/>
		<updated>2026-04-17T13:37:28Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>http://cegui.org/wiki/index.php?title=Loading_Resources_From_PhysFS&amp;diff=4836&amp;oldid=prev</id>
		<title>Wansti: Created page with &quot;{{VersionBadge|0.7}} To load GUI resources via icculus' PhysFS [http://icculus.org/physfs] file system abstraction library, use the following ResourceProvider instead of the defa...&quot;</title>
		<link rel="alternate" type="text/html" href="http://cegui.org/wiki/index.php?title=Loading_Resources_From_PhysFS&amp;diff=4836&amp;oldid=prev"/>
				<updated>2012-08-24T12:49:25Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{VersionBadge|0.7}} To load GUI resources via icculus&amp;#039; PhysFS [http://icculus.org/physfs] file system abstraction library, use the following ResourceProvider instead of the defa...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{VersionBadge|0.7}}&lt;br /&gt;
To load GUI resources via icculus' PhysFS [http://icculus.org/physfs] file system abstraction library, use the following ResourceProvider instead of the default. This was tested with CEGUI 0.7.7 and works with Linux and Windows.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File CEGUIPhysFSResourceProvider.h:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/***********************************************************************&lt;br /&gt;
        filename:       CEGUIPhysFSResourceProvider.h&lt;br /&gt;
        created:        8/7/2004&lt;br /&gt;
        author:         James '_mental_' O'Sullivan&lt;br /&gt;
                        with minor changes by Marek 'Wansti' Moeckel&lt;br /&gt;
&lt;br /&gt;
        purpose:        Load GUI resources via PhysFS&lt;br /&gt;
*************************************************************************/&lt;br /&gt;
/***************************************************************************&lt;br /&gt;
 *   Copyright (C) 2004 - 2006 Paul D Turner &amp;amp; The CEGUI Development Team&lt;br /&gt;
 *&lt;br /&gt;
 *   Permission is hereby granted, free of charge, to any person obtaining&lt;br /&gt;
 *   a copy of this software and associated documentation files (the&lt;br /&gt;
 *   &amp;quot;Software&amp;quot;), to deal in the Software without restriction, including&lt;br /&gt;
 *   without limitation the rights to use, copy, modify, merge, publish,&lt;br /&gt;
 *   distribute, sublicense, and/or sell copies of the Software, and to&lt;br /&gt;
 *   permit persons to whom the Software is furnished to do so, subject to&lt;br /&gt;
 *   the following conditions:&lt;br /&gt;
 *&lt;br /&gt;
 *   The above copyright notice and this permission notice shall be&lt;br /&gt;
 *   included in all copies or substantial portions of the Software.&lt;br /&gt;
 *&lt;br /&gt;
 *   THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND,&lt;br /&gt;
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF&lt;br /&gt;
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.&lt;br /&gt;
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR&lt;br /&gt;
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,&lt;br /&gt;
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR&lt;br /&gt;
 *   OTHER DEALINGS IN THE SOFTWARE.&lt;br /&gt;
 ***************************************************************************/&lt;br /&gt;
#ifndef _CEGUIPhysFSResourceProvider_h_&lt;br /&gt;
#define _CEGUIPhysFSResourceProvider_h_&lt;br /&gt;
&lt;br /&gt;
#include &amp;quot;CEGUI/CEGUIBase.h&amp;quot;&lt;br /&gt;
#include &amp;quot;CEGUI/CEGUIResourceProvider.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;map&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#if defined(_MSC_VER)&lt;br /&gt;
#       pragma warning(push)&lt;br /&gt;
#       pragma warning(disable : 4251)&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
// Start of CEGUI namespace section&lt;br /&gt;
namespace CEGUI&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
//! CEGUI Resource Provider for the PhysFS File System.&lt;br /&gt;
/*! This is an auxiliary class (based on the DefaultResourceProvider from CEGUI)&lt;br /&gt;
  * that provides file access via PhysFS. This is used to load GUI resources&lt;br /&gt;
  * via PhysFS. &lt;br /&gt;
  * Check the CEGUI documentation for further information on Resource Providers.&lt;br /&gt;
  * PhysFS must be initialized before this class can be used! Currently, the&lt;br /&gt;
  * Resource Provider blindly assumes that this has been done which might cause&lt;br /&gt;
  * errors.&lt;br /&gt;
*/&lt;br /&gt;
class PhysFSResourceProvider : public ResourceProvider&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
        /*************************************************************************&lt;br /&gt;
                Construction and Destruction&lt;br /&gt;
        *************************************************************************/&lt;br /&gt;
        PhysFSResourceProvider() {}&lt;br /&gt;
        ~PhysFSResourceProvider(void) {}&lt;br /&gt;
&lt;br /&gt;
    /*!&lt;br /&gt;
    \brief&lt;br /&gt;
        Set the directory associated with a given resource group identifier.&lt;br /&gt;
&lt;br /&gt;
    \param resourceGroup&lt;br /&gt;
        The resource group identifier whose directory is to be set.&lt;br /&gt;
&lt;br /&gt;
    \param directory&lt;br /&gt;
        The directory to be associated with resource group identifier&lt;br /&gt;
        \a resourceGroup&lt;br /&gt;
&lt;br /&gt;
    \return&lt;br /&gt;
        Nothing.&lt;br /&gt;
    */&lt;br /&gt;
    void setResourceGroupDirectory(const String&amp;amp; resourceGroup, const String&amp;amp; directory);&lt;br /&gt;
&lt;br /&gt;
    /*!&lt;br /&gt;
    \brief&lt;br /&gt;
        Return the directory associated with the specified resource group&lt;br /&gt;
        identifier.&lt;br /&gt;
&lt;br /&gt;
    \param resourceGroup&lt;br /&gt;
        The resource group identifier for which the associated directory is to&lt;br /&gt;
        be returned.&lt;br /&gt;
&lt;br /&gt;
    \return&lt;br /&gt;
        String object describing the directory currently associated with resource&lt;br /&gt;
        group identifier \a resourceGroup.&lt;br /&gt;
&lt;br /&gt;
    \note&lt;br /&gt;
        This member is not defined as being const because it may cause&lt;br /&gt;
        creation of an 'empty' directory specification for the resourceGroup&lt;br /&gt;
        if the resourceGroup has not previously been accessed.&lt;br /&gt;
    */&lt;br /&gt;
    const String&amp;amp; getResourceGroupDirectory(const String&amp;amp; resourceGroup);&lt;br /&gt;
&lt;br /&gt;
    /*!&lt;br /&gt;
    \brief&lt;br /&gt;
        clears any currently set directory for the specified resource group&lt;br /&gt;
        identifier.&lt;br /&gt;
&lt;br /&gt;
    \param resourceGroup&lt;br /&gt;
        The resource group identifier for which the associated directory is to&lt;br /&gt;
        be cleared.&lt;br /&gt;
    */&lt;br /&gt;
    void clearResourceGroupDirectory(const String&amp;amp; resourceGroup);&lt;br /&gt;
&lt;br /&gt;
    void loadRawDataContainer(const String&amp;amp; filename, RawDataContainer&amp;amp; output, const String&amp;amp; resourceGroup);&lt;br /&gt;
    void unloadRawDataContainer(RawDataContainer&amp;amp; data);&lt;br /&gt;
    size_t getResourceGroupFileNames(std::vector&amp;lt;String&amp;gt;&amp;amp; out_vec,&lt;br /&gt;
                                     const String&amp;amp; file_pattern,&lt;br /&gt;
                                     const String&amp;amp; resource_group);&lt;br /&gt;
&lt;br /&gt;
protected:&lt;br /&gt;
    /*!&lt;br /&gt;
    \brief&lt;br /&gt;
        Return the final path and filename, taking into account the given&lt;br /&gt;
        resource group identifier that should be used when attempting to&lt;br /&gt;
        load the data.&lt;br /&gt;
    */&lt;br /&gt;
    String getFinalFilename(const String&amp;amp; filename, const String&amp;amp; resourceGroup) const;&lt;br /&gt;
&lt;br /&gt;
    typedef std::map&amp;lt;String, String, String::FastLessCompare&amp;gt; ResourceGroupMap;&lt;br /&gt;
    ResourceGroupMap    d_resourceGroups;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
} // End of  CEGUI namespace section&lt;br /&gt;
&lt;br /&gt;
#if defined(_MSC_VER)&lt;br /&gt;
#       pragma warning(pop)&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#endif  // end of guard _CEGUIPhysFSResourceProvider_h_&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File CEGUIPhysFSResourceProvider.cpp&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
/***********************************************************************&lt;br /&gt;
    filename:   CEGUIPhysFSResourceProvider.cpp&lt;br /&gt;
    created:    8/7/2004&lt;br /&gt;
    author:     James '_mental_' O'Sullivan&lt;br /&gt;
                                with minor changes by Marek 'Wansti' Moeckel&lt;br /&gt;
*************************************************************************/&lt;br /&gt;
/***************************************************************************&lt;br /&gt;
 *   Copyright (C) 2004 - 2010 Paul D Turner &amp;amp; The CEGUI Development Team&lt;br /&gt;
 *&lt;br /&gt;
 *   Permission is hereby granted, free of charge, to any person obtaining&lt;br /&gt;
 *   a copy of this software and associated documentation files (the&lt;br /&gt;
 *   &amp;quot;Software&amp;quot;), to deal in the Software without restriction, including&lt;br /&gt;
 *   without limitation the rights to use, copy, modify, merge, publish,&lt;br /&gt;
 *   distribute, sublicense, and/or sell copies of the Software, and to&lt;br /&gt;
 *   permit persons to whom the Software is furnished to do so, subject to&lt;br /&gt;
 *   the following conditions:&lt;br /&gt;
 *&lt;br /&gt;
 *   The above copyright notice and this permission notice shall be&lt;br /&gt;
 *   included in all copies or substantial portions of the Software.&lt;br /&gt;
 *&lt;br /&gt;
 *   THE SOFTWARE IS PROVIDED &amp;quot;AS IS&amp;quot;, WITHOUT WARRANTY OF ANY KIND,&lt;br /&gt;
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF&lt;br /&gt;
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.&lt;br /&gt;
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR&lt;br /&gt;
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,&lt;br /&gt;
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR&lt;br /&gt;
 *   OTHER DEALINGS IN THE SOFTWARE.&lt;br /&gt;
 ***************************************************************************/&lt;br /&gt;
#include &amp;quot;CEGUIPhysFSResourceProvider.h&amp;quot;&lt;br /&gt;
#include &amp;quot;CEGUI/CEGUIExceptions.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;physfs.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#if defined(__WIN32__) || defined(_WIN32)&lt;br /&gt;
#   include &amp;lt;io.h&amp;gt;&lt;br /&gt;
#   include &amp;lt;windows.h&amp;gt;&lt;br /&gt;
#   include &amp;lt;string&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
std::wstring Utf8ToUtf16(const std::string&amp;amp; utf8text)&lt;br /&gt;
{&lt;br /&gt;
    const int textLen = MultiByteToWideChar(CP_UTF8, 0, utf8text.c_str(),&lt;br /&gt;
                                            utf8text.size() + 1, 0, 0);&lt;br /&gt;
&lt;br /&gt;
    if (textLen == 0)&lt;br /&gt;
        CEGUI_THROW(CEGUI::InvalidRequestException(&lt;br /&gt;
            &amp;quot;Utf8ToUtf16 - MultiByteToWideChar failed&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
    std::wstring wideStr(textLen, 0);&lt;br /&gt;
    MultiByteToWideChar(CP_UTF8, 0, utf8text.c_str(), utf8text.size() + 1,&lt;br /&gt;
                        &amp;amp;wideStr[0], wideStr.size());&lt;br /&gt;
    return wideStr;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
CEGUI::String Utf16ToString(const wchar_t* const utf16text)&lt;br /&gt;
{&lt;br /&gt;
    const int len = WideCharToMultiByte(CP_UTF8, 0, utf16text, -1,&lt;br /&gt;
                                        0, 0, 0, 0);&lt;br /&gt;
    if (!len)&lt;br /&gt;
        CEGUI_THROW(CEGUI::InvalidRequestException(&lt;br /&gt;
            &amp;quot;Utf16ToUtf8 - WideCharToMultiByte failed&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
    CEGUI::utf8* buff = new CEGUI::utf8[len + 1];&lt;br /&gt;
    WideCharToMultiByte(CP_UTF8, 0, utf16text, -1,&lt;br /&gt;
                        reinterpret_cast&amp;lt;char*&amp;gt;(buff), len, 0, 0);&lt;br /&gt;
    const CEGUI::String result(buff);&lt;br /&gt;
    delete[] buff;&lt;br /&gt;
&lt;br /&gt;
    return result;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
#else&lt;br /&gt;
#   include &amp;lt;sys/types.h&amp;gt;&lt;br /&gt;
#   include &amp;lt;sys/stat.h&amp;gt;&lt;br /&gt;
#   include &amp;lt;dirent.h&amp;gt;&lt;br /&gt;
#   include &amp;lt;fnmatch.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
// Start of CEGUI namespace section&lt;br /&gt;
namespace CEGUI&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
void PhysFSResourceProvider::loadRawDataContainer(const String&amp;amp; filename,&lt;br /&gt;
                                                   RawDataContainer&amp;amp; output,&lt;br /&gt;
                                                   const String&amp;amp; resourceGroup)&lt;br /&gt;
{&lt;br /&gt;
        // Make sure PhysFS has been initialized before this point!&lt;br /&gt;
    const String final_filename(getFinalFilename(filename, resourceGroup));&lt;br /&gt;
    if (!PHYSFS_exists(final_filename.c_str()))&lt;br /&gt;
        CEGUI_THROW(InvalidRequestException(&amp;quot;PhysFSResourceProvider::load: &amp;quot;&lt;br /&gt;
            &amp;quot;Filename supplied for data loading must be valid&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
        PHYSFS_file* file = PHYSFS_openRead(final_filename.c_str());&lt;br /&gt;
&lt;br /&gt;
    if (file == NULL)&lt;br /&gt;
        CEGUI_THROW(InvalidRequestException(&amp;quot;PhysFSResourceProvider::load: &amp;quot; +&lt;br /&gt;
            final_filename + &amp;quot; does not exist. &amp;quot; + PHYSFS_getLastError()));&lt;br /&gt;
&lt;br /&gt;
        const size_t size = PHYSFS_fileLength(file);&lt;br /&gt;
    unsigned char* const buffer = new unsigned char[size];&lt;br /&gt;
&lt;br /&gt;
        const size_t size_read = PHYSFS_read(file, buffer, 1, size);&lt;br /&gt;
    PHYSFS_close(file);&lt;br /&gt;
&lt;br /&gt;
    if (size_read != size)&lt;br /&gt;
    {&lt;br /&gt;
        delete[] buffer;&lt;br /&gt;
        CEGUI_THROW(GenericException(&lt;br /&gt;
            &amp;quot;PhysFSResourceProvider::loadRawDataContainer: &amp;quot;&lt;br /&gt;
            &amp;quot;A problem occurred while reading file: &amp;quot; + final_filename));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    output.setData(buffer);&lt;br /&gt;
    output.setSize(size);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
void PhysFSResourceProvider::unloadRawDataContainer(RawDataContainer&amp;amp; data)&lt;br /&gt;
{&lt;br /&gt;
    uint8* const ptr = data.getDataPtr();&lt;br /&gt;
    delete[] ptr;&lt;br /&gt;
    data.setData(0);&lt;br /&gt;
    data.setSize(0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
void PhysFSResourceProvider::setResourceGroupDirectory(&lt;br /&gt;
                                                const String&amp;amp; resourceGroup,&lt;br /&gt;
                                                const String&amp;amp; directory)&lt;br /&gt;
{&lt;br /&gt;
    if (directory.length() == 0)&lt;br /&gt;
        return;&lt;br /&gt;
&lt;br /&gt;
#if defined(_WIN32) || defined(__WIN32__)&lt;br /&gt;
    // while we rarely use the unportable '\', the user may have&lt;br /&gt;
    const String separators(&amp;quot;\\/&amp;quot;);&lt;br /&gt;
#else&lt;br /&gt;
    const String separators(&amp;quot;/&amp;quot;);&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
    if (String::npos == separators.find(directory[directory.length() - 1]))&lt;br /&gt;
        d_resourceGroups[resourceGroup] = directory + '/';&lt;br /&gt;
    else&lt;br /&gt;
        d_resourceGroups[resourceGroup] = directory;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
const String&amp;amp; PhysFSResourceProvider::getResourceGroupDirectory(&lt;br /&gt;
                                                const String&amp;amp; resourceGroup)&lt;br /&gt;
{&lt;br /&gt;
    return d_resourceGroups[resourceGroup];&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
void PhysFSResourceProvider::clearResourceGroupDirectory(&lt;br /&gt;
                                                const String&amp;amp; resourceGroup)&lt;br /&gt;
{&lt;br /&gt;
    ResourceGroupMap::iterator iter = d_resourceGroups.find(resourceGroup);&lt;br /&gt;
&lt;br /&gt;
    if (iter != d_resourceGroups.end())&lt;br /&gt;
        d_resourceGroups.erase(iter);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
String PhysFSResourceProvider::getFinalFilename(&lt;br /&gt;
                                            const String&amp;amp; filename,&lt;br /&gt;
                                            const String&amp;amp; resourceGroup) const&lt;br /&gt;
{&lt;br /&gt;
    String final_filename;&lt;br /&gt;
&lt;br /&gt;
    // look up resource group directory&lt;br /&gt;
    ResourceGroupMap::const_iterator iter =&lt;br /&gt;
        d_resourceGroups.find(resourceGroup.empty() ?&lt;br /&gt;
            d_defaultResourceGroup :&lt;br /&gt;
            resourceGroup);&lt;br /&gt;
&lt;br /&gt;
    // if there was an entry for this group, use it's directory as the&lt;br /&gt;
    // first part of the filename&lt;br /&gt;
    if (iter != d_resourceGroups.end())&lt;br /&gt;
        final_filename = (*iter).second;&lt;br /&gt;
&lt;br /&gt;
    // append the filename part that we were passed&lt;br /&gt;
    final_filename += filename;&lt;br /&gt;
&lt;br /&gt;
    // return result&lt;br /&gt;
    return final_filename;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
size_t PhysFSResourceProvider::getResourceGroupFileNames(&lt;br /&gt;
    std::vector&amp;lt;String&amp;gt;&amp;amp; out_vec,&lt;br /&gt;
    const String&amp;amp; file_pattern,&lt;br /&gt;
    const String&amp;amp; resource_group)&lt;br /&gt;
{&lt;br /&gt;
    // look-up resource group name&lt;br /&gt;
    ResourceGroupMap::const_iterator iter =&lt;br /&gt;
        d_resourceGroups.find(resource_group.empty() ? d_defaultResourceGroup :&lt;br /&gt;
                              resource_group);&lt;br /&gt;
    // get directory that's set for the resource group&lt;br /&gt;
    const String dir_name(&lt;br /&gt;
        iter != d_resourceGroups.end() ? (*iter).second : &amp;quot;./&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    size_t entries = 0;&lt;br /&gt;
&lt;br /&gt;
// Win32 code.&lt;br /&gt;
#if defined(__WIN32__) || defined(_WIN32)&lt;br /&gt;
    intptr_t f;&lt;br /&gt;
    struct _wfinddata_t fd;&lt;br /&gt;
&lt;br /&gt;
    if ((f = _wfindfirst(Utf8ToUtf16((dir_name + file_pattern).c_str()).c_str(), &amp;amp;fd)) != -1)&lt;br /&gt;
    {&lt;br /&gt;
        do&lt;br /&gt;
        {&lt;br /&gt;
            if ((fd.attrib &amp;amp; _A_SUBDIR))&lt;br /&gt;
                continue;&lt;br /&gt;
&lt;br /&gt;
            out_vec.push_back(Utf16ToString(fd.name));&lt;br /&gt;
            ++entries;&lt;br /&gt;
        }&lt;br /&gt;
        while (_wfindnext(f, &amp;amp;fd) == 0);&lt;br /&gt;
&lt;br /&gt;
        _findclose(f);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
// Everybody else&lt;br /&gt;
#else&lt;br /&gt;
    DIR* dirp;&lt;br /&gt;
&lt;br /&gt;
    if ((dirp = opendir(dir_name.c_str())))&lt;br /&gt;
    {&lt;br /&gt;
        struct dirent* dp;&lt;br /&gt;
&lt;br /&gt;
        while ((dp = readdir(dirp)))&lt;br /&gt;
        {&lt;br /&gt;
            const String filename(dir_name + dp-&amp;gt;d_name);&lt;br /&gt;
            struct stat s;&lt;br /&gt;
&lt;br /&gt;
            if ((stat(filename.c_str(), &amp;amp;s) == 0) &amp;amp;&amp;amp;&lt;br /&gt;
                    S_ISREG(s.st_mode) &amp;amp;&amp;amp;&lt;br /&gt;
                    (fnmatch(file_pattern.c_str(), dp-&amp;gt;d_name, 0) == 0))&lt;br /&gt;
            {&lt;br /&gt;
                out_vec.push_back(dp-&amp;gt;d_name);&lt;br /&gt;
                ++entries;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        closedir(dirp);&lt;br /&gt;
    }&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
    return entries;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//----------------------------------------------------------------------------//&lt;br /&gt;
&lt;br /&gt;
} // End of  CEGUI namespace section&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hr&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In your main code, initialize CEGUI with your custom Resource Provider. Load resources as usual.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;CEGUIPhysFSResourceProvider.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void Gui::init()&lt;br /&gt;
{&lt;br /&gt;
    OpenGLRenderer&amp;amp; myRenderer = OpenGLRenderer::create();&lt;br /&gt;
    PhysFSResourceProvider* rp = new PhysFSResourceProvider();&lt;br /&gt;
    System::create(myRenderer, static_cast&amp;lt;ResourceProvider*&amp;gt;(rp), NULL, NULL, NULL, &amp;quot;&amp;quot;, &amp;quot;log.txt&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    //set Resource Group directories and load data&lt;br /&gt;
    //...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>Wansti</name></author>	</entry>

	</feed>