summaryrefslogtreecommitdiff
path: root/tools/aapt2/link/Link.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/aapt2/link/Link.cpp')
-rw-r--r--tools/aapt2/link/Link.cpp37
1 files changed, 29 insertions, 8 deletions
diff --git a/tools/aapt2/link/Link.cpp b/tools/aapt2/link/Link.cpp
index 5003d9658525..418a802983c3 100644
--- a/tools/aapt2/link/Link.cpp
+++ b/tools/aapt2/link/Link.cpp
@@ -729,12 +729,18 @@ public:
std::string outPath = mOptions.generateJavaClassPath.value();
file::appendPath(&outPath, file::packageToPath(util::utf16ToUtf8(outPackage)));
- file::mkdirs(outPath);
+ if (!file::mkdirs(outPath)) {
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed to create directory '" << outPath << "'");
+ return false;
+ }
+
file::appendPath(&outPath, "R.java");
std::ofstream fout(outPath, std::ofstream::binary);
if (!fout) {
- mContext->getDiagnostics()->error(DiagMessage() << strerror(errno));
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno));
return false;
}
@@ -743,6 +749,11 @@ public:
mContext->getDiagnostics()->error(DiagMessage(outPath) << generator.getError());
return false;
}
+
+ if (!fout) {
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno));
+ }
return true;
}
@@ -754,12 +765,18 @@ public:
std::string outPath = mOptions.generateJavaClassPath.value();
file::appendPath(&outPath,
file::packageToPath(util::utf16ToUtf8(mContext->getCompilationPackage())));
- file::mkdirs(outPath);
+ if (!file::mkdirs(outPath)) {
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed to create directory '" << outPath << "'");
+ return false;
+ }
+
file::appendPath(&outPath, "Manifest.java");
std::ofstream fout(outPath, std::ofstream::binary);
if (!fout) {
- mContext->getDiagnostics()->error(DiagMessage() << strerror(errno));
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno));
return false;
}
@@ -770,7 +787,8 @@ public:
}
if (!fout) {
- mContext->getDiagnostics()->error(DiagMessage() << strerror(errno));
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno));
return false;
}
return true;
@@ -781,15 +799,18 @@ public:
return true;
}
- std::ofstream fout(mOptions.generateProguardRulesPath.value(), std::ofstream::binary);
+ const std::string& outPath = mOptions.generateProguardRulesPath.value();
+ std::ofstream fout(outPath, std::ofstream::binary);
if (!fout) {
- mContext->getDiagnostics()->error(DiagMessage() << strerror(errno));
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed to open '" << outPath << "': " << strerror(errno));
return false;
}
proguard::writeKeepSet(&fout, keepSet);
if (!fout) {
- mContext->getDiagnostics()->error(DiagMessage() << strerror(errno));
+ mContext->getDiagnostics()->error(
+ DiagMessage() << "failed writing to '" << outPath << "': " << strerror(errno));
return false;
}
return true;