FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) { FileLocation *result = nullptr; switch (constructor) { case 0x53d69076: result = new TL_fileLocation(); break; case 0x7c596b46: result = new TL_fileLocationUnavailable(); break; case 0x55555554: result = new TL_fileEncryptedLocation(); break; default: error = true; DEBUG_E("can't parse magic %x in FileLocation", constructor); return nullptr; } result->readParams(stream, instanceNum, error); return result; }
/** * If we are pre-loading XPTs, this method may do nothing because the * console service is not initialized. */ void LogMessageWithContext(FileLocation& aFile, uint32_t aLineNumber, const char* aMsg, ...) { va_list args; va_start(args, aMsg); AutoPR_smprintf_free formatted(PR_vsmprintf(aMsg, args)); va_end(args); if (!formatted) { return; } if (!nsComponentManagerImpl::gComponentManager) { return; } nsCString file; aFile.GetURIString(file); nsCOMPtr<nsIScriptError> error = do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); if (!error) { // This can happen early in component registration. Fall back to a // generic console message. LogMessage("Warning: in '%s', line %i: %s", file.get(), aLineNumber, (char*)formatted); return; } nsCOMPtr<nsIConsoleService> console = do_GetService(NS_CONSOLESERVICE_CONTRACTID); if (!console) { return; } nsresult rv = error->Init(NS_ConvertUTF8toUTF16(formatted), NS_ConvertUTF8toUTF16(file), EmptyString(), aLineNumber, 0, nsIScriptError::warningFlag, "chrome registration"); if (NS_FAILED(rv)) { return; } console->LogMessage(error); }
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); } } }
void MenuWidget::onAcSetTrigged() { FileLocation* pFileLoc = new FileLocation; pFileLoc->exec(); }