File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 22
22
23
23
#include " Firestore/core/src/util/path.h"
24
24
#include " Firestore/core/src/util/statusor.h"
25
+ #include " Firestore/core/src/util/string_format.h"
25
26
#include " absl/strings/str_cat.h"
26
27
27
28
namespace firebase {
90
91
return Path::FromUtf8 (" /tmp" );
91
92
}
92
93
94
+ Status Filesystem::IsDirectory (const Path& path) {
95
+ NSFileManager * file_manager = NSFileManager .defaultManager ;
96
+ NSString * ns_path_str = path.ToNSString ();
97
+ BOOL is_directory = NO ;
98
+
99
+ if (![file_manager fileExistsAtPath: ns_path_str isDirectory: &is_directory]) {
100
+ return Status{Error::kErrorNotFound , path.ToUtf8String ()};
101
+ }
102
+
103
+ if (!is_directory) {
104
+ return Status{Error::kErrorFailedPrecondition ,
105
+ StringFormat (" Path %s exists but is not a directory" ,
106
+ path.ToUtf8String ())};
107
+ }
108
+
109
+ return Status::OK ();
110
+ }
111
+
93
112
} // namespace util
94
113
} // namespace firestore
95
114
} // namespace firebase
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ Path Filesystem::TempDir() {
130
130
}
131
131
#endif // !__APPLE__ && !_WIN32
132
132
133
+ #if !__APPLE__
133
134
Status Filesystem::IsDirectory (const Path& path) {
134
135
struct stat buffer {};
135
136
if (::stat (path.c_str (), &buffer)) {
@@ -165,6 +166,7 @@ Status Filesystem::IsDirectory(const Path& path) {
165
166
166
167
return Status::OK ();
167
168
}
169
+ #endif // !__APPLE__
168
170
169
171
StatusOr<int64_t > Filesystem::FileSize (const Path& path) {
170
172
struct stat st {};
You can’t perform that action at this time.
0 commit comments