From 7910e844e29c90af883f1bc3e94d97e0f992f507 Mon Sep 17 00:00:00 2001 From: "mcmullen%netscape.com" Date: Mon, 19 Apr 1999 22:07:42 +0000 Subject: [PATCH] Fixed GetParent() on windows and unix (was incorrect for directories whose paths end in a separator). --- base/src/unix/nsFileSpecUnix.cpp | 1 + base/src/windows/nsFileSpecWin.cpp | 1 + xpcom/io/nsFileSpecUnix.cpp | 1 + xpcom/io/nsFileSpecWin.cpp | 1 + 4 files changed, 4 insertions(+) diff --git a/base/src/unix/nsFileSpecUnix.cpp b/base/src/unix/nsFileSpecUnix.cpp index faf6b8db1202..a443efec51b6 100644 --- a/base/src/unix/nsFileSpecUnix.cpp +++ b/base/src/unix/nsFileSpecUnix.cpp @@ -178,6 +178,7 @@ void nsFileSpec::GetParent(nsFileSpec& outSpec) const //---------------------------------------------------------------------------------------- { outSpec.mPath = mPath; + outSpec.mPath[outSpec.mPath.Length() - 1] = '\0'; // avoid trailing separator, if any char* cp = strrchr(outSpec.mPath, '/'); if (cp++) *cp = '\0'; diff --git a/base/src/windows/nsFileSpecWin.cpp b/base/src/windows/nsFileSpecWin.cpp index 074252b974d9..fab53f3bc3ec 100644 --- a/base/src/windows/nsFileSpecWin.cpp +++ b/base/src/windows/nsFileSpecWin.cpp @@ -222,6 +222,7 @@ void nsFileSpec::GetParent(nsFileSpec& outSpec) const //---------------------------------------------------------------------------------------- { outSpec.mPath = mPath; + outSpec.mPath[outSpec.mPath.Length() - 1] = '\0';; // avoid trailing separator, if any char* cp = strrchr(outSpec.mPath, '\\'); if (cp++) *cp = '\0'; diff --git a/xpcom/io/nsFileSpecUnix.cpp b/xpcom/io/nsFileSpecUnix.cpp index faf6b8db1202..a443efec51b6 100644 --- a/xpcom/io/nsFileSpecUnix.cpp +++ b/xpcom/io/nsFileSpecUnix.cpp @@ -178,6 +178,7 @@ void nsFileSpec::GetParent(nsFileSpec& outSpec) const //---------------------------------------------------------------------------------------- { outSpec.mPath = mPath; + outSpec.mPath[outSpec.mPath.Length() - 1] = '\0'; // avoid trailing separator, if any char* cp = strrchr(outSpec.mPath, '/'); if (cp++) *cp = '\0'; diff --git a/xpcom/io/nsFileSpecWin.cpp b/xpcom/io/nsFileSpecWin.cpp index 074252b974d9..fab53f3bc3ec 100644 --- a/xpcom/io/nsFileSpecWin.cpp +++ b/xpcom/io/nsFileSpecWin.cpp @@ -222,6 +222,7 @@ void nsFileSpec::GetParent(nsFileSpec& outSpec) const //---------------------------------------------------------------------------------------- { outSpec.mPath = mPath; + outSpec.mPath[outSpec.mPath.Length() - 1] = '\0';; // avoid trailing separator, if any char* cp = strrchr(outSpec.mPath, '\\'); if (cp++) *cp = '\0';