Skip to content

Commit f11f666

Browse files
committed
os: normalize execPath.
1 parent bff9a9f commit f11f666

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

fibjs/src/os/os_freebsd.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <sys/sysctl.h>
2222
#include <vm/vm_param.h>
2323
#include <stdlib.h>
24+
#include "path.h"
2425

2526
#undef NANOSEC
2627
#define NANOSEC ((uint64_t)1e9)
@@ -234,8 +235,8 @@ result_t os_base::get_execPath(exlib::string& retVal)
234235

235236
if (sysctl(mib, 4, exeName, &size, NULL, 0) < 0)
236237
return CHECK_ERROR(LastError());
238+
path_base::normalize(exeName, retVal);
237239

238-
retVal = exeName;
239240
return 0;
240241
}
241242

fibjs/src/os/os_linux.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <sys/sysinfo.h>
1616
#include <sys/param.h>
1717
#include <string.h>
18+
#include "path.h"
1819

1920
#ifndef CLOCK_BOOTTIME
2021
#define CLOCK_BOOTTIME 7
@@ -208,8 +209,8 @@ result_t os_base::get_execPath(exlib::string& retVal)
208209

209210
if (readlink("/proc/self/exe", exeName, linksize) == -1)
210211
return CHECK_ERROR(LastError());
212+
path_base::normalize(exeName, retVal);
211213

212-
retVal = exeName;
213214
return 0;
214215
}
215216

fibjs/src/os/os_osx.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <mach/mach.h>
1515
#include <mach-o/dyld.h>
1616
#include <sys/sysctl.h>
17+
#include "path.h"
1718

1819
namespace fibjs {
1920

@@ -171,8 +172,7 @@ result_t os_base::get_execPath(exlib::string& retVal)
171172
uint32_t size = sizeof(exeName);
172173

173174
_NSGetExecutablePath(exeName, &size);
174-
175-
retVal = exeName;
175+
path_base::normalize(exeName, retVal);
176176
return 0;
177177
}
178178

fibjs/src/os/os_win.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ result_t os_base::get_execPath(exlib::string& retVal)
547547
exlib::wchar szFileName[MAX_PATH];
548548

549549
GetModuleFileNameW(NULL, szFileName, MAX_PATH);
550-
retVal = utf16to8String(szFileName);
550+
path_base::normalize(utf16to8String(szFileName), retVal);
551551
return 0;
552552
}
553553

0 commit comments

Comments
 (0)