Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NS_IMETHODIMP nsEffectiveTLDService::Observe(nsISupports* aSubject,
- const char* aTopic,
- const char16_t* aData) {
- if (nsCRT::strcmp(aTopic, "public-suffix-list-updated") == 0) {
- nsCOMPtr<nsIFile> mDAFSABinFile;
- nsresult rv;
- mDAFSABinFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
- if (mDAFSABinFile) {
- rv = mDAFSABinFile->InitWithPath(nsDependentString(aData));
- nsCOMPtr<nsIInputStream> inputStream;
- rv = NS_NewLocalFileInputStream(getter_AddRefs(inputStream),
- mDAFSABinFile);
- if (rv != NS_ERROR_FILE_NOT_FOUND) {
- uint64_t length = 0;
- rv = inputStream->Available(&length);
- std::cout << length << "\n\n"; // For debugging, to be removed
- unsigned char kDafsaRemote[length];
- while (1) {
- uint32_t count;
- rv = inputStream->Read((char*)kDafsaRemote, length, &count);
- NS_ENSURE_SUCCESS(rv, rv);
- // We reached the end of the file.
- if (count == 0) {
- break;
- }
- }
- inputStream->Close();
- for (auto k : kDafsaRemote) {
- std::cout << (int)k << "\n"; // For debugging, to be removed
- }
- nsEffectiveTLDService::mGraph = mozilla::Dafsa(kDafsaRemote);
- }
- }
- }
- return NS_OK;
- }
Add Comment
Please, Sign In to add comment