Changeset 64 for trunk/src/helpers/dosh.c
- Timestamp:
- Apr 26, 2001, 10:21:31 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/dosh.c
r63 r64 2186 2186 2187 2187 /* 2188 *@@ doshFindExecutable:2189 * this searches the PATH for the specified pcszCommand2190 * by calling DosSearchPath.2191 *2192 * papcszExtensions determines if additional searches are to be2193 * performed if DosSearchPath returns ERROR_FILE_NOT_FOUND.2194 * This must point to an array of strings specifying the extra2195 * extensions to search for.2196 *2197 * If both papcszExtensions and cExtensions are null, no2198 * extra searches are performed.2199 *2200 * If this returns NO_ERROR, pszExecutable receives2201 * the full path of the executable found by DosSearchPath.2202 * Otherwise ERROR_FILE_NOT_FOUND is returned.2203 *2204 * Example:2205 *2206 + const char *aExtensions[] = { "EXE",2207 + "COM",2208 + "CMD"2209 + };2210 + CHAR szExecutable[CCHMAXPATH];2211 + APIRET arc = doshFindExecutable("lvm",2212 + szExecutable,2213 + sizeof(szExecutable),2214 + aExtensions,2215 + 3);2216 *2217 *@@added V0.9.9 (2001-03-07) [umoeller]2218 */2219 2220 APIRET doshFindExecutable(const char *pcszCommand, // in: command (e.g. "lvm")2221 PSZ pszExecutable, // out: full path (e.g. "F:\os2\lvm.exe")2222 ULONG cbExecutable, // in: sizeof (*pszExecutable)2223 const char **papcszExtensions, // in: array of extensions (without dots)2224 ULONG cExtensions) // in: array item count2225 {2226 APIRET arc = DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY,2227 "PATH",2228 (PSZ)pcszCommand,2229 pszExecutable,2230 cbExecutable);2231 if ( (arc == ERROR_FILE_NOT_FOUND) // not found?2232 && (cExtensions) // any extra searches wanted?2233 )2234 {2235 // try additional things then2236 PSZ psz2 = (PSZ)malloc(strlen(pcszCommand) + 20);2237 if (psz2)2238 {2239 ULONG ul;2240 for (ul = 0;2241 ul < cExtensions;2242 ul++)2243 {2244 const char *pcszExtThis = papcszExtensions[ul];2245 sprintf(psz2, "%s.%s", pcszCommand, pcszExtThis);2246 arc = DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY,2247 "PATH",2248 psz2,2249 pszExecutable,2250 cbExecutable);2251 if (arc != ERROR_FILE_NOT_FOUND)2252 break;2253 }2254 2255 free(psz2);2256 }2257 else2258 arc = ERROR_NOT_ENOUGH_MEMORY;2259 }2260 2261 return (arc);2262 }2263 2264 /*2265 2188 *@@ doshExecVIO: 2266 2189 * executes cmd.exe with the /c parameter
Note:
See TracChangeset
for help on using the changeset viewer.