From 506855911108bb73e8c5a28aacf9628b36b90a00 Mon Sep 17 00:00:00 2001 From: "sspitzer%netscape.com" Date: Tue, 14 Sep 1999 00:08:33 +0000 Subject: [PATCH] fix for #13704. also, instead of just checking that ".msf" or ".snm" or ".summary" appears in th e file name, we now check if the filename *ends* with ".msf", ".snm" or ".summar y". --- profile/pref-migrator/src/nsPrefMigration.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/profile/pref-migrator/src/nsPrefMigration.cpp b/profile/pref-migrator/src/nsPrefMigration.cpp index 304b48e99f11..92fd95383999 100644 --- a/profile/pref-migrator/src/nsPrefMigration.cpp +++ b/profile/pref-migrator/src/nsPrefMigration.cpp @@ -47,6 +47,7 @@ #else #define SUMMARY_SUFFIX_IN_4x ".snm" #endif /* XP_UNIX */ +#define SUMMARY_SUFFIX_IN_5x ".msf" #define PREMIGRATION_PREFIX "premigration" #define PREF_MAIL_DIRECTORY "mail.directory" @@ -622,7 +623,22 @@ nsPrefMigration::GetDirFromPref(const char *oldProfilePath, const char* newProfi } +static PRBool +nsStringEndsWith(nsString& name, const char *ending) +{ + if (!ending) return PR_FALSE; + PRInt32 len = name.Length(); + if (len == 0) return PR_FALSE; + + PRInt32 endingLen = PL_strlen(ending); + if (len > endingLen && name.RFind(ending, PR_TRUE) == len - endingLen) { + return PR_TRUE; + } + else { + return PR_FALSE; + } +} /*--------------------------------------------------------------------------------- * GetSizes reads the 4.x files in the profile tree and accumulates their sizes * @@ -646,7 +662,7 @@ nsPrefMigration::GetSizes(nsFileSpec inputPath, PRBool readSubdirs, PRUint32 *si folderName = fileOrDirName.GetLeafName(); fileOrDirNameStr = folderName; len = fileOrDirNameStr.Length(); - if (fileOrDirNameStr.Find(SUMMARY_SUFFIX_IN_4x, PR_TRUE) != -1) /* Don't copy the summary files */ + if (nsStringEndsWith(fileOrDirNameStr, SUMMARY_SUFFIX_IN_4x) || nsStringEndsWith(fileOrDirNameStr, SUMMARY_SUFFIX_IN_5x)) /* Don't copy the summary files */ continue; else { @@ -753,7 +769,7 @@ nsPrefMigration::DoTheCopy(nsFileSpec oldPath, nsFileSpec newPath, PRBool readSu folderName = fileOrDirName.GetLeafName(); //get the filename without the full path fileOrDirNameStr = folderName; - if (fileOrDirNameStr.Find(SUMMARY_SUFFIX_IN_4x, PR_TRUE) != -1) /* Don't copy the summary files */ + if (nsStringEndsWith(fileOrDirNameStr, SUMMARY_SUFFIX_IN_4x) || nsStringEndsWith(fileOrDirNameStr, SUMMARY_SUFFIX_IN_5x)) /* Don't copy the summary files */ continue; else { @@ -932,4 +948,3 @@ nsPrefMigration::OnShutdown(const nsCID& aClass, nsISupports *service) return NS_OK; } -