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

@@ -17,16 +17,16 @@
#ifndef AAPT_JAVA_CLASS_GENERATOR_H
#define AAPT_JAVA_CLASS_GENERATOR_H
#include <ostream>
#include <string>
#include "androidfw/StringPiece.h"
#include "ResourceTable.h"
#include "ResourceValues.h"
#include "androidfw/StringPiece.h"
#include "io/Io.h"
#include "process/IResourceTableConsumer.h"
#include "process/SymbolTable.h"
#include "text/Printer.h"
namespace aapt {
@@ -70,14 +70,14 @@ class JavaClassGenerator {
// All symbols technically belong to a single package, but linked libraries will
// have their names mangled, denoting that they came from a different package.
// We need to generate these symbols in a separate file. Returns true on success.
bool Generate(const android::StringPiece& package_name_to_generate, std::ostream* out,
std::ostream* out_r_txt = nullptr);
bool Generate(const android::StringPiece& package_name_to_generate, io::OutputStream* out,
io::OutputStream* out_r_txt = nullptr);
bool Generate(const android::StringPiece& package_name_to_generate,
const android::StringPiece& output_package_name, std::ostream* out,
std::ostream* out_r_txt = nullptr);
const android::StringPiece& output_package_name, io::OutputStream* out,
io::OutputStream* out_r_txt = nullptr);
const std::string& getError() const;
const std::string& GetError() const;
static std::string TransformToFieldName(const android::StringPiece& symbol);
@@ -94,13 +94,13 @@ class JavaClassGenerator {
bool ProcessType(const android::StringPiece& package_name_to_generate,
const ResourceTablePackage& package, const ResourceTableType& type,
ClassDefinition* out_type_class_def, MethodDefinition* out_rewrite_method_def,
std::ostream* out_r_txt);
text::Printer* r_txt_printer);
// Writes a resource to the R.java file, optionally writing out a rewrite rule for its package
// ID if `out_rewrite_method` is not nullptr.
void ProcessResource(const ResourceNameRef& name, const ResourceId& id,
const ResourceEntry& entry, ClassDefinition* out_class_def,
MethodDefinition* out_rewrite_method, std::ostream* out_r_txt);
MethodDefinition* out_rewrite_method, text::Printer* r_txt_printer);
// Writes a styleable resource to the R.java file, optionally writing out a rewrite rule for
// its package ID if `out_rewrite_method` is not nullptr.
@@ -109,7 +109,7 @@ class JavaClassGenerator {
const Styleable& styleable,
const android::StringPiece& package_name_to_generate,
ClassDefinition* out_class_def, MethodDefinition* out_rewrite_method,
std::ostream* out_r_txt);
text::Printer* r_txt_printer);
IAaptContext* context_;
ResourceTable* table_;
@@ -117,7 +117,7 @@ class JavaClassGenerator {
std::string error_;
};
inline const std::string& JavaClassGenerator::getError() const {
inline const std::string& JavaClassGenerator::GetError() const {
return error_;
}