Results 1 to 5 of 5

Thread: 2.2: get_section_names returning extra char

  1. #1

    Default 2.2: get_section_names returning extra char


    I'm running into a problem where the string values returned from CL_ResourceManager::get_section_names have a trailing character that prints to the console as "/". If I remove the trailing character then it won't find the section despite being the same as the original name in the XML.

    I've seen this kind of thing before and it's been an encoding issue, but I'm not sure if it's a bug or something weird I'm doing, since I can't find anything in the examples using this code.

    Running on Linux, g++ etc.


    EDIT: Additionally resourceFile.get_resource_names_of_type("layer", "name/") and resourceFile.get_resource_names_of_type("layer", "name") both return 0, while resourceFile.get_resource_names("layer") correctly returns the number of "layer" elements in all sections.
    This is code that was working in 0.8 before porting to 2.2.
    Last edited by Shulberry; 08-03-2010 at 10:41 PM.

  2. #2
    ClanLib Developer
    Join Date
    May 2007


    I have just tried porting the Resources example from ClanLib 1.0 (old 0.8)

    ... and it does not work.

    I'll have a quick look to see how easy it will be to fix.

    (For the 2.2.1 bug fixes release)

  3. #3
    ClanLib Developer
    Join Date
    May 2007


    See attached patch:

    It is not in the ClanLib 2.2 SVN yet, I'll do it tomorrow if I have time
    Index: Core/Resources/resource_manager.cpp
    --- Core/Resources/resource_manager.cpp	(revision 4800)
    +++ Core/Resources/resource_manager.cpp	(working copy)
    @@ -202,18 +202,18 @@
     	const CL_String &type,
     	const CL_String &section) const
    +	CL_String section_trailing_slash = CL_PathHelp::add_trailing_slash(section, CL_PathHelp::path_type_virtual);
     	std::vector<CL_String> names;
     	std::map<CL_String, CL_Resource>::const_iterator it;
     	for (it = impl->resources.begin(); it != impl->resources.end(); ++it)
    -		CL_String cur_section = CL_PathHelp::get_filename(it->first, CL_PathHelp::path_type_virtual);
    -		if (section == cur_section)
    +		CL_String cur_section = CL_PathHelp::get_fullpath(it->first, CL_PathHelp::path_type_virtual);
    +		if (section_trailing_slash == cur_section)
     			if (it->second.get_type() == type)
    -			{
    -				CL_String name = CL_PathHelp::get_filename(it->first, CL_PathHelp::path_type_virtual);
    -				names.push_back(name);
    -			}
    +				names.push_back(it->first);
     	return names;
    Attached Files Attached Files

  4. #4


    That seems to work fine, thanks for the quick fix!

  5. #5

    Default 2.2: get_section_names returning extra char -- same issue with 2.3?

    I am a C++ noob, but this (snippet) was working under ClanLib 1.0, but using get_all_sections() with std::vector<string>... now porting to ClanLib 2.3.4 on Linux:
    CL_ResourceManager resmgr;
    vector<CL_String> Sections;
    vector<CL_String>::iterator section;
    resmgr = CL_ResourceManager("myarcade.xml");
    Sections = resmgr.get_section_names();
    for (section = Sections.begin(); section != Sections.end(); section++)
    	CL_Console::write(" [" + *section + "] " );
    It outputs [arcade/] [computer/] [console/] [engine/] when before there was no trailing '/'. Is this supposed to be correct like this?



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts