Skip to content

Commit 368e0c8

Browse files
committed
fix
1 parent 6eeed4d commit 368e0c8

File tree

4 files changed

+31
-24
lines changed

4 files changed

+31
-24
lines changed

include/geode/basic/detail/geode_input_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace geode
4444
if( object.name() == Identifier::DEFAULT_NAME )
4545
{
4646
IdentifierBuilder{ object }.set_name(
47-
filename_without_extension( filename ) );
47+
filename_without_extension( filename ).string() );
4848
}
4949
}
5050

@@ -55,7 +55,7 @@ namespace geode
5555
if( object->name() == Identifier::DEFAULT_NAME )
5656
{
5757
IdentifierBuilder{ *object }.set_name(
58-
filename_without_extension( filename ) );
58+
filename_without_extension( filename ).string() );
5959
}
6060
}
6161

include/geode/basic/detail/geode_output_impl.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ namespace geode
6060
{
6161
const Timer timer;
6262
auto output = geode_object_output_writer< Factory >( filename );
63-
std::filesystem::create_directories(
64-
filepath_without_filename( filename ) );
63+
const auto directories = filepath_without_filename( filename );
64+
if( !directories.empty() )
65+
{
66+
std::filesystem::create_directories( directories );
67+
}
6568
auto result = output->write( object );
6669
Logger::info(
6770
type, " saved in ", filename, " in ", timer.duration() );

include/geode/basic/filename.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,23 @@
2323

2424
#pragma once
2525

26+
#include <filesystem>
27+
2628
#include <geode/basic/common.h>
2729

2830
namespace geode
2931
{
30-
std::string opengeode_basic_api filename_with_extension(
31-
std::string_view path );
32+
std::filesystem::path opengeode_basic_api filename_with_extension(
33+
const std::filesystem::path& path );
3234

33-
std::string opengeode_basic_api filename_without_extension(
34-
std::string_view path );
35+
std::filesystem::path opengeode_basic_api filename_without_extension(
36+
const std::filesystem::path& path );
3537

36-
std::string opengeode_basic_api filepath_without_extension(
37-
std::string_view path );
38+
std::filesystem::path opengeode_basic_api filepath_without_extension(
39+
const std::filesystem::path& path );
3840

39-
std::string opengeode_basic_api filepath_without_filename(
40-
std::string_view path );
41+
std::filesystem::path opengeode_basic_api filepath_without_filename(
42+
const std::filesystem::path& path );
4143

4244
std::string_view opengeode_basic_api extension_from_filename(
4345
std::string_view filename );

src/geode/basic/filename.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,30 @@
2828

2929
namespace geode
3030
{
31-
std::string filename_with_extension( std::string_view path )
31+
std::filesystem::path filename_with_extension(
32+
const std::filesystem::path& path )
3233
{
33-
const std::filesystem::path filepath{ to_string( path ) };
34-
return filepath.filename().string();
34+
return path.filename();
3535
}
3636

37-
std::string filename_without_extension( std::string_view path )
37+
std::filesystem::path filename_without_extension(
38+
const std::filesystem::path& path )
3839
{
39-
const std::filesystem::path filepath{ to_string( path ) };
40-
return filepath.filename().replace_extension( "" ).string();
40+
return path.filename().replace_extension( "" ).string();
4141
}
4242

43-
std::string filepath_without_extension( std::string_view path )
43+
std::filesystem::path filepath_without_extension(
44+
const std::filesystem::path& path )
4445
{
45-
std::filesystem::path filepath{ to_string( path ) };
46-
return filepath.replace_extension( "" ).string();
46+
auto filepath = path;
47+
return filepath.replace_extension( "" );
4748
}
4849

49-
std::string filepath_without_filename( std::string_view path )
50+
std::filesystem::path filepath_without_filename(
51+
const std::filesystem::path& path )
5052
{
51-
std::filesystem::path filepath{ to_string( path ) };
52-
return filepath.replace_filename( "" ).string();
53+
auto filepath = path;
54+
return filepath.remove_filename();
5355
}
5456

5557
std::string_view extension_from_filename( std::string_view filename )

0 commit comments

Comments
 (0)