MCPcopy Create free account
hub / github.com/axmolengine/axmol / open

Method open

core/platform/FileStream.cpp:303–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303bool 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
338osfhnd_t FileStream::nativeHandle() const
339{

Callers 2

getContentsMethod · 0.45
openFileStreamMethod · 0.45

Calls 7

axrt_lowio_openFunction · 0.85
getObbFileFunction · 0.85
getAssetManagerFunction · 0.85
vopenMethod · 0.80
findMethod · 0.45
substrMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected