18 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
19 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 |
*/ |
*/ |
21 |
|
|
22 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
23 |
#include <config.h> |
#include <config.h> |
24 |
#endif |
#endif |
47 |
struct progress_filter_s *pfx = (struct progress_filter_s *)cb->cb_value; |
struct progress_filter_s *pfx = (struct progress_filter_s *)cb->cb_value; |
48 |
DWORD nread = 0; |
DWORD nread = 0; |
49 |
|
|
50 |
ReadFile (cb->handle, buffer, size, &nread, NULL); |
if (cb->error) |
51 |
|
return -1; |
52 |
|
|
53 |
|
if (!ReadFile (cb->handle, buffer, size, &nread, NULL)) { |
54 |
|
cb->error = (int)GetLastError (); |
55 |
|
return -1; |
56 |
|
} |
57 |
|
|
58 |
/* XXX: there is a sync problem with the progress dialog. */ |
/* XXX: there is a sync problem with the progress dialog. */ |
59 |
if (pfx) |
if (pfx) |
70 |
file_data_t cb = (file_data_t)handle; |
file_data_t cb = (file_data_t)handle; |
71 |
DWORD nwritten; |
DWORD nwritten; |
72 |
|
|
73 |
/* XXX: check if fd == INVALID_HANDLE_VALUE. */ |
if (cb->error) |
74 |
|
return -1; |
75 |
|
|
76 |
if (!cb->handle) { |
if (!cb->handle) { |
77 |
SECURITY_ATTRIBUTES sec_attr; |
SECURITY_ATTRIBUTES sec_attr; |
81 |
sec_attr.nLength = sizeof (sec_attr); |
sec_attr.nLength = sizeof (sec_attr); |
82 |
cb->handle = CreateFile (cb->name, GENERIC_WRITE, FILE_SHARE_WRITE, |
cb->handle = CreateFile (cb->name, GENERIC_WRITE, FILE_SHARE_WRITE, |
83 |
&sec_attr, CREATE_ALWAYS, 0, NULL); |
&sec_attr, CREATE_ALWAYS, 0, NULL); |
84 |
|
if (cb->handle == INVALID_HANDLE_VALUE) { |
85 |
|
cb->error = (int)GetLastError (); |
86 |
|
return -1; |
87 |
|
} |
88 |
} |
} |
89 |
|
|
90 |
WriteFile (cb->handle, buffer, size, &nwritten, NULL); |
if (!WriteFile (cb->handle, buffer, size, &nwritten, NULL)) { |
91 |
|
cb->error = (int)GetLastError (); |
92 |
|
return -1; |
93 |
|
} |
94 |
return (long)nwritten; |
return (long)nwritten; |
95 |
} |
} |
96 |
|
|