Changeset 95844 in vbox
- Timestamp:
- Jul 26, 2022 9:43:10 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/nocrt-streams-win.cpp
r93115 r95844 35 35 36 36 #include <iprt/ctype.h> 37 #include <iprt/file.h> 37 38 #include <iprt/string.h> 38 39 … … 44 45 typedef struct PRINTFBUF 45 46 { 46 HANDLE h Handle;47 HANDLE hNative; 47 48 size_t offBuf; 48 49 char szBuf[128]; … … 52 53 { 53 54 int iStream; 54 HANDLE hHandle; 55 HANDLE hNative; 56 RTFILE hFile; 55 57 }; 56 58 … … 59 61 * Defined Constants And Macros * 60 62 *********************************************************************************************************************************/ 63 #define MAKE_SURE_WE_HAVE_HFILE_RETURN(a_pStream) do { \ 64 if ((a_pStream)->hFile != NIL_RTFILE) \ 65 break; \ 66 int rc = RTFileFromNative(&(a_pStream)->hFile, (uintptr_t)(a_pStream)->hNative); \ 67 AssertRCReturn(rc, rc); \ 68 } while (0) 69 70 71 /********************************************************************************************************************************* 72 * Global Variables * 73 *********************************************************************************************************************************/ 61 74 RTSTREAM g_aStdStreams[3] = 62 75 { 63 { 0, NULL },64 { 1, NULL },65 { 2, NULL },76 { 0, NULL, NIL_RTFILE }, 77 { 1, NULL, NIL_RTFILE }, 78 { 2, NULL, NIL_RTFILE }, 66 79 }; 67 80 … … 76 89 if (pParams) 77 90 { 78 g_pStdIn->h Handle = pParams->StandardInput;79 g_pStdOut->h Handle = pParams->StandardOutput;80 g_pStdErr->h Handle = pParams->StandardError;91 g_pStdIn->hNative = pParams->StandardInput; 92 g_pStdOut->hNative = pParams->StandardOutput; 93 g_pStdErr->hNative = pParams->StandardError; 81 94 } 82 95 } … … 88 101 { 89 102 DWORD cbWritten = 0; 90 WriteFile(pBuf->h Handle, pBuf->szBuf, (DWORD)pBuf->offBuf, &cbWritten, NULL);103 WriteFile(pBuf->hNative, pBuf->szBuf, (DWORD)pBuf->offBuf, &cbWritten, NULL); 91 104 pBuf->offBuf = 0; 92 105 pBuf->szBuf[0] = '\0'; … … 127 140 { 128 141 PRINTFBUF Buf; 129 Buf.h Handle = pStream->hHandle;142 Buf.hNative = pStream->hNative; 130 143 Buf.offBuf = 0; 131 144 Buf.szBuf[0] = '\0'; … … 148 161 { 149 162 PRINTFBUF Buf; 150 Buf.h Handle = g_pStdOut->hHandle;163 Buf.hNative = g_pStdOut->hNative; 151 164 Buf.offBuf = 0; 152 165 Buf.szBuf[0] = '\0'; … … 165 178 } 166 179 180 181 #if 0 182 RTR3DECL(int) RTStrmReadEx(PRTSTREAM pStream, void *pvBuf, size_t cbToRead, size_t *pcbRead) 183 { 184 MAKE_SURE_WE_HAVE_HFILE_RETURN(pStream); 185 return RTFileRead(pStream->hFile, pvBuf, cbToRead, pcbRead); 186 } 187 #endif 188 189 190 RTR3DECL(int) RTStrmWriteEx(PRTSTREAM pStream, const void *pvBuf, size_t cbToWrite, size_t *pcbWritten) 191 { 192 MAKE_SURE_WE_HAVE_HFILE_RETURN(pStream); 193 return RTFileWrite(pStream->hFile, pvBuf, cbToWrite, pcbWritten); 194 } 195 196 197 RTR3DECL(int) RTStrmFlush(PRTSTREAM pStream) 198 { 199 MAKE_SURE_WE_HAVE_HFILE_RETURN(pStream); 200 return RTFileFlush(pStream->hFile); 201 } 202 203 204 RTR3DECL(int) RTStrmSetMode(PRTSTREAM pStream, int fBinary, int fCurrentCodeSet) 205 { 206 AssertReturn(fBinary != (int)false, VERR_NOT_IMPLEMENTED); 207 AssertReturn(fCurrentCodeSet <= (int)false, VERR_NOT_IMPLEMENTED); 208 RT_NOREF(pStream); 209 return VINF_SUCCESS; 210 } 211
Note:
See TracChangeset
for help on using the changeset viewer.