diff options
Diffstat (limited to 'source/core/slang-platform.cpp')
| -rw-r--r-- | source/core/slang-platform.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index 10b9b576b..20dfed5a8 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -66,6 +66,19 @@ SLANG_COMPILE_TIME_ASSERT(E_NOTIMPL == SLANG_E_NOT_IMPLEMENTED); SLANG_COMPILE_TIME_ASSERT(E_INVALIDARG == SLANG_E_INVALID_ARG); SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); +/* static */SlangResult PlatformUtil::getInstancePath(StringBuilder& out) +{ + wchar_t path[_MAX_PATH]; + ::GetModuleFileName(::GetModuleHandle(NULL), path, SLANG_COUNT_OF(path)); + String pathString = String::fromWString(path); + + // We don't want the instance name, just the path to it + out.Clear(); + out.append(Path::getParentDirectory(pathString)); + + return out.getLength() > 0 ? SLANG_OK : SLANG_FAIL; +} + /* static */SlangResult PlatformUtil::appendResult(SlangResult res, StringBuilder& builderOut) { if (SLANG_FAILED(res) && res != SLANG_FAIL) @@ -142,6 +155,13 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); #else // _WIN32 +/* static */SlangResult PlatformUtil::getInstancePath(StringBuilder& out) +{ + // On non Windows it's typically hard to get the instance path, so we'll say not implemented. + // The meaning is also somewhat more ambiguous - is it the exe or the shared library path? + return SLANG_E_NOT_IMPLEMENTED; +} + /* static */SlangResult PlatformUtil::appendResult(SlangResult res, StringBuilder& builderOut) { return SLANG_E_NOT_IMPLEMENTED; @@ -260,4 +280,6 @@ static const PlatformFlags s_familyFlags[int(PlatformFamily::CountOf)] = return s_familyFlags[int(family)]; } + + } |
