| 655 | } |
| 656 | |
| 657 | int kwsysProcess_SetWorkingDirectory(kwsysProcess* cp, char const* dir) |
| 658 | { |
| 659 | if (!cp) { |
| 660 | return 0; |
| 661 | } |
| 662 | if (cp->WorkingDirectory) { |
| 663 | free(cp->WorkingDirectory); |
| 664 | cp->WorkingDirectory = 0; |
| 665 | } |
| 666 | if (dir && dir[0]) { |
| 667 | wchar_t* wdir = kwsysEncoding_DupToWide(dir); |
| 668 | /* We must convert the working directory to a full path. */ |
| 669 | DWORD length = GetFullPathNameW(wdir, 0, NULL, NULL); |
| 670 | if (length > 0) { |
| 671 | wchar_t* work_dir = malloc(length * sizeof(wchar_t)); |
| 672 | if (!work_dir) { |
| 673 | free(wdir); |
| 674 | return 0; |
| 675 | } |
| 676 | if (!GetFullPathNameW(wdir, length, work_dir, NULL)) { |
| 677 | free(work_dir); |
| 678 | free(wdir); |
| 679 | return 0; |
| 680 | } |
| 681 | cp->WorkingDirectory = work_dir; |
| 682 | } |
| 683 | free(wdir); |
| 684 | } |
| 685 | return 1; |
| 686 | } |
| 687 | |
| 688 | int kwsysProcess_SetPipeFile(kwsysProcess* cp, int pipe, char const* file) |
| 689 | { |
no test coverage detected
searching dependent graphs…