Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit c1dea39

Browse files
author
Andy Herrick
committedFeb 4, 2021
8260335: [macos] Running app using relative path causes problems
Reviewed-by: almatvee, kizune
1 parent f7a6cff commit c1dea39

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed
 

‎src/jdk.jpackage/share/native/common/FileUtils.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include "FileUtils.h"
3030

31-
3231
namespace FileUtils {
3332

3433
#ifdef _WIN32
@@ -54,7 +53,15 @@ bool isDirSeparator(const tstring::value_type c) {
5453

5554

5655
tstring dirname(const tstring &path) {
57-
tstring::size_type pos = path.find_last_of(_T("\\/"));
56+
tstring::size_type pos;
57+
if (tstrings::endsWith(path, _T("/.")) || tstrings::endsWith(path, _T("\\."))) {
58+
// this method is really getparent dirname - if the path ends with "/.",
59+
// we need to ignore that when looking for the last "/" to find parent
60+
pos = (path.substr(0, path.length() - 2)).find_last_of(_T("\\/"));
61+
} else {
62+
pos = path.find_last_of(_T("\\/"));
63+
}
64+
5865
if (pos != tstring::npos) {
5966
pos = path.find_last_not_of(_T("\\/"), pos); // skip trailing slashes
6067
}

0 commit comments

Comments
 (0)
This repository has been archived.