Improve wide paths support.

This commit is contained in:
lzwdgc 2020-01-12 22:16:48 +03:00
parent 3f9c32335c
commit e96b6d0bea
8 changed files with 15 additions and 16 deletions

View file

@ -143,10 +143,9 @@ void db::load(const buffer &b)
void db::open(const path &p)
{
std::string fn = p.string();
t.load(buffer(read_file(fn + ".tab")));
load(buffer(read_file(fn + ".ind")));
buffer b(read_file(fn + ".dat"));
t.load(buffer(read_file(path(p) += ".tab")));
load(buffer(read_file(path(p) += ".ind")));
buffer b(read_file(path(p) += ".dat"));
for (auto &v : values)
v.load_fields(t, b);
}

View file

@ -219,7 +219,7 @@ void process_lang(polygon4::Storage &s, const path &p, polygon4::String polygon4
AimKV kv1;
if (db.number_of_values)
{
kv1 = ::get_kv(db, get_cp(p.filename().string()));
kv1 = ::get_kv(db, get_cp(p.filename().u8string()));
kvm.insert(kv1.begin(), kv1.end());
}
};
@ -282,7 +282,7 @@ void process_lang(polygon4::Storage &s, const path &p, polygon4::String polygon4
str += wstring2string(kv.second.s) + "\n";
str += "\n================================================\n\n";
}*/
write_file(p / (p.filename().string() + "_diff.txt"), str);
write_file(p / (p.filename() += "_diff.txt"), str);
}
int main(int argc, char *argv[])
@ -313,7 +313,7 @@ int main(int argc, char *argv[])
#undef ADD_LANGUAGE
else
{
std::cerr << "No such lang: " << p.filename().string() << "\n";
std::cerr << "No such lang: " << p.filename().u8string() << "\n";
continue;
}
}

View file

@ -63,7 +63,7 @@ mmm read_mmm(const path &fn)
void process_mmm(const path &fn)
{
auto m = read_mmm(fn);
write_mat_bmp(fn.string() + ".bmp", m.data.unpack_mmm());
write_mat_bmp(fn.u8string() + ".bmp", m.data.unpack_mmm());
}
int main(int argc, char *argv[])

View file

@ -105,7 +105,7 @@ mmo_storage read_mmo(const path &fn)
void write_mmo(Storage *storage, const mmo_storage &s)
{
std::string map_name = s.name.filename().stem().string();
std::string map_name = s.name.filename().stem().u8string();
if (!prefix.empty())
map_name = prefix + "." + map_name;
std::transform(map_name.begin(), map_name.end(), map_name.begin(), ::tolower);
@ -303,7 +303,7 @@ int main(int argc, char *argv[])
std::cout << mg.name;
std::cout << " " << mg.org;
std::cout << " " << mg.mechanoids.size();
std::cout << " " << file.filename().stem().string();
std::cout << " " << file.filename().stem().u8string();
std::cout << "\n";
}
});

View file

@ -393,7 +393,7 @@ void mmp::writeHeightMap()
fclose(f);
};
cv::imwrite((path(filename) += ".heightmap16.png").string(), toCvMat(heightmap));
cv::imwrite((path(filename) += ".heightmap16.png").u8string(), toCvMat(heightmap));
//write_hm(".heightmap16.r16", heightmap, sizeof(decltype(heightmap)::type));
write_hm(".heightmap32.r32", heightmap32, sizeof(decltype(heightmap32)::type));

View file

@ -65,8 +65,8 @@ void convert_model(const model &m, const path &fn)
{
// write all
if (all_formats)
m.print(fn.string());
m.printFbx(fn.string());
m.print(fn.u8string());
m.printFbx(fn.u8string());
}
void convert_model(const path &fn)
@ -75,7 +75,7 @@ void convert_model(const path &fn)
if (stats)
{
m.save(root[fn.filename().string()]);
m.save(root[fn.filename().u8string()]);
return;
}

View file

@ -47,7 +47,7 @@ int main(int argc, char *argv[])
save s;
s.load(f);
//writeFile(p.string(), save_changes.out.buf());
//writeFile(p.u8string(), save_changes.out.buf());
};
if (fs::is_regular_file(p))

View file

@ -61,7 +61,7 @@ void convert(const path &fn)
src._read(&dxt5_flag, 1);
src.seek(0x4C);
auto s = fn.string() + ".bmp";
auto s = path(fn) += ".bmp";
mat<uint32_t> m(width, height);
if (dxt5_flag)
{