- Api nsILocalFile::AppendRelativePath() added to interface

- nsILocalFile::Append() returns error uniformly on all platforms if
more than one component of path is being appended.
This commit is contained in:
dp@netscape.com
2000-05-05 05:47:32 +00:00
parent 28ef04e815
commit 53f1fe2699
5 changed files with 63 additions and 6 deletions

View File

@@ -417,6 +417,28 @@ nsLocalFile::Append(const char *fragment)
{
NS_ENSURE_ARG(fragment);
CHECK_mPath();
// only one component of path can be appended
if (strstr(fragment, "/") != nsnull)
{
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
}
return AppendRelativePath(fragment);
}
NS_IMETHODIMP
nsLocalFile::AppendRelativePath(const char *fragment)
{
NS_ENSURE_ARG(fragment);
CHECK_mPath();
// Cannot start with a '/' and no .. allowed in the fragment
if ((*fragment == '/') || (strstr(fragment, "..") != nsnull))
{
return NS_ERROR_FILE_UNRECOGNIZED_PATH;
}
char * newPath = (char *)nsAllocator::Alloc(strlen(mPath) +
strlen(fragment) + 2);
if (!newPath)