<?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[Pfad korrigieren mit boost::filesystem V3]]></title><description><![CDATA[<pre><code class="language-cpp">namespace fs = boost::filesystem;
std::string GetDataPath(HINSTANCE hInstance)
{
    char dir[MAX_PATH];
    GetModuleFileNameA(hInstance, dir, MAX_PATH);

    fs::path p(dir);
    p = ( p.parent_path() / &quot;../data&quot; );
    p.make_preferred();
    return p.string();
}
</code></pre>
<p>Ich hole mir den ganzen Pfad zu der Anwendung die gerade ausgeführt wird mit GetModuleFileName. Danach schneide ich den Dateinamen ab und hänge &quot;../data&quot; an.</p>
<p>Ich dachte make_preferred würde jetzt das &quot;..&quot; entfernen und den Pfad entsprechend in &quot;D:\Source\SpaceGame\bin\data&quot; korrigieren, es bleibt aber bei &quot;D:\Source\SpaceGame\bin\Debug\..\data&quot;.<br />
Gibts hier noch was in boost oder komm ich um GetFullPathName() nicht herum?<br />
Habe die Doku durchgeschaut, aber nichts gefunden was mir da jetzt weiterhelfen würde leider...<br />
Bitte beachten: Ich nutze V3 mit BOOST_FILESYSTEM_NO_DEPRECATED Parameter.</p>
<p>edit:</p>
<pre><code class="language-cpp">std::string GetDataPath(HINSTANCE hInstance)
{
    char dir[MAX_PATH];
    GetModuleFileNameA(hInstance, dir, MAX_PATH);

    fs::path p(dir);
    p = ( p.parent_path().parent_path() / &quot;data&quot; );
    p.make_preferred();
    return p.string();
}
</code></pre>
<p>Das funktioniert soweit, aber ob das gut is?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/300970/pfad-korrigieren-mit-boost-filesystem-v3</link><generator>RSS for Node</generator><lastBuildDate>Wed, 12 Aug 2026 13:03:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/300970.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 15 Mar 2012 10:05:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Pfad korrigieren mit boost::filesystem V3 on Thu, 15 Mar 2012 10:27:40 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">namespace fs = boost::filesystem;
std::string GetDataPath(HINSTANCE hInstance)
{
    char dir[MAX_PATH];
    GetModuleFileNameA(hInstance, dir, MAX_PATH);

    fs::path p(dir);
    p = ( p.parent_path() / &quot;../data&quot; );
    p.make_preferred();
    return p.string();
}
</code></pre>
<p>Ich hole mir den ganzen Pfad zu der Anwendung die gerade ausgeführt wird mit GetModuleFileName. Danach schneide ich den Dateinamen ab und hänge &quot;../data&quot; an.</p>
<p>Ich dachte make_preferred würde jetzt das &quot;..&quot; entfernen und den Pfad entsprechend in &quot;D:\Source\SpaceGame\bin\data&quot; korrigieren, es bleibt aber bei &quot;D:\Source\SpaceGame\bin\Debug\..\data&quot;.<br />
Gibts hier noch was in boost oder komm ich um GetFullPathName() nicht herum?<br />
Habe die Doku durchgeschaut, aber nichts gefunden was mir da jetzt weiterhelfen würde leider...<br />
Bitte beachten: Ich nutze V3 mit BOOST_FILESYSTEM_NO_DEPRECATED Parameter.</p>
<p>edit:</p>
<pre><code class="language-cpp">std::string GetDataPath(HINSTANCE hInstance)
{
    char dir[MAX_PATH];
    GetModuleFileNameA(hInstance, dir, MAX_PATH);

    fs::path p(dir);
    p = ( p.parent_path().parent_path() / &quot;data&quot; );
    p.make_preferred();
    return p.string();
}
</code></pre>
<p>Das funktioniert soweit, aber ob das gut is?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2191836</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2191836</guid><dc:creator><![CDATA[[[global:former_user]]]]></dc:creator><pubDate>Thu, 15 Mar 2012 10:27:40 GMT</pubDate></item></channel></rss>