ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
ftvalue.cpp
1
2using namespace alib::system;
3namespace alib::filetree {
4
5void FTValue::SetLinkTarget(FTree& tree, const PathString& target, const PathString& realTarget) {
6 EISymLinkFile& ei= *static_cast<EISymLinkFile*>(extendedInfo);
7 auto& pool= tree.Pool;
8
9 // delete old values
10 if( ei.RealTarget.Length() && ei.RealTarget.Buffer() != ei.Target.Buffer() )
11 ei.RealTarget.Free(pool);
12 ei.Target.Free(pool);
13
14 // allocate target
15 ei.Target.Allocate(pool, target);
16
17 // real target is same?
18 if( realTarget.Equals(target) )
19 ei.RealTarget= ei.Target;
20 else
21 ei.RealTarget.Allocate(pool, realTarget);
22}
23
25 #if !defined ( _WIN32)
26 auto key= fInfo.Owner();
27 auto resultPair= ownerCache.Try( key );
28 if( !resultPair.first ) {
29 auto* result= getpwuid(key);
30 resultPair.second.Construct( key, NString(result ? result->pw_name : "?"));
31 }
32 return resultPair.second.Mapped();
33 #else
34 (void) fInfo;
35 return "?";
36 #endif
37}
38
40 #if !defined ( _WIN32)
41 auto key= fInfo.Group();
42 auto resultPair= groupCache.Try( key );
43 if( !resultPair.first ) {
44 auto* result= getgrgid(key);
45 resultPair.second.Construct( key, NString(result ? result->gr_name : "?"));
46 }
47 return resultPair.second.Mapped();
48 #else
49 (void) fInfo;
50 return "?";
51 #endif
52}
53} // namespace [alib::filetree]
ExtendedEntryInfo * extendedInfo
Extended information, depending on the entry type.
Definition ftvalue.hpp:151
void SetLinkTarget(FTree &tree, const PathString &target, const PathString &realTarget)
Definition ftvalue.cpp:5
PoolAllocator Pool
Definition ftree.hpp:159
const NString GetGroupName(const FileStatus &descriptor) const
Definition ftvalue.cpp:39
const NString GetOwnerName(const FileStatus &descriptor) const
Definition ftvalue.cpp:24
void Allocate(TAllocator &allocator, const TString< TChar > &copy)
Definition cstring.hpp:330
void Free(TAllocator &allocator) const
Definition cstring.hpp:352
constexpr integer Length() const
Definition string.hpp:300
constexpr const TChar * Buffer() const
Definition string.hpp:295
bool Equals(const TString< TChar > &rhs) const
Definition string.hpp:515
constexpr uint32_t Owner() const noexcept
constexpr uint32_t Group() const noexcept
strings::TString< nchar > NString
Type alias in namespace #"%alib".
Definition string.hpp:2174
strings::TString< PathCharType > PathString
The string-type used with this ALib Module.
Definition path.hpp:34
system::FileStatus FileStatus
Type alias in namespace #"%alib".
CPathString RealTarget
The resolved real target path.
Definition ftvalue.hpp:139
CPathString Target
The target path. This is a zero-terminated #"%CString".
Definition ftvalue.hpp:138