AAPT2: improve some error messages

Test: manual
Change-Id: I11c96f8c825ffd43b7f68cb24f2c0746d75845f5
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 5adf04a..cc1cd5c 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -145,7 +145,7 @@
   const std::string& root_dir = options.res_dir.value();
   std::unique_ptr<DIR, decltype(closedir)*> d(opendir(root_dir.data()), closedir);
   if (!d) {
-    context->GetDiagnostics()->Error(DiagMessage()
+    context->GetDiagnostics()->Error(DiagMessage(root_dir) << "failed to open directory: "
                                      << android::base::SystemErrorCodeToString(errno));
     return false;
   }
@@ -164,7 +164,7 @@
 
     std::unique_ptr<DIR, decltype(closedir)*> subdir(opendir(prefix_path.data()), closedir);
     if (!subdir) {
-      context->GetDiagnostics()->Error(DiagMessage()
+      context->GetDiagnostics()->Error(DiagMessage(prefix_path) << "failed to open directory: "
                                        << android::base::SystemErrorCodeToString(errno));
       return false;
     }
@@ -180,7 +180,7 @@
       std::string err_str;
       Maybe<ResourcePathData> path_data = ExtractResourcePathData(full_path, &err_str);
       if (!path_data) {
-        context->GetDiagnostics()->Error(DiagMessage() << err_str);
+        context->GetDiagnostics()->Error(DiagMessage(full_path) << err_str);
         return false;
       }
 
@@ -198,6 +198,7 @@
     std::ifstream fin(path_data.source.path, std::ifstream::binary);
     if (!fin) {
       context->GetDiagnostics()->Error(DiagMessage(path_data.source)
+                                       << "failed to open file: "
                                        << android::base::SystemErrorCodeToString(errno));
       return false;
     }
@@ -395,6 +396,7 @@
     std::ifstream fin(path_data.source.path, std::ifstream::binary);
     if (!fin) {
       context->GetDiagnostics()->Error(DiagMessage(path_data.source)
+                                       << "failed to open file: "
                                        << android::base::SystemErrorCodeToString(errno));
       return false;
     }
@@ -480,6 +482,7 @@
     std::string content;
     if (!android::base::ReadFileToString(path_data.source.path, &content)) {
       context->GetDiagnostics()->Error(DiagMessage(path_data.source)
+                                       << "failed to open file: "
                                        << android::base::SystemErrorCodeToString(errno));
       return false;
     }