equal
deleted
inserted
replaced
27 #include <io.h> |
27 #include <io.h> |
28 #include <stdio.h> |
28 #include <stdio.h> |
29 #include <string.h> |
29 #include <string.h> |
30 #include <malloc.h> |
30 #include <malloc.h> |
31 |
31 |
|
32 void report_error() |
|
33 { |
|
34 LPVOID lpMsgBuf; |
|
35 DWORD dw = GetLastError(); |
|
36 |
|
37 FormatMessage( |
|
38 FORMAT_MESSAGE_ALLOCATE_BUFFER | |
|
39 FORMAT_MESSAGE_FROM_SYSTEM | |
|
40 FORMAT_MESSAGE_IGNORE_INSERTS, |
|
41 NULL, |
|
42 dw, |
|
43 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), |
|
44 (LPTSTR) &lpMsgBuf, |
|
45 0, |
|
46 NULL); |
|
47 |
|
48 fprintf(stderr, |
|
49 "Could not start process! Failed with error %d: %s\n", |
|
50 dw, lpMsgBuf); |
|
51 |
|
52 LocalFree(lpMsgBuf); |
|
53 } |
|
54 |
32 /* |
55 /* |
33 * Test if pos points to /cygdrive/_/ where _ can |
56 * Test if pos points to /cygdrive/_/ where _ can |
34 * be any character. |
57 * be any character. |
35 */ |
58 */ |
36 int is_cygdrive_here(int pos, char *in, int len) |
59 int is_cygdrive_here(int pos, char *in, int len) |
254 char *line; |
277 char *line; |
255 int i; |
278 int i; |
256 DWORD exitCode; |
279 DWORD exitCode; |
257 |
280 |
258 if (argc<3 || argv[1][0] != '-' || (argv[1][1] != 'c' && argv[1][1] != 'm')) { |
281 if (argc<3 || argv[1][0] != '-' || (argv[1][1] != 'c' && argv[1][1] != 'm')) { |
259 fprintf(stderr, "Usage: fixpath -c|m<path@path@...> /cygdrive/c/WINDOWS/notepad.exe /cygdrive/c/x/test.txt"); |
282 fprintf(stderr, "Usage: fixpath -c|m<path@path@...> /cygdrive/c/WINDOWS/notepad.exe /cygdrive/c/x/test.txt\n"); |
260 exit(0); |
283 exit(0); |
261 } |
284 } |
262 |
285 |
263 if (getenv("DEBUG_FIXPATH") != NULL) { |
286 if (getenv("DEBUG_FIXPATH") != NULL) { |
264 fprintf(stderr, "fixpath input line >%s<\n", strstr(GetCommandLine(), argv[1])); |
287 fprintf(stderr, "fixpath input line >%s<\n", strstr(GetCommandLine(), argv[1])); |
306 0, |
329 0, |
307 0, |
330 0, |
308 0, |
331 0, |
309 &si, |
332 &si, |
310 &pi); |
333 &pi); |
311 if(!rc) |
334 if(!rc) { |
312 { |
335 // Could not start process for some reason. Try to report why: |
313 //Could not start process; |
336 report_error(); |
314 fprintf(stderr, "Could not start process!\n"); |
337 exit(rc); |
315 exit(-1); |
|
316 } |
338 } |
317 |
339 |
318 WaitForSingleObject(pi.hProcess,INFINITE); |
340 WaitForSingleObject(pi.hProcess,INFINITE); |
319 GetExitCodeProcess(pi.hProcess,&exitCode); |
341 GetExitCodeProcess(pi.hProcess,&exitCode); |
320 |
342 |