diff --git a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp index d79459597a..93e7928ed9 100644 --- a/src/add-ons/locale/catalogs/plaintext/Catalog.cpp +++ b/src/add-ons/locale/catalogs/plaintext/Catalog.cpp @@ -1,7 +1,7 @@ /* -** Copyright 2009 Adrien Destugues, pulkomandy@gmail.com. All rights reserved. -** Distributed under the terms of the MIT License. -*/ + * Copyright 2009 Adrien Destugues, pulkomandy@gmail.com. All rights reserved. + * Distributed under the terms of the MIT License. + */ #include @@ -354,16 +354,12 @@ PlainTextCatalog::UpdateAttributes(BFile& catalogFile) kCatMimeType, strlen(kCatMimeType)+1); } if (catalogFile.ReadAttr(BLocaleRoster::kCatLangAttr, B_STRING_TYPE, 0, - &buf, bufSize) <= 0 - || fLanguageName != buf) { - catalogFile.WriteAttr(BLocaleRoster::kCatLangAttr, B_STRING_TYPE, 0, - fLanguageName.String(), fLanguageName.Length()+1); + &buf, bufSize) <= 0 || fLanguageName != buf) { + catalogFile.WriteAttrString(BLocaleRoster::kCatLangAttr, &fLanguageName); } if (catalogFile.ReadAttr(BLocaleRoster::kCatSigAttr, B_STRING_TYPE, 0, - &buf, bufSize) <= 0 - || fSignature != buf) { - catalogFile.WriteAttr(BLocaleRoster::kCatSigAttr, B_STRING_TYPE, 0, - fSignature.String(), fSignature.Length()+1); + &buf, bufSize) <= 0 || fSignature != buf) { + catalogFile.WriteAttrString(BLocaleRoster::kCatSigAttr, &fSignature); } if (catalogFile.ReadAttr(BLocaleRoster::kCatFingerprintAttr, B_UINT32_TYPE, 0, &temp, sizeof(uint32)) <= 0) { diff --git a/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp b/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp index f638628628..68549c0164 100644 --- a/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp +++ b/src/add-ons/mail_daemon/inbound_filters/spam_filter/SpamFilter.cpp @@ -125,11 +125,9 @@ SpamFilter::_CheckForSpam(BFile& file) delete[] stringBuffer; // write attributes - const char *classificationString; - classificationString = spamRatio >= fSpamCutoffRatio ? "Spam" + BString classificationString = spamRatio >= fSpamCutoffRatio ? "Spam" : spamRatio < fGenuineCutoffRatio ? "Genuine" : "Uncertain"; - file.WriteAttr("MAIL:classification", B_STRING_TYPE, 0 /* offset */, - classificationString, strlen(classificationString) + 1); + file.WriteAttrString("MAIL:classification", &classificationString); // Store the spam ratio in an attribute called MAIL:ratio_spam, // attached to the eventual output file. @@ -303,8 +301,7 @@ SpamFilter::_AddSpamToSubject(BNode& file, float spamRatio) newSubjectString << buffer; delete[] buffer; - if (file.WriteAttr("Subject", B_STRING_TYPE, 0, newSubjectString.String(), - newSubjectString.Length()) < 0) + if (file.WriteAttrString("Subject", &newSubjectString) < 0) return B_ERROR; return B_OK; diff --git a/src/add-ons/mail_daemon/inbound_protocols/pop3/POP3.cpp b/src/add-ons/mail_daemon/inbound_protocols/pop3/POP3.cpp index 75b95ddc84..0450630acf 100644 --- a/src/add-ons/mail_daemon/inbound_protocols/pop3/POP3.cpp +++ b/src/add-ons/mail_daemon/inbound_protocols/pop3/POP3.cpp @@ -228,8 +228,8 @@ POP3Protocol::SyncMessages() } ReportProgress(1, 0); - if (file.WriteAttr("MAIL:unique_id", B_STRING_TYPE, 0, uid, - strlen(uid)) < 0) + const BString uidStr(uid); + if (file.WriteAttrString("MAIL:unique_id", &uidStr) < 0) error = B_ERROR; file.WriteAttr("MAIL:size", B_INT32_TYPE, 0, &size, sizeof(int32)); diff --git a/src/kits/translation/TranslationUtils.cpp b/src/kits/translation/TranslationUtils.cpp index 3e7383ec40..00ca0794c2 100644 --- a/src/kits/translation/TranslationUtils.cpp +++ b/src/kits/translation/TranslationUtils.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -678,8 +679,8 @@ BTranslationUtils::WriteStyledEditFile(BTextView* view, BFile* file, const char outText += length; } while (sourceLength > 0); - file->WriteAttr("be:encoding", B_STRING_TYPE, 0, - encoding, strlen(encoding)); + BString encodingStr(encoding); + file->WriteAttrString("be:encoding", &encodingStr); } // truncate any extra text diff --git a/src/preferences/keymap/Keymap.cpp b/src/preferences/keymap/Keymap.cpp index 7dda76d6da..2da93a902e 100644 --- a/src/preferences/keymap/Keymap.cpp +++ b/src/preferences/keymap/Keymap.cpp @@ -185,7 +185,8 @@ Keymap::Save(const entry_ref& ref) } if (status == B_OK) { - file.WriteAttr("keymap:name", B_STRING_TYPE, 0, fName, strlen(fName)); + const BString name(fName); + file.WriteAttrString("keymap:name", &name); // Failing would be non-fatal } diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index 396bb0526d..0dc4ab46c6 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -330,8 +330,10 @@ InputServer::_SaveKeymap(bool isDefault) // don't bother reporting an error if this fails, since this isn't fatal // the keymap will still be functional, and will just be identified as (Current) in prefs instead of its // actual name - if (isDefault) - file.WriteAttr("keymap:name", B_STRING_TYPE, 0, kSystemKeymapName, strlen(kSystemKeymapName)); + if (isDefault) { + const BString systemKeymapName(kSystemKeymapName); + file.WriteAttrString("keymap:name", &systemKeymapName); + } return B_OK; }