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
a747eca8
Commit
a747eca8
authored
Jun 02, 2007
by
Alexander Nicolaysen Sørnes
Committed by
Alexandre Julliard
Jun 04, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wordpad: Improve file reading code.
parent
a28f91f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
40 deletions
+11
-40
wordpad.c
programs/wordpad/wordpad.c
+11
-40
No files found.
programs/wordpad/wordpad.c
View file @
a747eca8
...
...
@@ -100,17 +100,16 @@ static void AddSeparator(HWND hwndToolBar)
SendMessage
(
hwndToolBar
,
TB_ADDBUTTONS
,
1
,
(
LPARAM
)
&
button
);
}
static
LPSTR
stream_buffer
;
static
LONG
stream_buffer_size
;
static
DWORD
CALLBACK
stream_in
(
DWORD_PTR
cookie
,
LPBYTE
buffer
,
LONG
cb
,
LONG
*
pcb
)
{
LONG
size
=
min
(
stream_buffer_size
,
cb
);
HANDLE
hFile
=
(
HANDLE
)
cookie
;
DWORD
read
;
if
(
!
ReadFile
(
hFile
,
buffer
,
cb
,
&
read
,
0
))
return
1
;
*
pcb
=
read
;
memcpy
(
buffer
,
stream_buffer
,
size
);
stream_buffer_size
-=
size
;
stream_buffer
+=
size
;
*
pcb
=
size
;
return
0
;
}
...
...
@@ -152,9 +151,6 @@ static void set_caption(LPCWSTR wszNewFileName)
static
void
DoOpenFile
(
LPCWSTR
szOpenFileName
)
{
HANDLE
hFile
;
LPSTR
pTemp
;
DWORD
size
;
DWORD
dwNumRead
;
EDITSTREAM
es
;
hFile
=
CreateFileW
(
szOpenFileName
,
GENERIC_READ
,
FILE_SHARE_READ
,
NULL
,
...
...
@@ -162,38 +158,13 @@ static void DoOpenFile(LPCWSTR szOpenFileName)
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
;
size
=
GetFileSize
(
hFile
,
NULL
);
if
(
size
==
INVALID_FILE_SIZE
)
{
CloseHandle
(
hFile
);
return
;
}
size
++
;
pTemp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
if
(
!
pTemp
)
{
CloseHandle
(
hFile
);
return
;
}
if
(
!
ReadFile
(
hFile
,
pTemp
,
size
,
&
dwNumRead
,
NULL
))
{
CloseHandle
(
hFile
);
HeapFree
(
GetProcessHeap
(),
0
,
pTemp
);
return
;
}
CloseHandle
(
hFile
);
pTemp
[
dwNumRead
]
=
0
;
memset
(
&
es
,
0
,
sizeof
(
es
));
es
.
dwCookie
=
(
DWORD_PTR
)
hFile
;
es
.
pfnCallback
=
stream_in
;
stream_buffer
=
pTemp
;
stream_buffer_size
=
size
;
/* FIXME: Handle different file formats */
SendMessageW
(
hEditorWnd
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
)
;
SendMessage
(
hEditorWnd
,
EM_STREAMIN
,
SF_RTF
,
(
LPARAM
)
&
es
);
HeapFree
(
GetProcessHeap
(),
0
,
pTemp
);
CloseHandle
(
hFile
);
SetFocus
(
hEditorWnd
);
...
...
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