This commit is contained in:
Nekotekina 2015-01-13 03:10:39 +03:00
parent 25672cdc47
commit fe86869f37
2 changed files with 43 additions and 24 deletions

View file

@ -567,23 +567,41 @@ namespace fmt
} }
}; };
template<size_t size> //template<size_t size>
struct get_fmt<const char[size], false> //struct get_fmt<char[size], false>
{ //{
static std::string text(const char* fmt, size_t len, const char(&arg)[size]) // static std::string text(const char* fmt, size_t len, const char(&arg)[size])
{ // {
if (fmt[len - 1] == 's') // if (fmt[len - 1] == 's')
{ // {
return std::string(arg, size); // return std::string(arg, size);
} // }
else // else
{ // {
throw "Invalid formatting (const char[size])"; // throw "Invalid formatting (char[size])";
} // }
return{}; // return{};
} // }
}; //};
//template<size_t size>
//struct get_fmt<const char[size], false>
//{
// static std::string text(const char* fmt, size_t len, const char(&arg)[size])
// {
// if (fmt[len - 1] == 's')
// {
// return std::string(arg, size);
// }
// else
// {
// throw "Invalid formatting (const char[size])";
// }
// return{};
// }
//};
template<> template<>
struct get_fmt<std::string> struct get_fmt<std::string>
@ -633,8 +651,9 @@ namespace fmt
float (%x, %f) float (%x, %f)
double (%x, %f) double (%x, %f)
bool (%x, %d, %s) bool (%x, %d, %s)
char*, const char*, const char[N], std::string (%s) char*, const char*, std::string (%s)
be_t<> of any appropriate type in this list be_t<> of any appropriate type in this list
enum of any appropriate type in this list
Supported formatting: Supported formatting:
%d - decimal; only basic std::to_string() functionality %d - decimal; only basic std::to_string() functionality

View file

@ -164,12 +164,12 @@ bool UnpackEntry(rFile& dec_pkg_f, const PKGEntry& entry, std::string dir)
dec_pkg_f.Read(buf, entry.name_size); dec_pkg_f.Read(buf, entry.name_size);
buf[entry.name_size] = 0; buf[entry.name_size] = 0;
switch (entry.type.ToBE() >> 24) switch (entry.type.data())
{ {
case PKG_FILE_ENTRY_NPDRM: case se32(PKG_FILE_ENTRY_NPDRM):
case PKG_FILE_ENTRY_NPDRMEDAT: case se32(PKG_FILE_ENTRY_NPDRMEDAT):
case PKG_FILE_ENTRY_SDAT: case se32(PKG_FILE_ENTRY_SDAT):
case PKG_FILE_ENTRY_REGULAR: case se32(PKG_FILE_ENTRY_REGULAR):
{ {
rFile out; rFile out;
auto path = dir + std::string(buf, entry.name_size); auto path = dir + std::string(buf, entry.name_size);
@ -199,7 +199,7 @@ bool UnpackEntry(rFile& dec_pkg_f, const PKGEntry& entry, std::string dir)
} }
} }
case PKG_FILE_ENTRY_FOLDER: case se32(PKG_FILE_ENTRY_FOLDER):
{ {
auto path = dir + std::string(buf, entry.name_size); auto path = dir + std::string(buf, entry.name_size);
if (!rExists(path) && !rMkdir(path)) if (!rExists(path) && !rMkdir(path))
@ -213,7 +213,7 @@ bool UnpackEntry(rFile& dec_pkg_f, const PKGEntry& entry, std::string dir)
default: default:
{ {
LOG_ERROR(LOADER, "PKG Loader: unknown PKG file entry: 0x%x", entry.type.ToLE()); LOG_ERROR(LOADER, "PKG Loader: unknown PKG file entry: 0x%x", entry.type);
return false; return false;
} }
} }