Skip to content

Commit

Permalink
#63 - Make sure that tokens are initiated before usage (linker order …
Browse files Browse the repository at this point in the history
…issue).
  • Loading branch information
PerMalmberg committed Aug 18, 2019
1 parent 3fae154 commit ae82b06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
6 changes: 1 addition & 5 deletions lib/smooth/core/filesystem/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

namespace smooth::core::filesystem
{
const std::string Path::separator = "/";
const std::string Path::dot_token = ".";
const std::string Path::dot_dot_token = "..";

void Path::append(const std::string& path)
{
if (p.empty())
Expand Down Expand Up @@ -128,7 +124,7 @@ namespace smooth::core::filesystem

auto absolute = is_absolute();

if (p.find(dot_dot_token) != std::string::npos || p.find('.') != std::string::npos)
if (p.find(dot_dot_token) != std::string::npos || p.find(dot_token) != std::string::npos)
{
auto prev = p.begin();
auto pos = std::search(p.begin(), p.end(), separator.begin(), separator.end());
Expand Down
25 changes: 13 additions & 12 deletions lib/smooth/include/smooth/core/filesystem/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,32 @@ namespace smooth::core::filesystem

bool operator!=(const char* p) const;

bool is_parent_of(const Path& child) const;
[[nodiscard]] bool is_parent_of(const Path& child) const;

Path parent() const;
[[nodiscard]] Path parent() const;

bool has_parent() const;
[[nodiscard]] bool has_parent() const;

bool is_relative() const
[[nodiscard]] bool is_relative() const
{
return !is_absolute();
}

bool is_absolute() const
[[nodiscard]] bool is_absolute() const
{
return !p.empty() && p[0] == '/';
}

bool empty() const
[[nodiscard]] bool empty() const
{
return p.empty();
}

std::string extension() const;
[[nodiscard]] std::string extension() const;

bool has_extension() const;
[[nodiscard]] bool has_extension() const;

const std::string str() const
[[nodiscard]] std::string str() const
{
return p;
}
Expand All @@ -147,9 +147,10 @@ namespace smooth::core::filesystem

bool contains_dots(const std::string& s);

static const std::string separator;
static const std::string dot_token;
static const std::string dot_dot_token;
std::string p;

std::string separator = "/";
std::string dot_token = ".";
std::string dot_dot_token = "..";
};
}

0 comments on commit ae82b06

Please sign in to comment.