/[winpt]/trunk/Src/wptFileCBS.cpp
ViewVC logotype

Diff of /trunk/Src/wptFileCBS.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 196 by twoaday, Fri Dec 9 08:04:51 2005 UTC revision 197 by twoaday, Mon Apr 10 07:38:06 2006 UTC
# Line 18  Line 18 
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
# Line 46  read_cb (void *handle, void *buffer, siz Line 47  read_cb (void *handle, void *buffer, siz
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)
# Line 63  write_cb (void *handle, const void *buff Line 70  write_cb (void *handle, const void *buff
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;
# Line 73  write_cb (void *handle, const void *buff Line 81  write_cb (void *handle, const void *buff
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    

Legend:
Removed from v.196  
changed lines
  Added in v.197

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26