FileLocation::FileLocation(const FileLocation &file, const char *path) { if (file.IsZip()) { if (file.mBaseFile) { Init(file.mBaseFile, file.mPath.get()); } else { Init(file.mBaseZip, file.mPath.get()); } if (path) { PRInt32 i = mPath.RFindChar('/'); if (kNotFound == i) { mPath.Truncate(0); } else { mPath.Truncate(i + 1); } mPath += path; } } else { if (path) { nsCOMPtr<nsIFile> cfile; file.mBaseFile->GetParent(getter_AddRefs(cfile)); nsCOMPtr<nsILocalFile> clfile = do_QueryInterface(cfile); #if defined(XP_WIN) || defined(XP_OS2) nsCAutoString pathStr(path); char *p; PRUint32 len = pathStr.GetMutableData(&p); for (; len; ++p, --len) { if ('/' == *p) { *p = '\\'; } } clfile->AppendRelativeNativePath(pathStr); #else clfile->AppendRelativeNativePath(nsDependentCString(path)); #endif Init(clfile); } else { Init(file.mBaseFile); } } }
FileLocation::FileLocation(const FileLocation& aFile, const char* aPath) { if (aFile.IsZip()) { if (aFile.mBaseFile) { Init(aFile.mBaseFile, aFile.mPath.get()); } else { Init(aFile.mBaseZip, aFile.mPath.get()); } if (aPath) { int32_t i = mPath.RFindChar('/'); if (kNotFound == i) { mPath.Truncate(0); } else { mPath.Truncate(i + 1); } mPath += aPath; } } else { if (aPath) { nsCOMPtr<nsIFile> cfile; aFile.mBaseFile->GetParent(getter_AddRefs(cfile)); #if defined(XP_WIN) nsAutoCString pathStr(aPath); char* p; uint32_t len = pathStr.GetMutableData(&p); for (; len; ++p, --len) { if ('/' == *p) { *p = '\\'; } } cfile->AppendRelativeNativePath(pathStr); #else cfile->AppendRelativeNativePath(nsDependentCString(aPath)); #endif Init(cfile); } else { Init(aFile.mBaseFile); } } }