8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
16#if !defined ( _WIN32 )
26 import ALib.Characters.Functions;
28 import ALib.Strings.Calendar;
30 import ALib.Expressions;
51 int perms= int(Value().Perms());
63 "This method is not compatible due to changes in the permission enumeration." );
66 std::array<char, 9> result;
67 std::array<char, 3> chars = {
'r',
'w',
'x'};
71 result[charIdx]= perms & bit ? chars[charIdx % 3] :
'-';
101 while (
format.IsNotEmpty() ) {
111 while (
format.ConsumeChar(c) )
120 auto& value= Value();
128 case 'a' : toBeAdded= Name();
break;
129 case 's' : toBeAdded=
Stem();
break;
130 case 'e' : toBeAdded=
Extension();
break;
136 pathBuffer << Name();
138 toBeAdded= pathBuffer;
143 ALIB_WARNING(
"ALIB",
"Format Error: Token 'n' followed by unknown "
144 "specifier '{}' in File::Format.", c )
145 target <<
"Format Error: Token 'n' followed by unknown specifier '" << c
146 <<
"' in File::Format.";
154 toBeAdded= strBuffer;
161 else toBeAdded= value.Type();
171 strBuffer <<
" -> " << value.GetLinkTarget();
172 if( value.GetRealLinkTarget().IsNotEmpty()
173 && !value.GetLinkTarget().Equals( value.GetRealLinkTarget()) )
174 strBuffer <<
" (" << value.GetRealLinkTarget() <<
")";
175 toBeAdded= strBuffer;
182 case 'x' : toBeAdded= (value.IsCrossingFS() ?
'm' :
'-') ;
break;
183 case 'a' : toBeAdded= (value.IsArtificialFS() ?
'm' :
'-') ;
break;
186 ALIB_WARNING(
"ALIB",
"Format Error: Unknown character {} after "
187 "token 'f' in File::Format.", c )
188 target <<
"Format Error: Unknown character '" << c
189 <<
"' after token 'f' in File::Format.";
195 toBeAdded= value.QtyHardLinks();
200 else toBeAdded= value.Quality();
207 case 'm' : date= value.MDate();
break;
208 case 'b' : date= value.BDate();
break;
209 case 'c' : date= value.CDate();
break;
210 case 'a' : date= value.ADate();
break;
214 "Format Error: Unknown character {} after token 'd' "
215 "in File::Format.", c )
216 target <<
"Format Error: Unknown character '" << c
217 <<
"' after token 'd' in File::Format.";
223 dateFormat=
A_CHAR(
"dd. MMM yyyy HH:mm");
224 date.
Format( dateFormat, strBuffer );
225 toBeAdded= strBuffer;
231 bool automaticMode =
true;
232 auto unit = ByteSizeUnits::IEC;
235 if(
format.CharAtStart() ==
'(' ) {
238 unit= ByteSizeUnits::SI;
245 automaticMode=
false;
248 if(
format.ConsumeChar() !=
')' ) {
250 "Format Error: Expected closing brace ')' after unit specification with token 's'." )
251 target <<
"Format Error: Expected closing brace ')' after unit specification with token 's'.";
256 if( !automaticMode ) {
260 if( unit==ByteSizeUnits::B || unit ==ByteSizeUnits::B_SI )
263 strBuffer <<
alib::Dec( dval , 0, ftreeNF);
268 toBeAdded= strBuffer;
275 bool isOwner= c==
'o';
278 if( c !=
'i' && c !=
'n' ) {
280 "Format Error: Expected 'i' or 'n' specifier after token 'o' and 'g'."
282 target <<
"Format Error: Expected 'i' or 'n' specifier after token 'o' and 'g'."
283 " Given: '" << c <<
"'";
286 bool isName= (c ==
'n');
290 toBeAdded= isOwner ? resolver.GetOwnerName(value)
291 : resolver.GetGroupName(value);
293 strBuffer << (isOwner ? value.Owner() : value.Group());
294 toBeAdded= strBuffer;
304 if( !value.IsDirectory()
320 "Format Error: Token 'r' followed by unknown specifier '{}' "
321 "in File::Format", c )
322 target <<
"Format Error: Token 'r' followed by unknown specifier '" << c
323 <<
"'in File::Format";
344 ALIB_WARNING(
"ALIB",
"Format Error: Missing single Quote" )
345 target <<
"Format Error: Missing closing single quote character <'>" ;
363 if(
format.CharAtStart() ==
'{' ) {
368 if(
format.ConsumeChar() !=
'}' ) {
370 "Format Error: Expected closing brace '}' with field specifier {width/alignment}." )
371 target <<
"Format Error: Expected closing brace '}' with field specifier {width/alignment}.";
374 target <<
Field( toBeAdded, width, alignment );
381 target.
ToUpper(previousLength);
389 :
FILES.GetResource(
"FFMT"),
404void AppendableTraits<files::File,nchar, lang::HeapAllocator>::operator()(
NAString& target,
411void AppendableTraits<files::File,wchar, lang::HeapAllocator>::operator()(
412 TAString<wchar, lang::HeapAllocator>& target,
413 const files::File& file ) {
constexpr CharacterType Separator() const noexcept
@ 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.
OwnerAndGroupResolver & GetOGResolver()
NumberFormat & GetNumberFormat()
ALIB_DLL AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep, NumberFormat *numberFormat=nullptr) const
Path & AssemblePath(Path &target, lang::CurrentData targetData=lang::CurrentData::Clear) const
system::PathString Extension() const
AString & FormatAccessRights(AString &target) const
ALIB_WARNINGS_RESTORE 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
ALIB_DLL AString & Format(Substring format, AString &target, lang::CurrentData targetData=lang::CurrentData::Keep) const
#define ALIB_WARNING(domain,...)
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.
constexpr PathCharType DIRECTORY_SEPARATOR
The standard path separator character. Defaults to '\' on Windows OS, '/' else.
strings::TDec< character > Dec
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
format::ByteSizeIEC ByteSizeIEC
Type alias in namespace alib.
LocalString< 4096 > String4K
Type alias name for TLocalString<character,4096>.
lang::integer integer
Type alias in namespace alib.
strings::TField< character > Field
Type alias in namespace alib.
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
system::Path Path
Type alias in namespace alib.
strings::util::CalendarDateTime CalendarDateTime
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
files::FilesCamp FILES
The singleton instance of ALib Camp class FilesCamp.
strings::TString< character > String
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
lang::uinteger uinteger
Type alias in namespace alib.
strings::TSubstring< character > Substring
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