AAPT2: Move all file output to FileOutputStream

FileOutputStream is safe to use on Windows, as it opens
files using our compatibility API.

Bug: 68262818
Test: make aapt2_tests
Change-Id: Ib0b27e93edd609b49b1327db7d9867a002198ebb
This commit is contained in:
Adam Lesinski
2017-11-09 11:29:39 -08:00
parent 60303333dc
commit a693c4a32e
20 changed files with 356 additions and 287 deletions

View File

@@ -23,6 +23,7 @@
#include "text/Utf8Iterator.h"
#include "util/Util.h"
using ::aapt::text::Printer;
using ::aapt::text::Utf8Iterator;
using ::android::StringPiece;
@@ -109,23 +110,22 @@ void AnnotationProcessor::AppendNewLine() {
}
}
void AnnotationProcessor::WriteToStream(const StringPiece& prefix, std::ostream* out) const {
void AnnotationProcessor::Print(Printer* printer) const {
if (has_comments_) {
std::string result = comment_.str();
for (StringPiece line : util::Tokenize(result, '\n')) {
*out << prefix << line << "\n";
printer->Println(line);
}
*out << prefix << " */"
<< "\n";
printer->Println(" */");
}
if (annotation_bit_mask_ & AnnotationRule::kDeprecated) {
*out << prefix << "@Deprecated\n";
printer->Println("@Deprecated");
}
for (const AnnotationRule& rule : sAnnotationRules) {
if (annotation_bit_mask_ & rule.bit_mask) {
*out << prefix << rule.annotation << "\n";
printer->Println(rule.annotation);
}
}
}