Skip to content

Commit 2924735

Browse files
committed
Finalize the changes to ice::Path and ice::HeapPath types.
#ICE-214 State In Review
1 parent dacfaa4 commit 2924735

File tree

15 files changed

+60
-42
lines changed

15 files changed

+60
-42
lines changed

source/code/core/utils/public/ice/native_file.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ namespace ice::native_file
166166
(ice::native_file::path_join_string(result, ice::forward<Strings>(strings)), ...);
167167
if constexpr (ice::has_all(Flags, PathFlags::Normalized))
168168
{
169-
ice::path::normalize(result);
169+
result.normalize();
170170
}
171171
return result;
172172
}

source/code/core/utils/public/ice/path_utils.hxx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,28 @@ namespace ice
134134
struct HeapPathString : public PathString
135135
{
136136
template<typename Self>
137-
auto append(this Self& self, ice::path::Path<Self> other) noexcept -> ice::path::Path<Self>
137+
auto join(this Self& self, ice::path::Path<Self> other) noexcept -> ice::path::Path<Self>
138138
{
139139
return ice::path::Path<Self>{ ice::path::join(self, other) };
140140
}
141+
142+
template<typename Self>
143+
auto normalize(this Self& self) noexcept -> ice::path::Path<Self>
144+
{
145+
return ice::path::Path<Self>{ ice::path::normalize(self) };
146+
}
147+
148+
template<typename Self>
149+
auto replace_filename(this Self& self, ice::string::String<Self> filename) noexcept -> ice::path::Path<Self>
150+
{
151+
return ice::path::Path<Self>{ ice::path::replace_filename(self, filename) };
152+
}
153+
154+
template<typename Self>
155+
auto replace_extension(this Self& self, ice::string::String<Self> extension) noexcept -> ice::path::Path<Self>
156+
{
157+
return ice::path::Path<Self>{ ice::path::replace_extension(self, extension) };
158+
}
141159
};
142160

143161
template<ice::concepts::SupportedCharType CharT>

source/code/framework/framework_base/private/framework_main.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ struct ice::app::Config
9494
, assets{ alloc }
9595
{ }
9696

97-
ice::HeapString<> shaders;
98-
ice::HeapString<> assets;
97+
ice::HeapPath shaders;
98+
ice::HeapPath assets;
9999
} dev_dirs;
100100
};
101101

@@ -334,10 +334,10 @@ auto ice_setup(
334334
config.dev_dirs.assets = ice::app::workingdir();
335335

336336
// Assumes the apps working-dir is in 'build' and no changes where done to shader compilation step
337-
ice::path::join(config.dev_dirs.shaders, "obj/VkShaders/GFX-Vulkan-Unoptimized-vk-glslc-1-3/data");
338-
ice::path::join(config.dev_dirs.assets, "../source/data");
339-
ice::path::normalize(config.dev_dirs.shaders);
340-
ice::path::normalize(config.dev_dirs.assets);
337+
config.dev_dirs.shaders.join("obj/VkShaders/GFX-Vulkan-Unoptimized-vk-glslc-1-3/data");
338+
config.dev_dirs.assets.join("../source/data");
339+
config.dev_dirs.shaders.normalize();
340+
config.dev_dirs.assets.normalize();
341341
config.dev_dirs.shaders.push_back('/');
342342
config.dev_dirs.assets.push_back('/');
343343
resource_paths.push_back(config.dev_dirs.assets);

source/code/platforms/platform_win32/private/win32_storage.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace ice::platform::win32
2222
namespace detail
2323
{
2424

25-
void get_known_path(ice::HeapString<>& out_path, const GUID& known_path_guid, ice::String appname = {})
25+
void get_known_path(ice::HeapPath& out_path, const GUID& known_path_guid, ice::String appname = {})
2626
{
2727
PWSTR path;
2828
if (SHGetKnownFolderPath(known_path_guid, KF_FLAG_CREATE, NULL, &path) == S_OK)
@@ -37,7 +37,7 @@ namespace ice::platform::win32
3737
out_path.push_back(appname);
3838
out_path.push_back('\\');
3939
}
40-
ice::path::normalize(out_path);
40+
out_path.normalize();
4141
CoTaskMemFree(path);
4242
}
4343
}
@@ -124,7 +124,7 @@ namespace ice::platform::win32
124124
// GetTempPathW already returns a path ending with a slash character.
125125
DWORD const len = GetTempPathW(256, tempbuff);
126126
ice::wide_to_utf8_append({ tempbuff, ice::u32(len) }, _temp_location);
127-
ice::path::normalize(_temp_location);
127+
_temp_location.normalize();
128128
}
129129

130130
} // namespace ice

source/code/systems/resource_system/private/resource_filesystem_baked.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ namespace ice
198198

199199
ice::HeapPath utf8_file_path{ alloc };
200200
ice::native_file::path_to_string(file_path, utf8_file_path);
201-
ice::path::normalize(utf8_file_path);
201+
utf8_file_path.normalize();
202202
IPT_ZONE_TEXT_STR(utf8_file_path);
203203

204204
ice::HeapString<> utf8_uri{ alloc };

source/code/systems/resource_system/private/resource_filesystem_loose.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ namespace ice
318318
{
319319
ice::HeapPath utf8_file_path{ alloc };
320320
ice::native_file::path_to_string(data_filepath, utf8_file_path);
321-
ice::path::normalize(utf8_file_path);
321+
utf8_file_path.normalize();
322322
IPT_ZONE_TEXT_STR(utf8_file_path);
323323

324324
// TODO: Decide how to handle the basepath naming.

source/code/systems/resource_system/private/resource_filesystem_writable.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ namespace ice
263263
{
264264
ice::HeapPath utf8_file_path{ alloc };
265265
ice::native_file::path_to_string(data_filepath, utf8_file_path);
266-
ice::path::normalize(utf8_file_path);
266+
utf8_file_path.normalize();
267267
IPT_ZONE_TEXT_STR(utf8_file_path);
268268

269269
// TODO: Decide how to handle the basepath naming.

source/code/systems/resource_system/private/resource_provider_custom.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ namespace ice
142142
0, origin_size - ice::Path{ root_resource->name() }.filename().size()
143143
);
144144

145-
predicted_path.append(relative_uri.path());
146-
ice::path::normalize(predicted_path);
145+
predicted_path.join(relative_uri.path());
146+
predicted_path.normalize();
147147

148148
ice::u64 const resource_hash = ice::hash(ice::String{ predicted_path });
149149

source/code/systems/resource_system/private/resource_provider_dynlib.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace ice
2525
, _resources{ _allocator }
2626
{
2727
ice::native_file::path_from_string(_base_path, path);
28-
ice::path::normalize(_base_path);
28+
_base_path.normalize();
2929
}
3030

3131
~ResourceProvider_DynLibs() noexcept override

source/code/systems/resource_system/private/resource_provider_filelist.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,11 @@ namespace ice
174174

175175
ice::FileSystemResource* found_resource = nullptr;
176176

177-
ice::HeapString<> predicted_path{ (ice::Allocator&)_named_allocator };
177+
ice::HeapPath predicted_path{ (ice::Allocator&)_named_allocator };
178178
for (ice::FileListEntry const& file_entry : _file_paths)
179179
{
180180
ice::native_file::path_to_string(file_entry.path, predicted_path);
181-
ice::path::normalize(predicted_path);
181+
predicted_path.normalize();
182182

183183
if (found_resource = _resources.get(uri.path(), nullptr); found_resource != nullptr)
184184
{
@@ -228,8 +228,8 @@ namespace ice
228228
0, origin_size - ice::Path{ root_resource->name() }.filename().size()
229229
);
230230

231-
predicted_path.append(relative_uri.path());
232-
ice::path::normalize(predicted_path);
231+
predicted_path.join(relative_uri.path());
232+
predicted_path.normalize();
233233

234234
ice::FileSystemResource const* found_resource = _resources.get(predicted_path, nullptr);
235235
if (found_resource != nullptr)

0 commit comments

Comments
 (0)