Skip to content
Permalink
Browse files
8260335: [macos] Running app using relative path causes problems
Reviewed-by: almatvee, kizune
  • Loading branch information
Andy Herrick committed Feb 4, 2021
1 parent f7a6cff commit c1dea39d08e3a9af03430b603e24192a02cde223
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/jdk.jpackage/share/native/common/FileUtils.cpp
@@ -28,7 +28,6 @@

#include "FileUtils.h"


namespace FileUtils {

#ifdef _WIN32
@@ -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
}

0 comments on commit c1dea39

Please sign in to comment.