Skip to content

Commit cba6085

Browse files
committed
fix: open files whose paths contain non-ascii characters
1 parent cf4c11d commit cba6085

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

third_party/mediapipe_workaround.diff

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/mediapipe/framework/output_stream_handler.cc b/mediapipe/framework/output_stream_handler.cc
2-
index e27d1c68..55f2f3bd 100644
2+
index e27d1c688..55f2f3bd3 100644
33
--- a/mediapipe/framework/output_stream_handler.cc
44
+++ b/mediapipe/framework/output_stream_handler.cc
55
@@ -143,9 +143,7 @@ OutputStreamHandler::GetMonitoringInfo() {
@@ -14,7 +14,7 @@ index e27d1c68..55f2f3bd 100644
1414
return monitoring_info_vector;
1515
}
1616
diff --git a/mediapipe/framework/port/opencv_core_inc.h b/mediapipe/framework/port/opencv_core_inc.h
17-
index 12862472..1a409417 100644
17+
index 128624725..1a4094173 100644
1818
--- a/mediapipe/framework/port/opencv_core_inc.h
1919
+++ b/mediapipe/framework/port/opencv_core_inc.h
2020
@@ -20,7 +20,7 @@
@@ -26,8 +26,44 @@ index 12862472..1a409417 100644
2626
#include <opencv2/cvconfig.h>
2727
#endif
2828

29+
diff --git a/mediapipe/tasks/cc/core/BUILD b/mediapipe/tasks/cc/core/BUILD
30+
index 9c53dcca7..b0d7283c1 100644
31+
--- a/mediapipe/tasks/cc/core/BUILD
32+
+++ b/mediapipe/tasks/cc/core/BUILD
33+
@@ -58,6 +58,7 @@ cc_library(
34+
srcs = ["external_file_handler.cc"],
35+
hdrs = ["external_file_handler.h"],
36+
deps = [
37+
+ "//mediapipe/framework/deps:platform_strings",
38+
"//mediapipe/framework/port:integral_types",
39+
"//mediapipe/framework/port:status",
40+
"//mediapipe/tasks/cc:common",
41+
diff --git a/mediapipe/tasks/cc/core/external_file_handler.cc b/mediapipe/tasks/cc/core/external_file_handler.cc
42+
index 069b904e9..d8b5e0364 100644
43+
--- a/mediapipe/tasks/cc/core/external_file_handler.cc
44+
+++ b/mediapipe/tasks/cc/core/external_file_handler.cc
45+
@@ -40,6 +40,7 @@ limitations under the License.
46+
#include "absl/strings/match.h"
47+
#include "absl/strings/str_format.h"
48+
#include "absl/strings/string_view.h"
49+
+#include "mediapipe/framework/deps/platform_strings.h"
50+
#include "mediapipe/framework/port/status_macros.h"
51+
#include "mediapipe/tasks/cc/common.h"
52+
#include "mediapipe/tasks/cc/core/proto/external_file.pb.h"
53+
@@ -124,7 +125,11 @@ absl::Status ExternalFileHandler::MapExternalFile() {
54+
if (!external_file_.file_name().empty()) {
55+
MP_ASSIGN_OR_RETURN(std::string file_name,
56+
PathToResourceAsFile(external_file_.file_name()));
57+
+#ifdef _WIN32
58+
+ owned_fd_ = _wopen(Utf8ToNative(file_name).c_str(), O_RDONLY | O_BINARY);
59+
+#else
60+
owned_fd_ = open(file_name.c_str(), O_RDONLY | O_BINARY);
61+
+#endif
62+
if (owned_fd_ < 0) {
63+
const std::string error_message = absl::StrFormat(
64+
"Unable to open file at %s", external_file_.file_name());
2965
diff --git a/mediapipe/tasks/cc/core/task_api_factory.h b/mediapipe/tasks/cc/core/task_api_factory.h
30-
index a11a23fc..dbb5fe6c 100644
66+
index a11a23fcf..dbb5fe6ca 100644
3167
--- a/mediapipe/tasks/cc/core/task_api_factory.h
3268
+++ b/mediapipe/tasks/cc/core/task_api_factory.h
3369
@@ -76,15 +76,17 @@ class TaskApiFactory {
@@ -50,7 +86,7 @@ index a11a23fc..dbb5fe6c 100644
5086
std::move(graph_config), std::move(resolver),
5187
std::move(packets_callback), std::move(default_executor),
5288
diff --git a/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc b/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc
53-
index 2ff140c0..128a4326 100644
89+
index 2ff140c07..128a43263 100644
5490
--- a/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc
5591
+++ b/mediapipe/tasks/cc/vision/holistic_landmarker/holistic_landmarker_graph.cc
5692
@@ -387,6 +387,13 @@ class HolisticLandmarkerGraph : public core::ModelTaskGraph {

0 commit comments

Comments
 (0)