为什么 opendir() 返回目录在 android 上不存在

Why opendir() returns directory does not exist on android

本文关键字:android 不存在 opendir 返回 为什么      更新时间:2023-10-16

我正在尝试使用 android 上 dirent.h 头文件中的opendir()函数,每次运行它时,它都会返回错误NULL ENOENT这意味着目录不存在。

我正在尝试将C++游戏移植到安卓,这在 Windows 上工作正常。

我已经检查了目录,它存在于assets/pics/Jason

我是这样称呼它的:

DIR *DIRpointer=opendir("pics/Jason");

还尝试了《/pics/Jason》而《pics/Jason/》而且我仍然遇到同样的错误...

我试过谷歌搜索,但没有解决方案。

如果您在 Android 手机中访问资产目录,请尝试使用 AAssetManager 和 AAssetManager_openDir(( 函数