More WriteAttr -> WriteAttrString cleanup across the tree.

Some of these were correct as they were ... but most weren't.
There are a variety of other correct ones I didn't change over yet
that someone else probably should (GCI task?).
This commit is contained in:
Augustin Cavalier
2018-11-11 16:22:10 -05:00
parent 5f5cc39c2c
commit 05f730b0f8
6 changed files with 21 additions and 24 deletions
@@ -1,7 +1,7 @@
/*
** Copyright 2009 Adrien Destugues, [email protected]. All rights reserved.
** Distributed under the terms of the MIT License.
*/
* Copyright 2009 Adrien Destugues, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <PlainTextCatalog.h>
@@ -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) {
@@ -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;
@@ -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));
+3 -2
View File
@@ -23,6 +23,7 @@
#include <Path.h>
#include <Resources.h>
#include <Roster.h>
#include <String.h>
#include <TextView.h>
#include <TranslationUtils.h>
#include <TranslatorFormats.h>
@@ -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
+2 -1
View File
@@ -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
}
+4 -2
View File
@@ -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;
}