Skip to content

Commit 0762a26

Browse files
LukeBoyercopybara-github
authored andcommitted
Add get parent to filesystem
LiteRT-PiperOrigin-RevId: 820520339
1 parent 418477d commit 0762a26

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

litert/core/filesystem.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,9 @@ Expected<void> MkDir(absl::string_view path) {
149149
return {};
150150
}
151151

152+
Expected<std::string> Parent(absl::string_view path) {
153+
auto std_path = MakeStdPath(path);
154+
return std_path.parent_path().generic_string();
155+
}
156+
152157
} // namespace litert::internal

litert/core/filesystem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ Expected<std::string> Filename(absl::string_view path);
5656
// Make a new directory at the given path.
5757
Expected<void> MkDir(absl::string_view path);
5858

59+
// Get the parent directory of the given path.
60+
Expected<std::string> Parent(absl::string_view path);
61+
5962
} // namespace litert::internal
6063

6164
#endif // ODML_LITERT_LITERT_CORE_FILESYSTEM_H_

0 commit comments

Comments
 (0)