MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / FilesExist

Method FilesExist

tensorflow/core/platform/env.cc:166–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166bool Env::FilesExist(const std::vector<string>& files,
167 std::vector<Status>* status) {
168 std::unordered_map<string, std::vector<string>> files_per_fs;
169 for (const auto& file : files) {
170 StringPiece scheme, host, path;
171 io::ParseURI(file, &scheme, &host, &path);
172 files_per_fs[string(scheme)].push_back(file);
173 }
174
175 std::unordered_map<string, Status> per_file_status;
176 bool result = true;
177 for (auto itr : files_per_fs) {
178 FileSystem* file_system = file_system_registry_->Lookup(itr.first);
179 bool fs_result;
180 std::vector<Status> local_status;
181 std::vector<Status>* fs_status = status ? &local_status : nullptr;
182 if (!file_system) {
183 fs_result = false;
184 if (fs_status) {
185 Status s = errors::Unimplemented("File system scheme '", itr.first,
186 "' not implemented");
187 local_status.resize(itr.second.size(), s);
188 }
189 } else {
190 fs_result = file_system->FilesExist(itr.second, fs_status);
191 }
192 if (fs_status) {
193 result &= fs_result;
194 for (int i = 0; i < itr.second.size(); ++i) {
195 per_file_status[itr.second[i]] = fs_status->at(i);
196 }
197 } else if (!fs_result) {
198 // Return early
199 return false;
200 }
201 }
202
203 if (status) {
204 for (const auto& file : files) {
205 status->push_back(per_file_status[file]);
206 }
207 }
208
209 return result;
210}
211
212Status Env::GetChildren(const string& dir, std::vector<string>* result) {
213 FileSystem* fs;

Callers 1

FilesExistFunction · 0.45

Calls 7

ParseURIFunction · 0.85
UnimplementedFunction · 0.85
push_backMethod · 0.45
LookupMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected