| 1054 | } |
| 1055 | |
| 1056 | std::shared_ptr<UniqueFD> PlatformState::GetUniqueFileHandle(const std::string& file_path) { |
| 1057 | amd::ScopedLock lock(ufd_lock_); |
| 1058 | |
| 1059 | if (ufd_map_.cend() == ufd_map_.find(file_path)) { |
| 1060 | // Get the file desc and file size from amd::Os API |
| 1061 | amd::Os::FileDesc fdesc; |
| 1062 | size_t fsize = 0; |
| 1063 | if (!amd::Os::GetFileHandle(file_path.c_str(), &fdesc, &fsize)) { |
| 1064 | return nullptr; |
| 1065 | } |
| 1066 | ufd_map_.insert(std::make_pair(file_path, std::make_shared<UniqueFD>(file_path, fdesc, fsize))); |
| 1067 | } |
| 1068 | |
| 1069 | // we should have an entry at this time. |
| 1070 | return ufd_map_[file_path]; |
| 1071 | } |
| 1072 | |
| 1073 | bool PlatformState::CloseUniqueFileHandle(const std::shared_ptr<UniqueFD>& ufd) { |
| 1074 | amd::ScopedLock lock(ufd_lock_); |
no outgoing calls
no test coverage detected