@@ -15,10 +15,13 @@ limitations under the License.
1515
1616#include " research/carls/base/file_helper.h"
1717
18+ #include < string>
19+
1820#include " absl/status/status.h"
1921#include " absl/strings/string_view.h"
2022#include " research/carls/base/status_helper.h"
2123#include " tensorflow/core/platform/env.h"
24+ #include " tensorflow/core/public/version.h"
2225
2326namespace carls {
2427namespace internal {
@@ -66,8 +69,13 @@ absl::Status ReadFileString(const std::string& filepath, std::string* output) {
6669 auto tf_status = env->NewReadOnlyMemoryRegionFromFile (filepath, &file);
6770 if (!tf_status.ok ()) {
6871 return absl::Status (absl::StatusCode::kInternal ,
72+ #if TF_GRAPH_DEF_VERSION < 1467
6973 absl::StrCat (" Reading file failed with error:" ,
7074 tf_status.error_message ()));
75+ #else
76+ absl::StrCat (" Reading file failed with error:" ,
77+ tf_status.message ()));
78+ #endif
7179 }
7280 *output = std::string (static_cast <const char *>(file->data ()), file->length ());
7381 return absl::OkStatus ();
@@ -84,20 +92,35 @@ absl::Status WriteFileString(const std::string& filepath,
8492 auto tf_status = env->NewWritableFile (filepath, &file);
8593 if (!tf_status.ok ()) {
8694 return absl::Status (absl::StatusCode::kInternal ,
95+ #if TF_GRAPH_DEF_VERSION < 1467
8796 absl::StrCat (" Creating file failed with error:" ,
8897 tf_status.error_message ()));
98+ #else
99+ absl::StrCat (" Creating file failed with error:" ,
100+ tf_status.message ()));
101+ #endif
89102 }
90103 tf_status = file->Append (content);
91104 if (!tf_status.ok ()) {
92105 return absl::Status (absl::StatusCode::kInternal ,
106+ #if TF_GRAPH_DEF_VERSION < 1467
93107 absl::StrCat (" Appending file failed with error:" ,
94108 tf_status.error_message ()));
109+ #else
110+ absl::StrCat (" Appending file failed with error:" ,
111+ tf_status.message ()));
112+ #endif
95113 }
96114 tf_status = file->Close ();
97115 if (!tf_status.ok ()) {
98116 return absl::Status (absl::StatusCode::kInternal ,
117+ #if TF_GRAPH_DEF_VERSION < 1467
99118 absl::StrCat (" Closing file failed with error:" ,
100119 tf_status.error_message ()));
120+ #else
121+ absl::StrCat (" Closing file failed with error:" ,
122+ tf_status.message ()));
123+ #endif
101124 }
102125 return absl::OkStatus ();
103126}
0 commit comments