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) void db::open(const path &p)
{ {
std::string fn = p.string(); t.load(buffer(read_file(path(p) += ".tab")));
t.load(buffer(read_file(fn + ".tab"))); load(buffer(read_file(path(p) += ".ind")));
load(buffer(read_file(fn + ".ind"))); buffer b(read_file(path(p) += ".dat"));
buffer b(read_file(fn + ".dat"));
for (auto &v : values) for (auto &v : values)
v.load_fields(t, b); 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; AimKV kv1;
if (db.number_of_values) 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()); 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 += wstring2string(kv.second.s) + "\n";
str += "\n================================================\n\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[]) int main(int argc, char *argv[])
@ -313,7 +313,7 @@ int main(int argc, char *argv[])
#undef ADD_LANGUAGE #undef ADD_LANGUAGE
else else
{ {
std::cerr << "No such lang: " << p.filename().string() << "\n"; std::cerr << "No such lang: " << p.filename().u8string() << "\n";
continue; continue;
} }
} }

View file

@ -63,7 +63,7 @@ mmm read_mmm(const path &fn)
void process_mmm(const path &fn) void process_mmm(const path &fn)
{ {
auto m = read_mmm(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[]) 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) 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()) if (!prefix.empty())
map_name = prefix + "." + map_name; map_name = prefix + "." + map_name;
std::transform(map_name.begin(), map_name.end(), map_name.begin(), ::tolower); 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.name;
std::cout << " " << mg.org; std::cout << " " << mg.org;
std::cout << " " << mg.mechanoids.size(); std::cout << " " << mg.mechanoids.size();
std::cout << " " << file.filename().stem().string(); std::cout << " " << file.filename().stem().u8string();
std::cout << "\n"; std::cout << "\n";
} }
}); });

View file

@ -393,7 +393,7 @@ void mmp::writeHeightMap()
fclose(f); 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(".heightmap16.r16", heightmap, sizeof(decltype(heightmap)::type));
write_hm(".heightmap32.r32", heightmap32, sizeof(decltype(heightmap32)::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 // write all
if (all_formats) if (all_formats)
m.print(fn.string()); m.print(fn.u8string());
m.printFbx(fn.string()); m.printFbx(fn.u8string());
} }
void convert_model(const path &fn) void convert_model(const path &fn)
@ -75,7 +75,7 @@ void convert_model(const path &fn)
if (stats) if (stats)
{ {
m.save(root[fn.filename().string()]); m.save(root[fn.filename().u8string()]);
return; return;
} }

View file

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

View file

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