<?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, Directory up (..&#x2F;)?]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ein wahrscheinlich eher triviales Problem, aber ich finde nicht heraus<br />
wie ich ein Verzeichnis nach oben springen kann...<br />
In der Kommandozeile wäre das ja ein &quot;../&quot;. Aber wie kann ich das in meiner<br />
SW umsetzen ?</p>
<p>Gruss Hoselupf</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;boost/filesystem.hpp&gt;

using namespace std;
namespace fs = boost::filesystem;

bool dicPathValid(string pathIn){
	if (!fs::is_directory(fs::path(pathIn))){
		cout &lt;&lt; &quot;Path not valid\n&quot;
			 &lt;&lt; &quot;Try again:\n&quot;;
		return false;
	}
	return true;
}

int main()
{
	cout &lt;&lt; &quot;Root directory path: &quot;;
	string rootPath;
	do{
		cin &gt;&gt; rootPath;
	} while (!dicPathValid(rootPath));

	fs::path myPath(rootPath);
	myPath /= &quot;OrdnerX&quot;;

	for (int i = 0; i != 20; i++){
		myPath /= &quot;Unterordner&quot; + to_string(i);
		//do stuff in Unterordner(i)
		//go directory up (../) ???
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/335843/boost-filesystem-directory-up</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Apr 2026 03:42:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/335843.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 15 Dec 2015 08:08:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Boost Filesystem, Directory up (..&#x2F;)? on Tue, 15 Dec 2015 08:11:42 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ein wahrscheinlich eher triviales Problem, aber ich finde nicht heraus<br />
wie ich ein Verzeichnis nach oben springen kann...<br />
In der Kommandozeile wäre das ja ein &quot;../&quot;. Aber wie kann ich das in meiner<br />
SW umsetzen ?</p>
<p>Gruss Hoselupf</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;boost/filesystem.hpp&gt;

using namespace std;
namespace fs = boost::filesystem;

bool dicPathValid(string pathIn){
	if (!fs::is_directory(fs::path(pathIn))){
		cout &lt;&lt; &quot;Path not valid\n&quot;
			 &lt;&lt; &quot;Try again:\n&quot;;
		return false;
	}
	return true;
}

int main()
{
	cout &lt;&lt; &quot;Root directory path: &quot;;
	string rootPath;
	do{
		cin &gt;&gt; rootPath;
	} while (!dicPathValid(rootPath));

	fs::path myPath(rootPath);
	myPath /= &quot;OrdnerX&quot;;

	for (int i = 0; i != 20; i++){
		myPath /= &quot;Unterordner&quot; + to_string(i);
		//do stuff in Unterordner(i)
		//go directory up (../) ???
	}
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2479578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2479578</guid><dc:creator><![CDATA[Hoselupf]]></dc:creator><pubDate>Tue, 15 Dec 2015 08:11:42 GMT</pubDate></item><item><title><![CDATA[Reply to Boost Filesystem, Directory up (..&#x2F;)? on Tue, 15 Dec 2015 08:19:09 GMT]]></title><description><![CDATA[<p>Den Pfad von hinten bis zum ersten Slash/Backslash (inklusive) abschneiden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2479579</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2479579</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Tue, 15 Dec 2015 08:19:09 GMT</pubDate></item><item><title><![CDATA[Reply to Boost Filesystem, Directory up (..&#x2F;)? on Tue, 15 Dec 2015 08:41:38 GMT]]></title><description><![CDATA[<p>Genau. Und dann ist der letzte Pfadbestandteil ein Symlink. Oops.</p>
<p>Zurück zur Frage: Häng .. an den Pfad an.</p>
<p><a href="http://www.boost.org/doc/libs/1_59_0/libs/filesystem/doc/reference.html#path-concatenation" rel="nofollow">http://www.boost.org/doc/libs/1_59_0/libs/filesystem/doc/reference.html#path-concatenation</a> schrieb:</p>
<blockquote>
<p>The filename &quot;..&quot; is considered to be a reference to the parent directory.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2479582</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2479582</guid><dc:creator><![CDATA[SG1]]></dc:creator><pubDate>Tue, 15 Dec 2015 08:41:38 GMT</pubDate></item><item><title><![CDATA[Reply to Boost Filesystem, Directory up (..&#x2F;)? on Tue, 15 Dec 2015 09:03:00 GMT]]></title><description><![CDATA[<p>Dies scheint auch zu funktionieren.</p>
<pre><code>myPath = myPath.parent_path();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2479584</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2479584</guid><dc:creator><![CDATA[Hoselupf]]></dc:creator><pubDate>Tue, 15 Dec 2015 09:03:00 GMT</pubDate></item><item><title><![CDATA[Reply to Boost Filesystem, Directory up (..&#x2F;)? on Tue, 15 Dec 2015 09:57:46 GMT]]></title><description><![CDATA[<p>Hoselupf schrieb:</p>
<blockquote>
<p>Dies scheint auch zu funktionieren.</p>
<pre><code>myPath = myPath.parent_path();
</code></pre>
</blockquote>
<p>Hat das gleiche Problem, wenn der letzte Pfadbestandteil ein Symlink ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2479597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2479597</guid><dc:creator><![CDATA[SG1]]></dc:creator><pubDate>Tue, 15 Dec 2015 09:57:46 GMT</pubDate></item></channel></rss>