-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FAM): add string support for property
- Loading branch information
1 parent
6d0c0cb
commit 95413af
Showing
11 changed files
with
127 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* (C) Copyright 1996- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence Version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation nor | ||
* does it submit to any jurisdiction. | ||
*/ | ||
|
||
/* | ||
* This software was developed as part of the Horizon Europe programme funded project OpenCUBE | ||
* (Grant agreement: 101092984) horizon-opencube.eu | ||
*/ | ||
|
||
#include "eckit/io/fam/FamProperty.h" | ||
|
||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
#include <string.h> | ||
|
||
namespace eckit { | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace { | ||
|
||
fam::perm_t stringToPerm(const std::string& perm) { | ||
return static_cast<fam::perm_t>(std::stoul(perm, nullptr, 8)); | ||
} | ||
|
||
std::string permToString(fam::perm_t perm) { | ||
char buf[5]; | ||
snprintf(buf, sizeof(buf), "%04o", perm); | ||
return std::string(buf); | ||
} | ||
|
||
} // namespace | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
FamProperty::FamProperty(fam::size_t size, fam::perm_t perm, std::string name, std::uint32_t uid, std::uint32_t gid) | ||
: size {size}, perm {perm}, name {std::move(name)}, uid {uid}, gid {gid} { } | ||
|
||
FamProperty::FamProperty(fam::size_t size, fam::perm_t perm, const std::string& name) | ||
: FamProperty(size, perm, name, getuid(), getgid()) { } | ||
|
||
FamProperty::FamProperty(fam::size_t size, fam::perm_t perm) : FamProperty(size, perm, "") { } | ||
|
||
FamProperty::FamProperty(fam::size_t size, const std::string& perm) : FamProperty(size, stringToPerm(perm)) { } | ||
|
||
void FamProperty::print(std::ostream& out) const { | ||
out << "Property[size=" << size << ", perm=" << perm << "(" << permToString(perm) << ")" << ",name=" << name | ||
<< ",uid=" << uid << ",gid=" << gid << "]"; | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
std::ostream& operator<<(std::ostream& out, const FamProperty& prop) { | ||
prop.print(out); | ||
return out; | ||
} | ||
|
||
//---------------------------------------------------------------------------------------------------------------------- | ||
|
||
} // namespace eckit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters