| 301 | } |
| 302 | |
| 303 | bool FileStream::open(std::string_view path, IFileStream::Mode mode) |
| 304 | { |
| 305 | #if AX_TARGET_PLATFORM != AX_PLATFORM_ANDROID |
| 306 | if (axrt_lowio_open(path, mode, _handle)) |
| 307 | this->_iof = &axrt_lowio_iof; |
| 308 | #else // Android |
| 309 | if (path[0] != '/') |
| 310 | { // from package, always readonly |
| 311 | size_t position = path.find("assets/"); |
| 312 | // "assets/" is at the beginning of the path and we don't want it |
| 313 | const auto relativePath = 0 == position ? path.substr(sizeof("assets/") - 1) : path; |
| 314 | |
| 315 | auto obb = FileUtilsAndroid::getObbFile(); |
| 316 | if (obb && (_handle.zentry = obb->vopen(relativePath))) |
| 317 | { |
| 318 | this->_iof = &axrt_obb_iof; |
| 319 | } |
| 320 | else |
| 321 | { |
| 322 | AAssetManager* asMgr = FileUtilsAndroid::getAssetManager(); |
| 323 | _handle.aasset = AAssetManager_open(asMgr, relativePath.data(), AASSET_MODE_UNKNOWN); |
| 324 | if (_handle.aasset) |
| 325 | this->_iof = &axrt_asset_iof; |
| 326 | } |
| 327 | } |
| 328 | else |
| 329 | { // otherwise, as a absolutely path |
| 330 | if (axrt_lowio_open(path, mode, _handle)) |
| 331 | this->_iof = &axrt_lowio_iof; |
| 332 | } |
| 333 | #endif |
| 334 | |
| 335 | return !!this->_iof; |
| 336 | } |
| 337 | |
| 338 | osfhnd_t FileStream::nativeHandle() const |
| 339 | { |
no test coverage detected