diff --git a/apps/yimageproc/yimageproc.cpp b/apps/yimageproc/yimageproc.cpp index 1de38ebd2..747c9ab2a 100644 --- a/apps/yimageproc/yimageproc.cpp +++ b/apps/yimageproc/yimageproc.cpp @@ -281,12 +281,11 @@ int main(int argc, const char* argv[]) { auto error = ""s; // load - auto ext = path(filename).extension().string(); - auto basename = path(filename).stem().string(); - auto ioerror = ""s; - auto img = image{}; - if (ext == ".ypreset") { - if (!make_image_preset(basename, img, ioerror)) print_fatal(ioerror); + auto ioerror = ""s; + auto img = image{}; + if (path{filename}.extension().string() == ".ypreset") { + if (!make_image_preset(path{filename}.stem().string(), img, ioerror)) + print_fatal(ioerror); } else { if (!load_image(filename, img, ioerror)) print_fatal(ioerror); } diff --git a/apps/yimageview/yimageview.cpp b/apps/yimageview/yimageview.cpp index db13b2ed1..650157edd 100644 --- a/apps/yimageview/yimageview.cpp +++ b/apps/yimageview/yimageview.cpp @@ -134,8 +134,8 @@ void update_display(app_state* app) { void load_image_async(app_states* apps, const string& filename) { auto app = apps->states.emplace_back(new app_state{}); app->filename = filename; - app->outname = path(filename).replace_extension(".display.png").string(); - app->name = path(filename).filename().string(); + app->outname = path{filename}.replace_extension(".display.png").string(); + app->name = path{filename}.filename().string(); app->exposure = apps->exposure; app->filmic = apps->filmic; app->params = apps->params; @@ -164,8 +164,8 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { } continue_line(win); if (draw_filedialog_button(win, "save", apps->selected && apps->selected->ok, - "save image", save_path, true, path(save_path).parent_path().string(), - path(save_path).filename().string(), + "save image", save_path, true, path{save_path}.parent_path().string(), + path{save_path}.filename().string(), "*.png;*.jpg;*.tga;*.bmp;*.hdr;*.exr")) { auto app = apps->selected; app->outname = save_path; @@ -227,7 +227,7 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { end_header(win); } if (begin_header(win, "inspect")) { - draw_label(win, "image", path(app->filename).filename().string()); + draw_label(win, "image", path{app->filename}.filename().string()); draw_label(win, "filename", app->filename); draw_label(win, "outname", app->outname); draw_label(win, "image", diff --git a/apps/ymeshproc/ymeshproc.cpp b/apps/ymeshproc/ymeshproc.cpp index d6db91eeb..04d803e6a 100644 --- a/apps/ymeshproc/ymeshproc.cpp +++ b/apps/ymeshproc/ymeshproc.cpp @@ -164,11 +164,9 @@ int main(int argc, const char* argv[]) { // load mesh auto ioerror = ""s; print_progress("load mesh", 0, 1); - auto ext = path(filename).extension().string(); - auto basename = path(filename).stem().string(); - if (ext == ".ypreset") { + if (path{filename}.extension().string() == ".ypreset") { if (!make_mesh_preset(triangles, positions, normals, texcoords, colors, - basename, ioerror)) + path{filename}.stem().string(), ioerror)) print_fatal(ioerror); } else { if (!load_mesh(filename, triangles, positions, normals, texcoords, colors, diff --git a/apps/ysceneitrace/ysceneitrace.cpp b/apps/ysceneitrace/ysceneitrace.cpp index cb8872c34..170613512 100644 --- a/apps/ysceneitrace/ysceneitrace.cpp +++ b/apps/ysceneitrace/ysceneitrace.cpp @@ -264,10 +264,10 @@ void reset_display(app_state* app) { void load_scene_async(app_states* apps, const string& filename, const string& camera_name = "", bool add_skyenv = false) { auto app = apps->states.emplace_back(new app_state{}); - app->name = path(filename).filename().string() + " [loading]"; + app->name = path{filename}.filename().string() + " [loading]"; app->filename = filename; - app->imagename = path(filename).replace_extension(".png").string(); - app->outname = path(filename).replace_extension(".edited.yaml").string(); + app->imagename = path{filename}.replace_extension(".png").string(); + app->outname = path{filename}.replace_extension(".edited.yaml").string(); app->params = apps->params; app->status = "load"; app->loader = std::async(std::launch::async, [app, camera_name, @@ -462,8 +462,8 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { } continue_line(win); if (draw_filedialog_button(win, "save", apps->selected && apps->selected->ok, - "save", save_path, true, path(save_path).parent_path().string(), - path(save_path).filename().string(), "*.yaml;*.obj;*.pbrt")) { + "save", save_path, true, path{save_path}.parent_path().string(), + path{save_path}.filename().string(), "*.yaml;*.obj;*.pbrt")) { auto app = apps->selected; app->outname = save_path; save_scene(app->outname, app->ioscene, app->error); @@ -472,8 +472,8 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { continue_line(win); if (draw_filedialog_button(win, "save image", apps->selected && apps->selected->ok, "save image", save_path, true, - path(save_path).parent_path().string(), - path(save_path).filename().string(), + path{save_path}.parent_path().string(), + path{save_path}.filename().string(), "*.png;*.jpg;*.tga;*.bmp;*.hdr;*.exr")) { auto app = apps->selected; app->outname = save_path; @@ -527,7 +527,7 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { end_header(win); } if (begin_header(win, "inspect")) { - draw_label(win, "scene", path(app->filename).filename().string()); + draw_label(win, "scene", path{app->filename}.filename().string()); draw_label(win, "filename", app->filename); draw_label(win, "outname", app->outname); draw_label(win, "imagename", app->imagename); diff --git a/apps/ysceneproc/ysceneproc.cpp b/apps/ysceneproc/ysceneproc.cpp index 22133bf1f..e376b3f7c 100644 --- a/apps/ysceneproc/ysceneproc.cpp +++ b/apps/ysceneproc/ysceneproc.cpp @@ -796,9 +796,9 @@ bool make_preset(scene_model* scene, const string& type, string& error) { } void make_dir(const string& dirname) { - if (exists(path(dirname))) return; + if (exists(path{dirname})) return; try { - create_directories(path(dirname)); + create_directories(path{dirname}); } catch (...) { print_fatal("cannot create directory " + dirname); } @@ -822,14 +822,13 @@ int main(int argc, const char* argv[]) { parse_cli(cli, argc, argv); // load scene - auto ext = path(filename).extension().string(); - auto basename = path(filename).stem().string(); auto scene_guard = std::make_unique(); auto scene = scene_guard.get(); auto ioerror = ""s; - if (ext == ".ypreset") { + if (path{filename}.extension().string() == ".ypreset") { print_progress("make preset", 0, 1); - if (!make_preset(scene, basename, ioerror)) print_fatal(ioerror); + if (!make_preset(scene, path{filename}.stem().string(), ioerror)) + print_fatal(ioerror); print_progress("make preset", 1, 1); } else { if (!load_scene(filename, scene, ioerror, print_progress)) @@ -853,16 +852,16 @@ int main(int argc, const char* argv[]) { } // tesselate if needed - if (path(output).extension() != ".json") { + if (path{output}.extension() != ".json") { tesselate_shapes(scene, print_progress); } // make a directory if needed - make_dir(path(output).parent_path().string()); + make_dir(path{output}.parent_path().string()); if (!scene->shapes.empty()) - make_dir((path(output).parent_path() / "shapes").string()); + make_dir((path{output}.parent_path() / "shapes").string()); if (!scene->textures.empty()) - make_dir((path(output).parent_path() / "textures").string()); + make_dir((path{output}.parent_path() / "textures").string()); // save scene if (!save_scene(output, scene, ioerror, print_progress)) print_fatal(ioerror); diff --git a/apps/yscenetrace/yscenetrace.cpp b/apps/yscenetrace/yscenetrace.cpp index 4f66bc35e..e8f117cf7 100644 --- a/apps/yscenetrace/yscenetrace.cpp +++ b/apps/yscenetrace/yscenetrace.cpp @@ -103,8 +103,8 @@ int main(int argc, const char* argv[]) { const image& render, int sample, int samples) { if (!save_batch) return; auto ext = "-s" + std::to_string(sample + samples) + - path(imfilename).extension().string(); - auto outfilename = path(imfilename).replace_extension(ext).string(); + path{imfilename}.extension().string(); + auto outfilename = path{imfilename}.replace_extension(ext).string(); auto ioerror = ""s; print_progress("save image", sample, samples); if (!save_image(outfilename, render, ioerror)) print_fatal(ioerror); @@ -120,10 +120,10 @@ int main(int argc, const char* argv[]) { const int feature_samples = 8; std::string feature_ext = "exr"s; - auto imext = path(imfilename).extension().string(); + auto imext = path{imfilename}.extension().string(); if (imext != "hdr" && is_hdr_filename(imext)) feature_ext = imext; - auto base_name = path(imfilename).filename().replace_extension("").string(); + auto base_name = path{imfilename}.filename().replace_extension("").string(); auto fparams = params; fparams.bounces = feature_bounces; @@ -132,7 +132,7 @@ int main(int argc, const char* argv[]) { // render denoise albedo fparams.sampler = trace_sampler_type::albedo; auto albedo = trace_image(scene, camera, fparams, print_progress); - auto albedo_filename = path(imfilename) + auto albedo_filename = path{imfilename} .replace_filename(base_name + "-albedo") .replace_extension(feature_ext) .string(); @@ -144,7 +144,7 @@ int main(int argc, const char* argv[]) { // render denoise normals fparams.sampler = trace_sampler_type::normal; auto normal = trace_image(scene, camera, fparams, print_progress); - auto normal_filename = path(imfilename) + auto normal_filename = path{imfilename} .replace_filename(base_name + "-normal") .replace_extension(feature_ext) .string(); diff --git a/apps/ysceneview/ysceneview.cpp b/apps/ysceneview/ysceneview.cpp index dce06612d..5c407ff87 100644 --- a/apps/ysceneview/ysceneview.cpp +++ b/apps/ysceneview/ysceneview.cpp @@ -109,9 +109,9 @@ void load_scene_async( app_states* apps, const string& filename, const string& camera_name = "") { auto app = apps->states.emplace_back(new app_state{}); app->filename = filename; - app->imagename = path(filename).replace_extension(".png").string(); - app->outname = path(filename).replace_extension(".edited.yaml").string(); - app->name = path(app->filename).filename().string(); + app->imagename = path{filename}.replace_extension(".png").string(); + app->outname = path{filename}.replace_extension(".edited.yaml").string(); + app->name = path{app->filename}.filename().string(); app->drawgl_prms = apps->drawgl_prms; app->status = "load"; app->loader = std::async(std::launch::async, [app, camera_name]() { @@ -422,8 +422,8 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { } continue_line(win); if (draw_filedialog_button(win, "save", apps->selected && apps->selected->ok, - "save", save_path, true, path(save_path).parent_path().string(), - path(save_path).filename().string(), "*.yaml;*.obj;*.pbrt")) { + "save", save_path, true, path{save_path}.parent_path().string(), + path{save_path}.filename().string(), "*.yaml;*.obj;*.pbrt")) { auto app = apps->selected; app->outname = save_path; save_scene(app->outname, app->ioscene, app->error); @@ -472,7 +472,7 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { end_header(win); } if (begin_header(win, "inspect")) { - draw_label(win, "scene", path(app->filename).filename().string()); + draw_label(win, "scene", path{app->filename}.filename().string()); draw_label(win, "filename", app->filename); draw_label(win, "outname", app->outname); draw_label(win, "imagename", app->imagename); diff --git a/apps/yshapeproc/yshapeproc.cpp b/apps/yshapeproc/yshapeproc.cpp index 24fd67d3b..1928c1b01 100644 --- a/apps/yshapeproc/yshapeproc.cpp +++ b/apps/yshapeproc/yshapeproc.cpp @@ -270,10 +270,9 @@ int main(int argc, const char* argv[]) { // load mesh auto ioerror = ""s; print_progress("load shape", 0, 1); - auto ext = path(filename).extension().string(); - auto basename = path(filename).stem().string(); - if (ext == ".ypreset") { - if (!make_shape_preset(shape, basename, ioerror)) print_fatal(ioerror); + if (path{filename}.extension().string() == ".ypreset") { + if (!make_shape_preset(shape, path{filename}.stem().string(), ioerror)) + print_fatal(ioerror); } else { if (!load_shape(filename, shape, ioerror, facevarying)) print_fatal(ioerror); diff --git a/apps/yshapeview/yshapeview.cpp b/apps/yshapeview/yshapeview.cpp index 5aa58bf21..1e259ff16 100644 --- a/apps/yshapeview/yshapeview.cpp +++ b/apps/yshapeview/yshapeview.cpp @@ -100,9 +100,9 @@ void load_shape_async( app_states* apps, const string& filename, const string& camera_name = "") { auto app = apps->states.emplace_back(new app_state{}); app->filename = filename; - app->imagename = path(filename).replace_extension(".png").string(); - app->outname = path(filename).replace_extension(".edited.obj").string(); - app->name = path(app->filename).filename().string(); + app->imagename = path{filename}.replace_extension(".png").string(); + app->outname = path{filename}.replace_extension(".edited.obj").string(); + app->name = path{app->filename}.filename().string(); app->drawgl_prms = apps->drawgl_prms; app->status = "load"; app->loader = std::async(std::launch::async, [app, camera_name]() { @@ -233,8 +233,8 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { } continue_line(win); if (draw_filedialog_button(win, "save", apps->selected && apps->selected->ok, - "save", save_path, true, path(save_path).parent_path().string(), - path(save_path).filename().string(), "*.ply;*.obj")) { + "save", save_path, true, path{save_path}.parent_path().string(), + path{save_path}.filename().string(), "*.ply;*.obj")) { auto app = apps->selected; app->outname = save_path; auto ok = save_shape(app->outname, *app->ioshape, app->error); @@ -297,7 +297,7 @@ void draw_widgets(gui_window* win, app_states* apps, const gui_input& input) { end_header(win); } if (begin_header(win, "inspect")) { - draw_label(win, "shape", path(app->filename).filename().string()); + draw_label(win, "shape", path{app->filename}.filename().string()); draw_label(win, "filename", app->filename); draw_label(win, "outname", app->outname); draw_label(win, "imagename", app->imagename); diff --git a/libs/yocto/yocto_modelio.cpp b/libs/yocto/yocto_modelio.cpp index 8e254f10e..e894a5a53 100644 --- a/libs/yocto/yocto_modelio.cpp +++ b/libs/yocto/yocto_modelio.cpp @@ -1925,7 +1925,7 @@ bool load_obj(const string& filename, obj_model* obj, string& error, if (std::find(mtllibs.begin(), mtllibs.end(), mtllib) == mtllibs.end()) { mtllibs.push_back(mtllib); if (!load_mtl( - (path(filename).parent_path() / mtllib).string(), obj, error)) + (path{filename}.parent_path() / mtllib).string(), obj, error)) return dependent_error(); for (auto material : obj->materials) material_map[material->name] = material; @@ -1973,8 +1973,8 @@ bool load_obj(const string& filename, obj_model* obj, string& error, if (geom_only) return true; // load extensions - auto extfilename = path(filename).replace_extension(".objx"); - if (exists(path(extfilename))) { + auto extfilename = path{filename}.replace_extension(".objx"); + if (exists(path{extfilename})) { if (!load_objx(extfilename.string(), obj, error)) return dependent_error(); } @@ -2278,7 +2278,7 @@ inline void format_obj_value(string& str, const obj_vertex& value) { // save material library if (!obj->materials.empty()) { if (!format_obj_values(fs, "mtllib {}\n\n", - (path(filename).filename().replace_extension(".mtl").string()))) + (path{filename}.filename().replace_extension(".mtl").string()))) return write_error(); } @@ -2326,7 +2326,7 @@ inline void format_obj_value(string& str, const obj_vertex& value) { // save mtl if (!obj->materials.empty()) { if (!save_mtl( - path(filename).replace_extension(".mtl").string(), obj, error)) + path{filename}.replace_extension(".mtl").string(), obj, error)) return dependent_error(); } @@ -2335,7 +2335,7 @@ inline void format_obj_value(string& str, const obj_vertex& value) { std::any_of(obj->shapes.begin(), obj->shapes.end(), [](auto shape) { return !shape->instances.empty(); })) { if (!save_objx( - path(filename).replace_extension(".objx").string(), obj, error)) + path{filename}.replace_extension(".objx").string(), obj, error)) return dependent_error(); } @@ -3567,18 +3567,18 @@ inline pair get_subsurface(const string& name) { auto filenames = vector{}; if (!parse_pbrt_value(str, filename)) return false; if (!str.data()) return false; - auto filenamep = path(filename).filename(); - if (path(filenamep).extension() == ".spd") { - filenamep = path(filenamep).replace_extension("").string(); + auto filenamep = path{filename}.filename(); + if (path{filenamep}.extension() == ".spd") { + filenamep = path{filenamep}.replace_extension("").string(); if (filenamep == "SHPS") { value.value3f = {1, 1, 1}; - } else if (path(filenamep).extension() == ".eta") { + } else if (path{filenamep}.extension() == ".eta") { auto eta = - get_etak(path(filenamep).replace_extension("").string()).first; + get_etak(path{filenamep}.replace_extension("").string()).first; value.value3f = {eta.x, eta.y, eta.z}; - } else if (path(filenamep).extension() == ".k") { + } else if (path{filenamep}.extension() == ".k") { auto k = - get_etak(path(filenamep).replace_extension("").string()).second; + get_etak(path{filenamep}.replace_extension("").string()).second; value.value3f = {k.x, k.y, k.z}; } else { return false; @@ -4725,7 +4725,7 @@ struct pbrt_context { } else if (cmd == "Include") { auto includename = ""s; if (!parse_param(str, includename)) return parse_error(); - if (!load_pbrt((path(filename).parent_path() / includename).string(), + if (!load_pbrt((path{filename}.parent_path() / includename).string(), pbrt, error, ctx, material_map, named_materials, named_textures, named_mediums, ply_dirname)) return dependent_error(); @@ -4768,7 +4768,7 @@ bool load_pbrt(const string& filename, pbrt_model* pbrt, string& error) { auto named_materials = unordered_map{{"", {}}}; auto named_mediums = unordered_map{{"", {}}}; auto named_textures = unordered_map{{"", {}}}; - auto dirname = path(filename).parent_path().string(); + auto dirname = path{filename}.parent_path().string(); if (dirname != "") dirname += "/"; if (!load_pbrt(filename, pbrt, error, ctx, material_map, named_materials, named_textures, named_mediums, dirname)) @@ -5044,7 +5044,7 @@ bool save_pbrt( add_normals(ply, shape->normals); add_texcoords(ply, shape->texcoords); add_triangles(ply, shape->triangles); - if (!save_ply((path(filename).parent_path() / shape->filename_).string(), + if (!save_ply((path{filename}.parent_path() / shape->filename_).string(), ply, error)) return dependent_error(); } diff --git a/libs/yocto/yocto_sceneio.cpp b/libs/yocto/yocto_sceneio.cpp index 0043fb3e7..d2d6913ba 100644 --- a/libs/yocto/yocto_sceneio.cpp +++ b/libs/yocto/yocto_sceneio.cpp @@ -100,7 +100,7 @@ static bool save_pbrt_scene(const string& filename, const scene_model* scene, // Load a scene bool load_scene(const string& filename, scene_model* scene, string& error, progress_callback progress_cb, bool noparallel) { - auto ext = path(filename).extension(); + auto ext = path{filename}.extension(); if (ext == ".json" || ext == ".JSON") { return load_json_scene(filename, scene, error, progress_cb, noparallel); } else if (ext == ".obj" || ext == ".OBJ") { @@ -119,7 +119,7 @@ bool load_scene(const string& filename, scene_model* scene, string& error, // Save a scene bool save_scene(const string& filename, const scene_model* scene, string& error, progress_callback progress_cb, bool noparallel) { - auto ext = path(filename).extension(); + auto ext = path{filename}.extension(); if (ext == ".json" || ext == ".JSON") { return save_json_scene(filename, scene, error, progress_cb, noparallel); } else if (ext == ".obj" || ext == ".OBJ") { @@ -697,10 +697,10 @@ static bool load_json_scene(const string& filename, scene_model* scene, auto get_filename = [filename](const string& name, const string& group, const vector& extensions) { for (auto& extension : extensions) { - auto filepath = path(filename).parent_path() / group / (name + extension); + auto filepath = path{filename}.parent_path() / group / (name + extension); if (exists(filepath)) return filepath; } - return path(filename).parent_path() / group / (name + extensions.front()); + return path{filename}.parent_path() / group / (name + extensions.front()); }; // load shapes @@ -769,7 +769,7 @@ static bool load_json_scene(const string& filename, scene_model* scene, } // fix scene - if (scene->name == "") scene->name = path(filename).stem().string(); + if (scene->name == "") scene->name = path{filename}.stem().string(); add_cameras(scene); add_radius(scene); add_materials(scene); @@ -903,7 +903,7 @@ static bool save_json_scene(const string& filename, const scene_model* scene, // get filename from name auto get_filename = [filename](const string& name, const string& group, const string& extension) { - return path(filename).parent_path() / group / (name + extension); + return path{filename}.parent_path() / group / (name + extension); }; // save shapes @@ -1095,7 +1095,7 @@ static bool load_obj_scene(const string& filename, scene_model* scene, // get filename from name auto get_filename = [filename](const string& name) { - return path(filename).parent_path() / name; + return path{filename}.parent_path() / name; }; // load textures @@ -1117,7 +1117,7 @@ static bool load_obj_scene(const string& filename, scene_model* scene, } // fix scene - if (scene->name == "") scene->name = path(filename).stem().string(); + if (scene->name == "") scene->name = path{filename}.stem().string(); add_cameras(scene); add_radius(scene); add_materials(scene); @@ -1148,7 +1148,7 @@ static bool save_obj_scene(const string& filename, const scene_model* scene, // convert cameras for (auto camera : scene->cameras) { auto ocamera = add_camera(obj); - ocamera->name = path(camera->name).stem().string(); + ocamera->name = path{camera->name}.stem().string(); ocamera->frame = camera->frame; ocamera->ortho = camera->orthographic; ocamera->width = camera->film; @@ -1171,7 +1171,7 @@ static bool save_obj_scene(const string& filename, const scene_model* scene, {nullptr, nullptr}}; for (auto material : scene->materials) { auto omaterial = add_material(obj); - omaterial->name = path(material->name).stem().string(); + omaterial->name = path{material->name}.stem().string(); omaterial->illum = 2; omaterial->as_pbr = true; omaterial->pbr_emission = material->emission; @@ -1225,7 +1225,7 @@ static bool save_obj_scene(const string& filename, const scene_model* scene, // convert environments for (auto environment : scene->environments) { auto oenvironment = add_environment(obj); - oenvironment->name = path(environment->name).stem().string(); + oenvironment->name = path{environment->name}.stem().string(); oenvironment->frame = environment->frame; oenvironment->emission = environment->emission; oenvironment->emission_tex = get_texture(environment->emission_tex); @@ -1240,7 +1240,7 @@ static bool save_obj_scene(const string& filename, const scene_model* scene, // get filename from name auto get_filename = [filename](const string& name, const string& group, const string& extension) { - return path(filename).parent_path() / group / (name + extension); + return path{filename}.parent_path() / group / (name + extension); }; // save textures @@ -1370,7 +1370,7 @@ static bool load_gltf_scene(const string& filename, scene_model* scene, if (progress_cb) progress_cb("load scene", progress.x++, progress.y); // load buffers - auto dirname = path(filename).parent_path().string(); + auto dirname = path{filename}.parent_path().string(); if (dirname != "") dirname += "/"; if (cgltf_load_buffers(¶ms, data, dirname.c_str()) != cgltf_result_success) @@ -1701,7 +1701,7 @@ static bool load_gltf_scene(const string& filename, scene_model* scene, ctexture_map.erase(""); for (auto [tpath, texture] : ctexture_map) { if (progress_cb) progress_cb("load texture", progress.x++, progress.y); - if (!load_image((path(filename).parent_path() / tpath).string(), + if (!load_image((path{filename}.parent_path() / tpath).string(), texture->colorf, texture->colorb, error)) return dependent_error(); } @@ -1712,7 +1712,7 @@ static bool load_gltf_scene(const string& filename, scene_model* scene, if (progress_cb) progress_cb("load texture", progress.x++, progress.y); auto color_opacityf = image{}; auto color_opacityb = image{}; - if (!load_image((path(filename).parent_path() / tpath).string(), + if (!load_image((path{filename}.parent_path() / tpath).string(), color_opacityf, color_opacityb, error)) return dependent_error(); if (!color_opacityf.empty()) { @@ -1751,7 +1751,7 @@ static bool load_gltf_scene(const string& filename, scene_model* scene, if (progress_cb) progress_cb("load texture", progress.x++, progress.y); auto metallic_roughnessf = image{}; auto metallic_roughnessb = image{}; - if (!load_image((path(filename).parent_path() / tpath).string(), + if (!load_image((path{filename}.parent_path() / tpath).string(), metallic_roughnessf, metallic_roughnessb, error)) return dependent_error(); if (!metallic_roughnessf.empty()) { @@ -1798,7 +1798,7 @@ static bool load_gltf_scene(const string& filename, scene_model* scene, scene->textures.end()); // fix scene - if (scene->name == "") scene->name = path(filename).stem().string(); + if (scene->name == "") scene->name = path{filename}.stem().string(); add_cameras(scene); add_radius(scene); add_materials(scene); @@ -1957,7 +1957,7 @@ static bool load_pbrt_scene(const string& filename, scene_model* scene, // get filename from name auto get_filename = [filename](const string& name) { - return path(filename).parent_path() / name; + return path{filename}.parent_path() / name; }; // load texture @@ -1990,7 +1990,7 @@ static bool load_pbrt_scene(const string& filename, scene_model* scene, } // fix scene - if (scene->name == "") scene->name = path(filename).stem().string(); + if (scene->name == "") scene->name = path{filename}.stem().string(); add_cameras(scene); add_radius(scene); add_materials(scene); @@ -2033,7 +2033,7 @@ static bool save_pbrt_scene(const string& filename, const scene_model* scene, auto material_map = unordered_map{}; for (auto material : scene->materials) { auto pmaterial = add_material(pbrt); - pmaterial->name = path(material->name).stem().string(); + pmaterial->name = path{material->name}.stem().string(); pmaterial->emission = material->emission; pmaterial->color = material->color; pmaterial->metallic = material->metallic; @@ -2051,7 +2051,7 @@ static bool save_pbrt_scene(const string& filename, const scene_model* scene, for (auto instance : scene->instances) { auto pshape = add_shape(pbrt); pshape->filename_ = - path(instance->shape->name).replace_extension(".ply").string(); + path{instance->shape->name}.replace_extension(".ply").string(); pshape->frame = instance->frame; pshape->frend = instance->frame; pshape->material = material_map.at(instance->material); @@ -2076,7 +2076,7 @@ static bool save_pbrt_scene(const string& filename, const scene_model* scene, // get filename from name auto get_filename = [filename](const string& name, const string& group, const string& extension) { - return path(filename).parent_path() / group / (name + extension); + return path{filename}.parent_path() / group / (name + extension); }; // save textures diff --git a/libs/yocto_gui/yocto_gui.cpp b/libs/yocto_gui/yocto_gui.cpp index 8bd06edae..223d38184 100644 --- a/libs/yocto_gui/yocto_gui.cpp +++ b/libs/yocto_gui/yocto_gui.cpp @@ -2306,7 +2306,7 @@ struct filedialog_state { void refresh() { entries.clear(); - for (auto entry : directory_iterator(path(dirname))) { + for (auto entry : directory_iterator(path{dirname})) { if (remove_hidden && entry.path().stem().string()[0] == '.') continue; if (entry.is_directory()) { entries.push_back({entry.path().stem().string() + "/", true});