Skip to content

Commit

Permalink
8260335: [macos] Running app using relative path causes problems
Browse files Browse the repository at this point in the history
Reviewed-by: almatvee, kizune
  • Loading branch information
Andy Herrick committed Feb 4, 2021
1 parent f7a6cff commit c1dea39
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/jdk.jpackage/share/native/common/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include "FileUtils.h"


namespace FileUtils {

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


tstring dirname(const tstring &path) {
tstring::size_type pos = path.find_last_of(_T("\\/"));
tstring::size_type pos;
if (tstrings::endsWith(path, _T("/.")) || tstrings::endsWith(path, _T("\\."))) {
// this method is really getparent dirname - if the path ends with "/.",
// we need to ignore that when looking for the last "/" to find parent
pos = (path.substr(0, path.length() - 2)).find_last_of(_T("\\/"));
} else {
pos = path.find_last_of(_T("\\/"));
}

if (pos != tstring::npos) {
pos = path.find_last_not_of(_T("\\/"), pos); // skip trailing slashes
}
Expand Down

0 comments on commit c1dea39

Please sign in to comment.