Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
63e11558
Commit
63e11558
authored
Oct 05, 2011
by
Frédéric Delanoy
Committed by
Alexandre Julliard
Oct 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd: Improve handle type recognition in WCMD_ReadFile.
parent
e2fd09c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
wcmdmain.c
programs/cmd/wcmdmain.c
+17
-19
No files found.
programs/cmd/wcmdmain.c
View file @
63e11558
...
@@ -233,6 +233,11 @@ void WCMD_leave_paged_mode(void)
...
@@ -233,6 +233,11 @@ void WCMD_leave_paged_mode(void)
pagedMessage
=
NULL
;
pagedMessage
=
NULL
;
}
}
static
inline
BOOL
is_console_handle
(
HANDLE
h
)
{
return
(((
DWORD_PTR
)
h
)
&
3
)
==
3
;
}
/***************************************************************************
/***************************************************************************
* WCMD_Readfile
* WCMD_Readfile
*
*
...
@@ -240,30 +245,23 @@ void WCMD_leave_paged_mode(void)
...
@@ -240,30 +245,23 @@ void WCMD_leave_paged_mode(void)
*/
*/
BOOL
WCMD_ReadFile
(
const
HANDLE
hIn
,
WCHAR
*
intoBuf
,
const
DWORD
maxChars
,
LPDWORD
charsRead
)
BOOL
WCMD_ReadFile
(
const
HANDLE
hIn
,
WCHAR
*
intoBuf
,
const
DWORD
maxChars
,
LPDWORD
charsRead
)
{
{
BOOL
res
;
DWORD
numRead
;
char
*
buffer
;
/* Try to read from console as Unicode */
res
=
ReadConsoleW
(
hIn
,
intoBuf
,
maxChars
,
charsRead
,
NULL
);
/* If reading from console has failed we assume its file
i/o so read in and convert from OEM codepage */
if
(
!
res
)
{
DWORD
numRead
;
if
(
is_console_handle
(
hIn
))
char
*
buffer
;
/* Try to read from console as Unicode */
return
ReadConsoleW
(
hIn
,
intoBuf
,
maxChars
,
charsRead
,
NULL
);
if
(
!
(
buffer
=
get_file_buffer
()))
/* We assume it's a file handle and read then convert from assumed OEM codepage */
return
FALSE
;
if
(
!
(
buffer
=
get_file_buffer
()))
return
FALSE
;
/* Read from file (assume OEM codepage) */
if
(
!
ReadFile
(
hIn
,
buffer
,
maxChars
,
&
numRead
,
NULL
))
re
s
=
ReadFile
(
hIn
,
buffer
,
maxChars
,
&
numRead
,
NULL
)
;
re
turn
FALSE
;
/* Convert from OEM */
*
charsRead
=
MultiByteToWideChar
(
GetConsoleCP
(),
0
,
buffer
,
numRead
,
intoBuf
,
maxChars
);
*
charsRead
=
MultiByteToWideChar
(
GetConsoleCP
(),
0
,
buffer
,
numRead
,
intoBuf
,
maxChars
);
}
return
TRUE
;
return
res
;
}
}
/*******************************************************************
/*******************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment