Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
paths.cpp
Go to the documentation of this file.
1// paths.cpp — paths.h の実装。GetModuleFileNameW を使う。
2//
3// core はプリコンパイルヘッダを持たない小さな静的ライブラリなので、windows.h はここで直接 include する。
4#include "core/paths.h"
5
6#include <windows.h>
7
8#include <string>
9
10namespace bicameral {
11
13 // MAX_PATH を超えるパスもあるので、足りなければ広げて取り直す
14 std::wstring buffer(MAX_PATH, L'\0');
15 for (;;) {
16 const DWORD length = GetModuleFileNameW(nullptr, buffer.data(), static_cast<DWORD>(buffer.size()));
17 if (length == 0)
18 return {};
19
20 if (length < buffer.size()) {
21 buffer.resize(length);
22 break;
23 }
24
25 buffer.resize(buffer.size() * 2);
26 }
27
28 return fs::path(buffer).parent_path();
29 }
30
31} // namespace bicameral
fs::path ExecutableDirectory()
Definition paths.cpp:12