Mercurial > vim
comparison src/os_win32.c @ 8443:6c421014a0b3 v7.4.1512
commit https://github.com/vim/vim/commit/94d0191dbcce829ad9b92d902b6e2717041db3b8
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Mar 8 13:48:51 2016 +0100
patch 7.4.1512
Problem: Channel input from file not supported on MS-Windows.
Solution: Implement it. (Yasuhiro Matsumoto)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 08 Mar 2016 14:00:05 +0100 |
parents | 800423dbc260 |
children | 20533e3de373 |
comparison
equal
deleted
inserted
replaced
8442:d2dd8de62539 | 8443:6c421014a0b3 |
---|---|
5037 saAttr.bInheritHandle = TRUE; | 5037 saAttr.bInheritHandle = TRUE; |
5038 saAttr.lpSecurityDescriptor = NULL; | 5038 saAttr.lpSecurityDescriptor = NULL; |
5039 if (use_file_for_in) | 5039 if (use_file_for_in) |
5040 { | 5040 { |
5041 char_u *fname = options->jo_io_name[PART_IN]; | 5041 char_u *fname = options->jo_io_name[PART_IN]; |
5042 | 5042 #ifdef FEAT_MBYTE |
5043 // TODO | 5043 WCHAR *wn = NULL; |
5044 EMSG2(_(e_notopen), fname); | 5044 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) |
5045 goto failed; | 5045 { |
5046 wn = enc_to_utf16(fname, NULL); | |
5047 if (wn != NULL) | |
5048 { | |
5049 ifd[0] = CreateFileW(wn, GENERIC_WRITE, FILE_SHARE_READ, | |
5050 &saAttr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | |
5051 vim_free(wn); | |
5052 if (ifd[0] == INVALID_HANDLE_VALUE | |
5053 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) | |
5054 wn = NULL; | |
5055 } | |
5056 } | |
5057 if (wn == NULL) | |
5058 #endif | |
5059 | |
5060 ifd[0] = CreateFile((LPCSTR)fname, GENERIC_READ, FILE_SHARE_READ, | |
5061 &saAttr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | |
5062 if (ifd[0] == INVALID_HANDLE_VALUE) | |
5063 { | |
5064 EMSG2(_(e_notopen), fname); | |
5065 goto failed; | |
5066 } | |
5046 } | 5067 } |
5047 else if (!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0) | 5068 else if (!CreatePipe(&ifd[0], &ifd[1], &saAttr, 0) |
5048 || !pSetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0)) | 5069 || !pSetHandleInformation(ifd[1], HANDLE_FLAG_INHERIT, 0)) |
5049 goto failed; | 5070 goto failed; |
5050 | 5071 |
5086 job->jv_proc_info = pi; | 5107 job->jv_proc_info = pi; |
5087 job->jv_job_object = jo; | 5108 job->jv_job_object = jo; |
5088 job->jv_status = JOB_STARTED; | 5109 job->jv_status = JOB_STARTED; |
5089 | 5110 |
5090 # ifdef FEAT_CHANNEL | 5111 # ifdef FEAT_CHANNEL |
5091 CloseHandle(ifd[0]); | 5112 if (!use_file_for_in) |
5113 CloseHandle(ifd[0]); | |
5092 CloseHandle(ofd[1]); | 5114 CloseHandle(ofd[1]); |
5093 if (!use_out_for_err) | 5115 if (!use_out_for_err) |
5094 CloseHandle(efd[1]); | 5116 CloseHandle(efd[1]); |
5095 | 5117 |
5096 job->jv_channel = channel; | 5118 job->jv_channel = channel; |
5097 channel_set_pipes(channel, (sock_T)ifd[1], (sock_T)ofd[0], | 5119 channel_set_pipes(channel, |
5098 use_out_for_err ? INVALID_FD : (sock_T)efd[0]); | 5120 use_file_for_in ? INVALID_FD : (sock_T)ifd[1], |
5121 (sock_T)ofd[0], | |
5122 use_out_for_err ? INVALID_FD : (sock_T)efd[0]); | |
5099 channel_set_job(channel, job, options); | 5123 channel_set_job(channel, job, options); |
5100 # ifdef FEAT_GUI | 5124 # ifdef FEAT_GUI |
5101 channel_gui_register(channel); | 5125 channel_gui_register(channel); |
5102 # endif | 5126 # endif |
5103 # endif | 5127 # endif |
5104 return; | 5128 return; |
5105 | 5129 |
5106 failed: | 5130 failed: |
5107 # ifdef FEAT_CHANNEL | 5131 # ifdef FEAT_CHANNEL |