diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2016-03-11 00:09:13 +0300 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2016-03-11 20:44:47 +0300 |
commit | 096c82deabf1e3fbe6b5f794b7a2e5c250b48ead (patch) | |
tree | c7143265a9f093eacf4c16867411294c5ab5e00b /src/Native/Runtime/RhConfig.cpp | |
parent | 654002d3cd76aa9f302257cb47791f1c806819a6 (diff) |
Implement PalGetModuleFileName for Unix
This change implements PalGetModuleFileName for Unix. Since the module name
passed to us is a utf-8 string, I have modified the signature of the function
to use TCHAR and then modified managed RhGetModuleFileName interop signature
to use byte* for Unix instead of char*. And I have also modified the called
of this function, the TryGetFullPathToApplicationModule, to perform
conversion of that to regular string.
Diffstat (limited to 'src/Native/Runtime/RhConfig.cpp')
-rw-r--r-- | src/Native/Runtime/RhConfig.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/Native/Runtime/RhConfig.cpp b/src/Native/Runtime/RhConfig.cpp index 2fa93a9a8..a87799041 100644 --- a/src/Native/Runtime/RhConfig.cpp +++ b/src/Native/Runtime/RhConfig.cpp @@ -221,50 +221,45 @@ void RhConfig::ReadConfigIni() //returns the path to the runtime configuration ini _Ret_maybenull_z_ TCHAR* RhConfig::GetConfigPath() { - TCHAR* exePathBuff; + const TCHAR* exePathBuff; //get the path to rhconfig.ini, this file is expected to live along side the app //to build the path get the process executable module full path strip off the file name and //append rhconfig.ini -#ifdef PLATFORM_UNIX - // UNIXTODO: Implement RhConfig::GetConfigPath! - Int32 pathLen = 0; exePathBuff = NULL; -#else Int32 pathLen = PalGetModuleFileName(&exePathBuff, NULL); -#endif if (pathLen <= 0) { return NULL; } - UInt32 iLastBackslash = 0; + UInt32 iLastDirSeparator = 0; for (UInt32 iPath = pathLen - 1; iPath > 0; iPath--) { - if (exePathBuff[iPath] == '\\') + if (exePathBuff[iPath] == DIRECTORY_SEPARATOR_CHAR) { - iLastBackslash = iPath; + iLastDirSeparator = iPath; break; } } - if (iLastBackslash == 0) + if (iLastDirSeparator == 0) { return NULL; } - TCHAR* configPath = new (nothrow) TCHAR[iLastBackslash + 1 + wcslen(CONFIG_INI_FILENAME) + 1]; + TCHAR* configPath = new (nothrow) TCHAR[iLastDirSeparator + 1 + wcslen(CONFIG_INI_FILENAME) + 1]; if (configPath != NULL) { //copy the path base and file name - for (UInt32 i = 0; i <= iLastBackslash; i++) + for (UInt32 i = 0; i <= iLastDirSeparator; i++) { configPath[i] = exePathBuff[i]; } for (UInt32 i = 0; i <= wcslen(CONFIG_INI_FILENAME); i++) { - configPath[i + iLastBackslash + 1] = CONFIG_INI_FILENAME[i]; + configPath[i + iLastDirSeparator + 1] = CONFIG_INI_FILENAME[i]; } } |