MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / util_FileIsExecutable

Function util_FileIsExecutable

src/core/unixfsservices.cpp:1023–1033  ·  view source on GitHub ↗

////////////////////////////////////////////////////////////////////////// Function name : util_FileIsExecutable Description : file ( or file a link points to ) must be a regular file and executable by someone Return type : bool Argument : const TSTRING& strFile //////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

1021// Argument : const TSTRING& strFile
1022///////////////////////////////////////////////////////////////////////////////
1023bool util_FileIsExecutable(const TSTRING& strFile)
1024{
1025 if (strFile.empty())
1026 return false;
1027
1028 struct stat s;
1029 if (stat(strFile.c_str(), &s) < 0) // this call handles links
1030 return false;
1031
1032 return (S_ISREG(s.st_mode) && (s.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))); // can someone execute it?
1033}
1034
1035
1036////////////////////////////////////////////////////////////////////////////////

Callers 1

util_PathFindFunction · 0.85

Calls 3

emptyMethod · 0.80
c_strMethod · 0.80
statClass · 0.70

Tested by

no test coverage detected