9#if !defined(HPP_ALIB_FILES_FILEEXPRESSIONS)
16#if ( defined(__GLIBCXX__) \
17 || defined(__APPLE__) \
18 || defined(__ANDROID_NDK__) ) && !defined(ALIB_TESTSTDFS)
34 #define ES ExpressionScope
35 #define FS dynamic_cast<FileExpressions::FexScope&>(scope)
36 #define AI ArgIterator
38 #define VAL FS.Node.Value()
39 #define INTARG0 args->Unbox<integer>()
40 Box getName (ES& scope, AI , AI) {
return MAString(scope.Allocator, NODE.Name(), 0); }
41 Box getType (ES& scope, AI , AI) {
return VAL.Type(); }
42 Box isDirectory(ES& scope, AI , AI) {
return VAL.IsDirectory(); }
43 Box isSymLink (ES& scope, AI , AI) {
return VAL.IsSymbolicLink(); }
44 Box getSize (ES& scope, AI , AI) {
return integer(VAL.Size()); }
45 Box getTime (ES& scope, AI , AI) {
return VAL.MTime(); }
46 Box getCTime (ES& scope, AI , AI) {
return VAL.CTime(); }
47 Box getATime (ES& scope, AI , AI) {
return VAL.ATime(); }
48 Box getPerms (ES& scope, AI , AI) {
return VAL.Perms(); }
49 Box getOwner (ES& scope, AI , AI) {
return VAL.Owner(); }
50 Box getGroup (ES& scope, AI , AI) {
return VAL.Group(); }
51#if ( (defined(__GLIBCXX__) && !defined(__MINGW32__)) \
52 || defined(__APPLE__) \
53 || defined(__ANDROID_NDK__) ) && !defined(ALIB_TESTSTDFS)
60 Box kiloBytes (ES& , AI args, AI) {
return INTARG0 *
integer(1024); }
61 Box megaBytes (ES& , AI args, AI) {
return INTARG0 *
integer(1024) *
integer(1024); }
66 Box getPath (ES& scope, AI , AI) {
return MAString(scope.Allocator, FS.ParentPath, 0); }
74 extern Box constOwnRead ;
Box constOwnRead ;
75 extern Box constOwnWrite ;
Box constOwnWrite;
76 extern Box constOwnExec ;
Box constOwnExec ;
77 extern Box constGrpRead ;
Box constGrpRead ;
78 extern Box constGrpWrite ;
Box constGrpWrite;
79 extern Box constGrpExec ;
Box constGrpExec ;
80 extern Box constOthRead ;
Box constOthRead ;
81 extern Box constOthWrite ;
Box constOthWrite;
82 extern Box constOthExec ;
Box constOthExec ;
84 extern Box constTDirectory ;
Box constTDirectory ;
85 extern Box constTSymbolicLinkDir ;
Box constTSymbolicLinkDir;
86 extern Box constTRegular ;
Box constTRegular ;
87 extern Box constTSymbolicLink ;
Box constTSymbolicLink ;
88 extern Box constTBlock ;
Box constTBlock ;
89 extern Box constTCharacter ;
Box constTCharacter ;
90 extern Box constTFifo ;
Box constTFifo ;
91 extern Box constTSocket ;
Box constTSocket ;
93 extern Box TypeUsrGrpID ;
Box TypeUsrGrpID ;
105:
Calculus(
"Files Plug-in", pCompiler )
108 constOwnRead = FInfo::Permissions::OWNER_READ ;
132 constexpr int tableSize= 38;
133 Token functionNames[tableSize];
137 Token* descriptor= functionNames;
151 { *descriptor++, constOwnRead },
152 { *descriptor++, constOwnWrite },
153 { *descriptor++, constOwnExec },
154 { *descriptor++, constGrpRead },
155 { *descriptor++, constGrpWrite },
156 { *descriptor++, constGrpExec },
157 { *descriptor++, constOthRead },
158 { *descriptor++, constOthWrite },
159 { *descriptor++, constOthExec },
161 { *descriptor++, constTDirectory },
162 { *descriptor++, constTSymbolicLinkDir },
163 { *descriptor++, constTRegular },
164 { *descriptor++, constTSymbolicLink },
165 { *descriptor++, constTBlock },
166 { *descriptor++, constTCharacter },
167 { *descriptor++, constTFifo },
168 { *descriptor++, constTSocket },
227, scope( pFex.compiler.CfgFormatter )
230 if( !
expression->ResultType().IsType<
bool>() )
231 throw std::runtime_error(
"Expression result type mismatch: expecting boolean result!" );
virtual ALIB_API SPExpression Compile(const String &expressionString)
ALIB_API void AddType(Type sample, const NString &name)
ALIB_API void SetupDefaults()
@ DIRECTORY
Directory/folder.
@ CHARACTER
A character special file.
@ BLOCK
A block special file.
@ FIFO
A FIFO (also known as pipe) file.
static constexpr TOwnerAndGroupID UnknownID
uint32_t TOwnerAndGroupID
@ GROUP_READ
< S_IRWXU File owner has read, write, and execute/search permissions Equivalent to owner_read | owner...
@ GROUP_EXEC
< S_IWGRP The file's user group has write permission
@ OTHERS_EXEC
S_IXOTH Other users have execute/search permission.
@ GROUP_WRITE
< S_IRGRP The file's user group has read permission
@ OWNER_EXEC
< S_IWUSR File owner has write permission
@ OWNER_WRITE
< S_IRUSR File owner has read permission
@ OTHERS_READ
< S_IRWXG The file's user group has read, write, and execute/search permissions Equivalent to group_r...
@ OTHERS_WRITE
S_IWOTH Other users have write permission.
SPExpression expression
The compiled expression.
FileExpressions & fex
The scope used with this filter.
Plugin plugin
The file expression Plugin.
Compiler compiler
The expression compiler.
ALIB_API FileExpressions()
ALIB_API SPFileFilter CreateFilter(const String &expressionString)
const String & GetResource(const NString &name)
void InsertPlugin(TPlugin *plugin, TPriorities priority, lang::Responsibility responsibility=lang::Responsibility::KeepWithSender)
static ALIB_API void LoadResourcedTokens(lang::resources::ResourcePool &resourcePool, const NString &resourceCategory, const NString &resourceName, strings::util::Token *target, int dbgSizeVerifier, character outerSeparator=',', character innerSeparator=' ')
#define CALCULUS_DEFAULT_AUTOCAST
#define CALCULUS_CALLBACK(func)
#define CALCULUS_SIGNATURE(BoxPointerArray)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
std::shared_ptr< FFilter > SPFileFilter
monomem::TMAString< character > MAString
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
static ALIB_API Box * I[1]
Function accepts one integral argument.
static ALIB_API Box DateTime
static ALIB_API Box Integer
static ALIB_API Box Boolean
static ALIB_API Box String
std::vector< ConstantIdentifierEntry > ConstantIdentifiers
std::vector< FunctionEntry > Functions
static constexpr CTInvokable ETI
std::vector< AutoCastEntry > AutoCasts