////////////////////////////////////////////////////////////////////////// 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 //////////////////////////////////////////////////////////////////////////
| 1021 | // Argument : const TSTRING& strFile |
| 1022 | /////////////////////////////////////////////////////////////////////////////// |
| 1023 | bool 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 | //////////////////////////////////////////////////////////////////////////////// |
no test coverage detected