Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/native/corehost/hostmisc/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,21 @@ bool utils::ends_with(const pal::string_t& value, const pal::char_t* suffix, siz

void append_path(pal::string_t* path1, const pal::char_t* path2)
{
if (pal::is_path_rooted(path2))
if (pal::strlen(path2) == 0)
return;

if (path1->empty())
{
path1->assign(path2);
return;
}
else

if (path1->back() != DIR_SEPARATOR && path2[0] != DIR_SEPARATOR)
{
if (!path1->empty() && path1->back() != DIR_SEPARATOR)
{
path1->push_back(DIR_SEPARATOR);
}
path1->append(path2);
path1->push_back(DIR_SEPARATOR);
}

path1->append(path2);
}

pal::string_t strip_executable_ext(const pal::string_t& filename)
Expand Down
4 changes: 4 additions & 0 deletions src/native/corehost/hostmisc/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ pal::string_t get_directory(const pal::string_t& path);
pal::string_t strip_file_ext(const pal::string_t& path);
pal::string_t get_filename(const pal::string_t& path);
pal::string_t get_filename_without_ext(const pal::string_t& path);

// Concatenate path1 and path2 into path1, ensuring there is a directory separator.
// This does not check for rooted paths or make any attempt to root the returned path.
void append_path(pal::string_t* path1, const pal::char_t* path2);

bool file_exists_in_dir(const pal::string_t& dir, const pal::char_t* file_name, pal::string_t* out_file_path);
bool coreclr_exists_in_dir(const pal::string_t& candidate);
void remove_trailing_dir_separator(pal::string_t* dir);
Expand Down
Loading