MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / LoadFile

Method LoadFile

LuaSTGPlus/ResourceMgr.cpp:1508–1577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1506}
1507
1508bool ResourcePack::LoadFile(const wchar_t* path, fcyRefPointer<fcyMemStream>& outBuf)LNOEXCEPT
1509{
1510 string tPathInUtf8;
1511 try
1512 {
1513 tPathInUtf8 = fcyStringHelper::WideCharToMultiByte(path, CP_UTF8);
1514 pathUniform(tPathInUtf8.begin(), tPathInUtf8.end());
1515 }
1516 catch (const bad_alloc&)
1517 {
1518 LERROR("ResourcePack: ת����ԴĿ¼����ʱ�޷������ڴ�");
1519 return false;
1520 }
1521
1522 int tStatus = unzGoToFirstFile(m_zipFile);
1523 while (UNZ_OK == tStatus)
1524 {
1525 unz_file_info tFileInfo;
1526 char tZipName[MAX_PATH];
1527
1528 if (UNZ_OK == unzGetCurrentFileInfo(m_zipFile, &tFileInfo, tZipName, sizeof(tZipName), nullptr, 0, nullptr, 0))
1529 {
1530 // ��·����ͳһ��ת��
1531 pathUniform(tZipName, tZipName + MAX_PATH);
1532
1533 // ���·���Ƿ�����
1534 if (strcmp(tPathInUtf8.c_str(), tZipName) == 0)
1535 {
1536#ifdef LSHOWRESLOADINFO
1537 LINFO("ResourcePack: ��Դ��'%s'�����ļ�'%s'", m_Path.c_str(), path);
1538#endif
1539 if (unzOpenCurrentFilePassword(m_zipFile, m_Password.length() > 0 ? m_Password.c_str() : nullptr) != UNZ_OK)
1540 {
1541 LERROR("ResourcePack: ���Դ���Դ��'%s'�е��ļ�'%s'ʧ��(�������?)", m_Path.c_str(), path);
1542 return false;
1543 }
1544
1545 try
1546 {
1547 outBuf.DirectSet(new fcyMemStream(NULL, tFileInfo.uncompressed_size, true, false));
1548 }
1549 catch (const bad_alloc&)
1550 {
1551 unzCloseCurrentFile(m_zipFile);
1552 LERROR("ResourcePack: �޷������㹻�ڴ��ѹ��Դ��'%s'�е��ļ�'%s'", m_Path.c_str(), path);
1553 return false;
1554 }
1555
1556 if (outBuf->GetLength() > 0)
1557 {
1558 if (unzReadCurrentFile(m_zipFile, outBuf->GetInternalBuffer(), tFileInfo.uncompressed_size) < 0)
1559 {
1560 unzCloseCurrentFile(m_zipFile);
1561 LERROR("ResourcePack: ��ѹ��Դ��'%s'�е��ļ�'%s'ʧ�� (unzReadCurrentFileʧ��)", m_Path.c_str(), path);
1562 return false;
1563 }
1564 }
1565 unzCloseCurrentFile(m_zipFile);

Callers 10

AppFrame.cppFile · 0.80
InitMethod · 0.80
LoadTextureMethod · 0.80
LoadMusicMethod · 0.80
LoadSoundMethod · 0.80
LoadParticleMethod · 0.80
LoadSpriteFontMethod · 0.80
LoadTTFFontMethod · 0.80
LoadFXMethod · 0.80
ResourceMgr.cppFile · 0.80

Calls 7

pathUniformFunction · 0.85
unzGoToFirstFileFunction · 0.85
unzGetCurrentFileInfoFunction · 0.85
unzCloseCurrentFileFunction · 0.85
unzReadCurrentFileFunction · 0.85
unzGoToNextFileFunction · 0.85

Tested by

no test coverage detected