Skip to content

Commit

Permalink
Merge pull request #149 from ecmwf/feature/localPathName_append
Browse files Browse the repository at this point in the history
Feature/local path name append
  • Loading branch information
simondsmart authored Nov 13, 2024
2 parents 127ab50 + c74365f commit cceb069
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/eckit/filesystem/LocalPathName.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "eckit/config/LibEcKit.h"
#include "eckit/config/Resource.h"
#include "eckit/filesystem/BasePathNameT.h"
#include "eckit/filesystem/PathName.h"
#include "eckit/filesystem/PathNameFactory.h"
#include "eckit/filesystem/StdDir.h"
#include "eckit/io/FileHandle.h"
Expand Down Expand Up @@ -149,6 +150,9 @@ static void init() {

//----------------------------------------------------------------------------------------------------------------------

LocalPathName::LocalPathName(const PathName& path) :
LocalPathName(path.path(), false, true) {}

LocalPathName LocalPathName::baseName(bool ext) const {
const char* q = path_.c_str();
int n = -1;
Expand Down Expand Up @@ -415,6 +419,18 @@ void operator>>(Stream& s, LocalPathName& path) {
s >> path.path_;
}

LocalPathName operator/(const LocalPathName& p1, const LocalPathName& p2) {
bool tildeIsUserHome = false;
bool skipTildeExpansion = true;
return eckit::LocalPathName(p1.path() + "/" + p2.path(), tildeIsUserHome, skipTildeExpansion);
}

LocalPathName operator/(const LocalPathName& p1, const char* p2) {
bool tildeIsUserHome = false;
bool skipTildeExpansion = true;
return eckit::LocalPathName(p1.path() + "/" + p2, tildeIsUserHome, skipTildeExpansion);
}

LocalPathName LocalPathName::fullName() const {
if (path_.length() > 0 && path_[0] != '/') {
char buf[PATH_MAX];
Expand Down
6 changes: 6 additions & 0 deletions src/eckit/filesystem/LocalPathName.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace eckit {
class Length;
class DataHandle;
class BasePathName;
class PathName;

struct FileSystemSize;

Expand All @@ -54,6 +55,7 @@ class LocalPathName {
tidy(tildeIsUserHome, skipTildeExpansion);
}
}
explicit LocalPathName(const PathName& path);
LocalPathName(const LocalPathName& p) :
path_(p.path_) {}

Expand Down Expand Up @@ -279,6 +281,10 @@ class LocalPathName {
friend LocalPathName operator+(const LocalPathName& p, const char* s) { return LocalPathName(p.path_ + s); }

friend LocalPathName operator+(const LocalPathName& p, char s) { return LocalPathName(p.path_ + s); }

friend LocalPathName operator/(const LocalPathName& p1, const LocalPathName& p2);

friend LocalPathName operator/(const LocalPathName& p1, const char* p2);
};

template <>
Expand Down

0 comments on commit cceb069

Please sign in to comment.