| 190 | } |
| 191 | |
| 192 | string GetRunfilesDir() override { |
| 193 | string bin_path = this->GetExecutablePath(); |
| 194 | string runfiles_suffix = ".runfiles/org_tensorflow"; |
| 195 | std::size_t pos = bin_path.find(runfiles_suffix); |
| 196 | |
| 197 | // Sometimes (when executing under python) bin_path returns the full path to |
| 198 | // the python scripts under runfiles. Get the substring. |
| 199 | if (pos != std::string::npos) { |
| 200 | return bin_path.substr(0, pos + runfiles_suffix.length()); |
| 201 | } |
| 202 | |
| 203 | // See if we have the executable path. if executable.runfiles exists, return |
| 204 | // that folder. |
| 205 | string runfiles_path = bin_path + runfiles_suffix; |
| 206 | Status s = this->IsDirectory(runfiles_path); |
| 207 | if (s.ok()) { |
| 208 | return runfiles_path; |
| 209 | } |
| 210 | |
| 211 | // If nothing can be found, return something close. |
| 212 | return bin_path.substr(0, bin_path.find_last_of("/\\")); |
| 213 | } |
| 214 | |
| 215 | private: |
| 216 | void GetLocalTempDirectories(std::vector<string>* list) override; |
nothing calls this directly
no test coverage detected