<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Boost::filesystem -&amp;gt; need help]]></title><description><![CDATA[<p>Hallo allerseit,<br />
sitze derzeit über einer Plattformübergreifenden Filesearch Funktion.<br />
Läuft eigentlich auch ganz ok soweit, ich bekomme jedoch bei einer zu großen Anzahl an vorhandenen Unterordnern und Files eine Fehlermeldung. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Bei einer genaueren Zuweisung des Pfads macht das Programm keine Probleme!</p>
<p>Hier mal der Code:</p>
<pre><code class="language-cpp">#include&lt;boost/filesystem/operations.hpp&gt;
#include&lt;iostream&gt;
#include&lt;string&gt;
namespace bfs=boost::filesystem;

// Search for a file with the name 'filename' starting in directory 'dir_path', 
// copy the path of the file in 'pfound' if found, and return true.
// Else return false.
bool find_file(const bfs::path &amp; dir_path, const std::string &amp; file_name, bfs::path &amp; pfound)
{
	if( !exists(dir_path) || !is_directory(dir_path) )
		return false;
	bfs::directory_iterator iter(dir_path), end_iter;
	for(; iter!= end_iter; ++iter)
	{
		if( bfs::is_directory(*iter) )
		{
			if( find_file(*iter, file_name, pfound) )
				return true;
		}
		else if( iter-&gt;leaf() == file_name )
		{
			pfound = *iter;
			std::cout&lt;&lt;pfound&lt;&lt;std::endl;
			return true;
		}
	}
	return false;
}

int main(){
	bfs::path my_path(&quot;c:\\&quot;);
	bfs::path temp_path(&quot;&quot;);
	if(!find_file(my_path,&quot;test.cpp&quot;, temp_path)) std::cout&lt;&lt;&quot;Konnte nicht gefunden werden!&quot;&lt;&lt;std::endl;
	system(&quot;pause&quot;);
}
</code></pre>
<p>Vielen Dank für eure Hilfe<br />
geneticZ</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/216404/boost-filesystem-gt-need-help</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 12:39:21 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/216404.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 23 Jun 2008 16:04:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 16:04:24 GMT]]></title><description><![CDATA[<p>Hallo allerseit,<br />
sitze derzeit über einer Plattformübergreifenden Filesearch Funktion.<br />
Läuft eigentlich auch ganz ok soweit, ich bekomme jedoch bei einer zu großen Anzahl an vorhandenen Unterordnern und Files eine Fehlermeldung. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>Bei einer genaueren Zuweisung des Pfads macht das Programm keine Probleme!</p>
<p>Hier mal der Code:</p>
<pre><code class="language-cpp">#include&lt;boost/filesystem/operations.hpp&gt;
#include&lt;iostream&gt;
#include&lt;string&gt;
namespace bfs=boost::filesystem;

// Search for a file with the name 'filename' starting in directory 'dir_path', 
// copy the path of the file in 'pfound' if found, and return true.
// Else return false.
bool find_file(const bfs::path &amp; dir_path, const std::string &amp; file_name, bfs::path &amp; pfound)
{
	if( !exists(dir_path) || !is_directory(dir_path) )
		return false;
	bfs::directory_iterator iter(dir_path), end_iter;
	for(; iter!= end_iter; ++iter)
	{
		if( bfs::is_directory(*iter) )
		{
			if( find_file(*iter, file_name, pfound) )
				return true;
		}
		else if( iter-&gt;leaf() == file_name )
		{
			pfound = *iter;
			std::cout&lt;&lt;pfound&lt;&lt;std::endl;
			return true;
		}
	}
	return false;
}

int main(){
	bfs::path my_path(&quot;c:\\&quot;);
	bfs::path temp_path(&quot;&quot;);
	if(!find_file(my_path,&quot;test.cpp&quot;, temp_path)) std::cout&lt;&lt;&quot;Konnte nicht gefunden werden!&quot;&lt;&lt;std::endl;
	system(&quot;pause&quot;);
}
</code></pre>
<p>Vielen Dank für eure Hilfe<br />
geneticZ</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534262</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534262</guid><dc:creator><![CDATA[geneticZ]]></dc:creator><pubDate>Mon, 23 Jun 2008 16:04:24 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 16:15:41 GMT]]></title><description><![CDATA[<p>Mensch, wenn du Hilfe willst musst du auch sagen, was der Fehler ist.<br />
Ich rate jetzt einfach mal, es gibt einen Stack-Overflow. Dann musst du die Funktion iterativ (also die Logik hinter if(is_directory) { find_file } verschleifen). Versuch's mal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534266</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534266</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Mon, 23 Jun 2008 16:15:41 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 16:47:03 GMT]]></title><description><![CDATA[<p>hallo filmor,<br />
sorry dass ich keine Fehlermeldung dazu geschrieben habe, aber ich bekomme da auch nur von Boost die Exception Meldung reingeballert und die ist leider nicht sehr aussage kräftig. (Zumindest für mich)</p>
<p>Hier die Meldung:</p>
<pre><code>First-chance exception at 0x7680b09e in boost-nexttry.exe: Microsoft C++ exception:
boost::filesystem::basic_filesystem_error&lt;boost::filesystem::basic_path&lt;std::basic_string&lt;char,std::char_traits&lt;char&gt;,std::allocator&lt;char&gt; &gt;,
boost::filesystem::path_traits&gt; &gt; at memory location 0x0029f354..
</code></pre>
<p>Wie kann ich die Funktion iterativ umschreiben?<br />
Eigentlich is die Funktion ja direkt von der Boost Seite und warum weisen die einen dann nicht darauf hin dass es Probleme mit dem Stack geben könnte?</p>
<p>Warum gibt es kein Problem mit den Winapi Funktionen bei der genau der selben Datenmenge zum Durchsuchen?</p>
<p>Danke für die Hilfe<br />
geneticZ</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534286</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534286</guid><dc:creator><![CDATA[geneticZ]]></dc:creator><pubDate>Mon, 23 Jun 2008 16:47:03 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 16:50:17 GMT]]></title><description><![CDATA[<p>Oh, nein, das ist kein Stack-Overflow. Wahrscheinlich beschwert sich Boost.Filesystem nur, dass er auf eine Datei oder ein Verzeichnis nicht zugreifen kann. Fang die Exception in der Funktion. Das rekursive sollte es schon tun, so tief sind Verzeichnishierarchien normalerweise nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534291</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534291</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Mon, 23 Jun 2008 16:50:17 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 17:11:54 GMT]]></title><description><![CDATA[<p>Vielleicht solltest du mal &quot;what()&quot; von der Exception ausdrucken...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534306</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534306</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Jun 2008 17:11:54 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 17:42:13 GMT]]></title><description><![CDATA[<p>wie kann ich das Abfangen, ich steh grad echt auf dem Schlauch!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534319</guid><dc:creator><![CDATA[geneticZ]]></dc:creator><pubDate>Mon, 23 Jun 2008 17:42:13 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 17:43:59 GMT]]></title><description><![CDATA[<p>geneticZ schrieb:</p>
<blockquote>
<p>wie kann ich das Abfangen, ich steh grad echt auf dem Schlauch!</p>
</blockquote>
<p>Du bekommst ja eine Exception geworfen. Und wenn du die fängst (catch ), dann kannst du dort auch what () aufrufen und du bekommst eine Beschreibung des Problems.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534320</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534320</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 23 Jun 2008 17:43:59 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 17:48:05 GMT]]></title><description><![CDATA[<p>ja, aber was ich gerade gar nicht begreife is halt, dass ich in meinem Code die Exception gar nicht werfe <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Normal wäre das ja try - catch...<br />
Aber wo muss ich hier mit dem catch ansetzen?</p>
<p>Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534322</guid><dc:creator><![CDATA[geneticZ]]></dc:creator><pubDate>Mon, 23 Jun 2008 17:48:05 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 17:53:42 GMT]]></title><description><![CDATA[<p>geneticZ schrieb:</p>
<blockquote>
<p>ja, aber was ich gerade gar nicht begreife is halt, dass ich in meinem Code die Exception gar nicht werfe <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Normal wäre das ja try - catch...<br />
Aber wo muss ich hier mit dem catch ansetzen?</p>
<p>Danke</p>
</blockquote>
<p>Die musst auch nicht unbedingt DU werfen. Das ist ja der Sinn, dass die jemand anderst werfen kann und DU darauf reagieren kannst.<br />
Du solltest dich mal mit Exceptions beschäftigen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534324</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534324</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 23 Jun 2008 17:53:42 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 17:56:31 GMT]]></title><description><![CDATA[<p>drakon schrieb:</p>
<blockquote>
<p>Die musst auch nicht unbedingt DU werfen. Das ist ja der Sinn, dass die jemand anderst werfen kann und DU darauf reagieren kannst.<br />
Du solltest dich mal mit Exceptions beschäftigen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
</blockquote>
<p>Da gebe ich dir absolut recht!<br />
Und zum guten Einstieg könntest du mir gerade mal bisl unter die Arme greifen und mir sagen wie und wo ich das hier ansetzen kann <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534325</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534325</guid><dc:creator><![CDATA[geneticZ]]></dc:creator><pubDate>Mon, 23 Jun 2008 17:56:31 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 18:26:33 GMT]]></title><description><![CDATA[<p><a href="http://tutorial.schornboeck.net/exceptions.htm" rel="nofollow">http://tutorial.schornboeck.net/exceptions.htm</a></p>
<p><a href="http://www.cplusplus.com/doc/tutorial/exceptions.html" rel="nofollow">http://www.cplusplus.com/doc/tutorial/exceptions.html</a></p>
<p>Oder gleich:<br />
<a href="http://www.google.ch/search?q=exception+c%2B%2B&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla:de:official&amp;client=firefox-a" rel="nofollow">http://www.google.ch/search?q=exception+c%2B%2B&amp;ie=utf-8&amp;oe=utf-8&amp;aq=t&amp;rls=org.mozilla<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f1e9-1f1ea.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--germany"
      title=":de:"
      alt="🇩🇪"
    />official&amp;client=firefox-a</a></p>
<p>Ansonsten sind da die Standardwerke (<a href="http://www.research.att.com/~bs/3rd.html" rel="nofollow">TC++PL</a> usw) auch eine gute Möglichkeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534346</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534346</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Mon, 23 Jun 2008 18:26:33 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 19:13:22 GMT]]></title><description><![CDATA[<p>Ganz einfach, so geht das:</p>
<pre><code class="language-cpp">int main() { 
    bfs::path my_path(&quot;c:\\&quot;); 
    bfs::path temp_path(&quot;&quot;); 

    try {
        if (!find_file(my_path,&quot;test.cpp&quot;, temp_path))
            std::cout &lt;&lt; &quot;Konnte nicht gefunden werden!&quot; &lt;&lt; std::endl; 
    }
    catch (std::exception const&amp; e) {
        std::cout &lt;&lt; &quot;EEEEERROR!!!!11elf&quot; &lt;&lt; std::endl;
        std::cout &lt;&lt; &quot;  type: &quot; &lt;&lt; typeid(e).name() &lt;&lt; std::endl;
        std::cout &lt;&lt; &quot;  message: &quot; &lt;&lt; e.what() &lt;&lt; std::endl;
    }
    system(&quot;pause&quot;); 
}
</code></pre>
<p>Wenn man so nur exceptions fangen könnte die unmittelbar im try {} Block stehen wäre die ganze Sache ja auch ziemlich sinnlos, nicht? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>D.h. catch fängt alle passenden Exceptions die im try {} Block irgendwo geworfen werden, ganz egal wie &quot;tief&quot; in irgendwelchen Unterfunktionen die geworfen werden. Ausser natürlich wenn sie &quot;davor&quot; schon gefangen werden, d.h. &quot;näher&quot; an der Stelle wo sie geworfen werden. (&quot;näher&quot; wäre hier z.B. ein catch Block in der Funktion find_file)</p>
<p>Die Feinheiten kannst du ja nachlesen, ich schätze die Links von drakon werden das wohl genauer erklären.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534380</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534380</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Jun 2008 19:13:22 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 19:21:45 GMT]]></title><description><![CDATA[<p>super vielen Dank!</p>
<pre><code>EEEEERROR!!!!11elf
  type: class boost::filesystem::basic_filesystem_error&lt;class boost::filesystem:
:basic_path&lt;class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std
::allocator&lt;char&gt; &gt;,struct boost::filesystem::path_traits&gt; &gt;
  message: boost::filesystem::basic_directory_iterator constructor: Zugriff verw
eigert: &quot;c:\$Recycle.Bin\S-1-5-21-1829455090-3793272444-3375908254-500&quot;
Drücken Sie eine beliebige Taste . . .
</code></pre>
<p>Also, wie ihr vermutet habt wird der Zugriff verweigert.<br />
Wie kann ich dieses Problem lösen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534387</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534387</guid><dc:creator><![CDATA[geneticZ]]></dc:creator><pubDate>Mon, 23 Jun 2008 19:21:45 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Mon, 23 Jun 2008 19:39:44 GMT]]></title><description><![CDATA[<p>Naja, entweder fangen und ignorieren, oder gucken ob du es mit den &quot;non throwing&quot; Funktionen irgendwie gebacken bekommst.<br />
(Ich weiss nicht von welchen Funktionen es alles non-throwing Versionen gibt, daher weiss ich auch nicht ob man damit auskommt)</p>
<p>Auf jeden Fall müsstest du die find_file Funktion umbauen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534396</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534396</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Mon, 23 Jun 2008 19:39:44 GMT</pubDate></item><item><title><![CDATA[Reply to Boost::filesystem -&amp;gt; need help on Tue, 24 Jun 2008 10:04:29 GMT]]></title><description><![CDATA[<p>so, also ich weiß momentan wirklich überhaupt nicht wie ich damit umgehen soll <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
<p>Exception ignore is ja auch nicht wirklich das ware oder?<br />
Gibt es nicht ne möglichkeit Ordner ohne zugriff zu überspringen?</p>
<p>Danke für die Hilfe<br />
geneticZ</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1534415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1534415</guid><dc:creator><![CDATA[geneticZ]]></dc:creator><pubDate>Tue, 24 Jun 2008 10:04:29 GMT</pubDate></item></channel></rss>