Boost C++ Libraries: Ticket #11663: No way to query file extension without allocating memory https://svn.boost.org/trac10/ticket/11663 <p> the function .extension() returns an fs::path, containing a fresh string that contains the extension. On certain library implementations that don't implement the SSO -- or, I guess, for files with very long extensions -- there will be a memory allocation each time the function is called. </p> <p> That means that for solutions implementing search-by-extension such as is written in: </p> <p> <a class="ext-link" href="http://stackoverflow.com/questions/11140483/how-to-get-list-of-files-with-a-specific-extension-in-a-given-folder"><span class="icon">​</span>http://stackoverflow.com/questions/11140483/how-to-get-list-of-files-with-a-specific-extension-in-a-given-folder</a> </p> <p> there could be hundreds of memory allocations for just iterating a directory structure. IMO, there really shouldn't be. </p> <p> I propose adding the function bool path::has_extension(string const&amp;) which can compare the extension in a memory-friendly way. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11663 Trac 1.4.3 Beman Dawes Sun, 04 Oct 2015 12:05:13 GMT status changed https://svn.boost.org/trac10/ticket/11663#comment:1 https://svn.boost.org/trac10/ticket/11663#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> The broader problem is that neither Boost.Filesystem nor the C++ Filesystem Library TS supports globbing. See <a class="ext-link" href="https://en.wikipedia.org/wiki/Glob_%28programming%29"><span class="icon">​</span>https://en.wikipedia.org/wiki/Glob_%28programming%29</a> </p> <p> So rather than tackling your suggested change, I'll take a look the more general glob match problem. </p> <p> Thanks, </p> <p> --Beman </p> Ticket daniel.kruegler@… Fri, 09 Sep 2016 18:14:22 GMT <link>https://svn.boost.org/trac10/ticket/11663#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11663#comment:2</guid> <description> <p> I have doubts regarding the practical usefulness of that feature (modulo globbing as pointed out by Beman): At least on Windows systems, path names are handled case-insensitive, so if you want to check whether a given path has a .pdf extension, you would need to check against all uppercase and lowercase character combinations of .pdf (.Pdf, .pDf, .pdF, ...). Note that this wouldn't be solved by has_extension() internally because all other existing lexical comparison functions of filesystem do compare *exactly* and for consistency reasons this function would need to do the same. </p> </description> <category>Ticket</category> </item> </channel> </rss>