8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Configuration MACRO ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
16#if !defined ( _WIN32 )
25 import ALib.Characters.Functions;
27 import ALib.Strings.Calendar;
29 import ALib.Expressions;
49strings::TAString<system::PathCharType>&
53 static constexpr int STACK_SIZE= 32;
54 FTree::ConstCursorHandle nStack[STACK_SIZE];
56 File childNode= (*this);
61 if (childNode.IsRoot())
66 while( !childNode.IsRoot() ) {
69 if(sp == STACK_SIZE) {
73 nStack[sp++]= childNode.Export();
74 childNode= childNode.Parent();
84 FTree::CursorHandle ch;
85 ch.value= (nStack[sp]).value;
87 if( !actual.IsRoot() ) {
90 target << actual.Name();
100 int perms= int(Value().Perms());
112 "This method is not compatible due to changes in the permission enumeration." );
115 std::array<char, 9> result;
116 std::array<char, 3> chars = {
'r',
'w',
'x'};
120 result[charIdx]= perms & bit ? chars[charIdx % 3] :
'-';
150 while (
format.IsNotEmpty() ) {
160 while (
format.ConsumeChar(c) )
169 auto& value= Value();
177 case 'a' : toBeAdded= Name();
break;
178 case 's' : toBeAdded=
Stem();
break;
179 case 'e' : toBeAdded=
Extension();
break;
184 toBeAdded= pathBuffer;
190 toBeAdded= pathBuffer;
195 ALIB_WARNING(
"ALIB",
"Format Error: Token 'n' followed by unknown "
196 "specifier '{}' in File::Format.", c )
197 target <<
"Format Error: Token 'n' followed by unknown specifier '" << c
198 <<
"' in File::Format.";
206 toBeAdded= strBuffer;
213 else toBeAdded= value.Type();
223 strBuffer <<
" -> " << value.GetLinkTarget();
224 if( value.GetRealLinkTarget().IsNotEmpty()
225 && !value.GetLinkTarget().Equals( value.GetRealLinkTarget()) )
226 strBuffer <<
" (" << value.GetRealLinkTarget() <<
")";
227 toBeAdded= strBuffer;
233 if(value.symParent != 0) {
235 if constexpr (std::is_same_v<character, PathCharType>) {
241 strBuffer <<
" <- " << parentPath;
243 toBeAdded= strBuffer;
250 case 'x' : toBeAdded= (value.IsCrossingFS() ?
'm' :
'-') ;
break;
251 case 'a' : toBeAdded= (value.IsArtificialFS() ?
'm' :
'-') ;
break;
254 ALIB_WARNING(
"ALIB",
"Format Error: Unknown character {} after "
255 "token 'f' in File::Format.", c )
256 target <<
"Format Error: Unknown character '" << c
257 <<
"' after token 'f' in File::Format.";
263 toBeAdded= value.QtyHardLinks();
268 else toBeAdded= value.ScanState();
275 case 'm' : date= value.MDate();
break;
276 case 'b' : date= value.BDate();
break;
277 case 'c' : date= value.CDate();
break;
278 case 'a' : date= value.ADate();
break;
282 "Format Error: Unknown character {} after token 'd' "
283 "in File::Format.", c )
284 target <<
"Format Error: Unknown character '" << c
285 <<
"' after token 'd' in File::Format.";
291 dateFormat=
A_CHAR(
"dd. MMM yyyy HH:mm");
292 date.
Format( dateFormat, strBuffer );
293 toBeAdded= strBuffer;
299 bool automaticMode =
true;
300 auto unit = ByteSizeUnits::IEC;
303 if(
format.CharAtStart() ==
'(' ) {
306 unit= ByteSizeUnits::SI;
313 automaticMode=
false;
316 if(
format.ConsumeChar() !=
')' ) {
318 "Format Error: Expected closing brace ')' after unit specification with token 's'." )
319 target <<
"Format Error: Expected closing brace ')' after unit specification with token 's'.";
324 if( !automaticMode ) {
328 if( unit==ByteSizeUnits::B || unit ==ByteSizeUnits::B_SI )
331 strBuffer <<
alib::Dec( dval , 0, ftreeNF);
336 toBeAdded= strBuffer;
343 bool isOwner= c==
'o';
346 if( c !=
'i' && c !=
'n' ) {
348 "Format Error: Expected 'i' or 'n' specifier after token 'o' and 'g'."
350 target <<
"Format Error: Expected 'i' or 'n' specifier after token 'o' and 'g'."
351 " Given: '" << c <<
"'";
354 bool isName= (c ==
'n');
358 toBeAdded= isOwner ? resolver.GetOwnerName(value)
359 : resolver.GetGroupName(value);
361 strBuffer << (isOwner ? value.Owner() : value.Group());
362 toBeAdded= strBuffer;
372 if( !value.IsDirectory()
388 "Format Error: Token 'r' followed by unknown specifier '{}' "
389 "in File::Format", c )
390 target <<
"Format Error: Token 'r' followed by unknown specifier '" << c
391 <<
"'in File::Format";
412 ALIB_WARNING(
"ALIB",
"Format Error: Missing single Quote" )
413 target <<
"Format Error: Missing closing single quote character <'>" ;
431 if(
format.CharAtStart() ==
'{' ) {
436 if(
format.ConsumeChar() !=
'}' ) {
438 "Format Error: Expected closing brace '}' with field specifier {width/alignment}." )
439 target <<
"Format Error: Expected closing brace '}' with field specifier {width/alignment}.";
442 target <<
Field( toBeAdded, width, alignment );
449 target.
ToUpper(previousLength);
457 :
FILES.GetResource(
"FFMT"),
#define ALIB_WARNING(domain,...)
Cursor ImportCursor(CursorHandle handle)
@ RECURSIVE
Follow symlink target strings.
@ RESOLVED
Read symlink target strings.
@ GROUP_READ
Posix S_IRGRP: The file's user group has read permission.
@ GROUP_EXEC
Posix S_IXGRP: The file's user group has execute/search permission.
@ OTHERS_EXEC
Posix S_IXOTH: Other users have execute/search permission.
@ GROUP_WRITE
Posix S_IWGRP: The file's user group has write permission.
@ OWNER_READ
Posix S_IRUSR: File owner has read permission.
@ OWNER_EXEC
Posix S_IXUSR: File owner has execute/search permission.
@ OWNER_WRITE
Posix S_IWUSR: File owner has write permission.
@ OTHERS_READ
Posix S_IROTH: Other users have read permission.
@ OTHERS_WRITE
Posix S_IWOTH: Other users have write permission.
const OwnerAndGroupResolver & GetOGResolver() const
NumberFormat & GetNumberFormat()
AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep, NumberFormat *numberFormat=nullptr) const
File()=default
Defaulted default constructor.
system::PathString Extension() const
AString & FormatAccessRights(AString &target) const
strings::TAString< system::PathCharType > & AssembleSymbolicPath(strings::TAString< system::PathCharType > &target, lang::Inclusion includeFilename) const
strings::TAString< system::PathCharType > & AssembleRealPath(strings::TAString< system::PathCharType > &target, lang::Inclusion includeFilename) const
system::PathString Stem() const
TAString & InsertChars(TChar c, integer qty)
TAString & ToUpper(integer regionStart=0, integer regionLength=MAX_LEN)
TAString & _(const TAppendable &src)
constexpr integer Length() const
constexpr bool IsEmpty() const
constexpr bool IsNotEmpty() const
AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep) const
bool Parse(strings::TSubstring< TChar > &input, TEnum &result)
void FFormat_File(const Box &box, const String &formatSpec, NumberFormat &nf, AString &target)
Alignment
Denotes Alignments.
@ Right
Chooses right alignment.
@ Keep
Chooses not no clear existing data.
@ Clear
Chooses to clear existing data.
Inclusion
Denotes how members of a set something should be taken into account.
@ Exclude
Chooses exclusion.
@ Include
Chooses inclusion.
constexpr PathCharType DIRECTORY_SEPARATOR
The standard path separator character. Defaults to '\' on Windows OS, '/' else.
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
strings::TField< character > Field
Type alias in namespace alib.
LocalString< 4096 > String4K
Type alias name for #"TLocalString;TLocalString<character,4096>".
strings::TString< character > String
Type alias in namespace alib.
system::Path Path
Type alias in namespace alib.
strings::TDec< character > Dec
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
strings::util::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
files::FilesCamp FILES
The singleton instance of ALib Camp class #"FilesCamp".
format::ByteSizeIEC ByteSizeIEC
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
lang::uinteger uinteger
Type alias in namespace alib.
Recursively accumulated values for directories.
uint32_t QtyErrsAccess
Number of access errors in the folder and subfolders.
uint32_t CountNonDirectories() const noexcept
uint32_t QtyErrsBrokenLink
Number of broken symbolic links in the directory and its subfolders.
uint32_t CountDirectories() const noexcept