| 1087 | #pragma warning(disable : 6400) |
| 1088 | #endif |
| 1089 | bool IsExecutable(LPCWSTR aszFilePathName, wchar_t** rsExpandedVars /*= nullptr*/) |
| 1090 | { |
| 1091 | #ifndef __GNUC__ |
| 1092 | #pragma warning( push ) |
| 1093 | #pragma warning(disable : 6400) |
| 1094 | #endif |
| 1095 | bool result = false; |
| 1096 | CEStr expanded; |
| 1097 | |
| 1098 | for (int i = 0; i <= 1; i++) |
| 1099 | { |
| 1100 | // ReSharper disable once CppLocalVariableMayBeConst |
| 1101 | LPCWSTR extension = PointToExt(aszFilePathName); |
| 1102 | |
| 1103 | if (extension) // if .exe or .com was specified |
| 1104 | { |
| 1105 | if (lstrcmpiW(extension, L".exe")==0 || lstrcmpiW(extension, L".com")==0) |
| 1106 | { |
| 1107 | if (FileExists(aszFilePathName)) |
| 1108 | { |
| 1109 | result = true; |
| 1110 | break; |
| 1111 | } |
| 1112 | } |
| 1113 | } |
| 1114 | |
| 1115 | if (!i && wcschr(aszFilePathName, L'%')) |
| 1116 | { |
| 1117 | expanded = ExpandEnvStr(aszFilePathName); |
| 1118 | if (!expanded) |
| 1119 | break; |
| 1120 | aszFilePathName = expanded.c_str(); |
| 1121 | continue; |
| 1122 | } |
| 1123 | break; |
| 1124 | } |
| 1125 | |
| 1126 | if (rsExpandedVars) |
| 1127 | { |
| 1128 | SafeFree(*rsExpandedVars) |
| 1129 | *rsExpandedVars = expanded.Detach(); |
| 1130 | } |
| 1131 | |
| 1132 | return result; |
| 1133 | } |
| 1134 | #ifndef __GNUC__ |
| 1135 | #pragma warning( pop ) |
| 1136 | #endif |
no test coverage detected