首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PhysFS_init()返回非零值,并返回错误:"no error“

PhysFS_init()返回非零值,并返回错误:"no error“
EN

Stack Overflow用户
提问于 2019-03-09 23:00:48
回答 1查看 148关注 0票数 0

我在我的代码中遇到了一个相当奇怪的崩溃,我不确定是什么导致了它。我正在尝试在我的c++代码中使用PhysFS。下面的代码是一个类的一部分,Visual Studio2017告诉我,崩溃出现在PHYSFS_mount()中,随后出现在EnterCriticalSection()中,据我所知,这与互斥有关。现在,根据我的理解,这应该是正确的(请注意,main首先调用initArchives() )

代码语言:javascript
复制
physfs_initialized = false;

...

void scope::parse_archive(const std::string& archive_path, const std::string& path_in_archive)
{
    assert(physfs_initialized);

    m_archivePath = archive_path;
    m_relativeArchivePath = path_in_archive.substr(1);

    //fsx = std::filesystem or std::expiremental::filesystem whatever floats your boat
    if(exists(fsx::path(archive_path))) return;


    if(!PHYSFS_mount(m_archivePath.c_str(),"",0)) return;
    const auto file = PHYSFS_openRead(m_relativeArchivePath.c_str());

    if(file) m_isValid = true;

    PHYSFS_close(file);
    PHYSFS_unmount(m_archivePath.c_str());
}

...

void initArchives(char ** argv)
{
    if (!PHYSFS_init(argv[0])) physfs_initialized = true;
    //a bit of ugly syntax because of the need to consume the return type
    atexit([]() {PHYSFS_deinit(); });
}

坠机显然出现在这里

代码语言:javascript
复制
int __PHYSFS_platformGrabMutex(void *mutex)
{
    EnterCriticalSection((LPCRITICAL_SECTION) mutex); // <-- here 
    return 1;
} /* __PHYSFS_platformGrabMutex */

我是不是做错了什么?这是库的问题,还是我的操作系统的问题?在PhysFS的构建步骤中,有什么我遗漏的东西吗?

编辑:我注意到我读错了PHYSFS_init()的返回值,但是现在我更困惑了,因为PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())返回“没有错误”,这是怎么回事?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-09 23:45:23

显然,关于Windows10的PhysFS中存在一个错误。这将阻止正确执行PHYSFS_init(),将phsyfs_platform_windows.c的第578行改为

rc = pGetDir(accessToken, NULL, &psize);

库的重新编译为我解决了这个问题:/

https://hg.icculus.org/icculus/physfs/rev/ece6769c0676

https://discourse.libsdl.org/t/resolved-physfs-exception-thrown/25697/11

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55078623

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档