/[mldonkey]/mldonkey/src/config/mingw/os_stubs_c.c
ViewVC logotype

Diff of /mldonkey/src/config/mingw/os_stubs_c.c

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

revision 1.10 by spiralvoice, Mon Aug 29 14:52:49 2005 UTC revision 1.11 by spiralvoice, Fri Sep 2 22:39:33 2005 UTC
# Line 20  Line 20 
20  extern void enter_blocking_section();  extern void enter_blocking_section();
21  extern void leave_blocking_section();  extern void leave_blocking_section();
22    
23  extern ssize_t os_read(OS_FD fd, char *buf, size_t len)  extern ssize_t os_read(OS_FD fd, char *buf, size_t len)
24  {  {
25    DWORD numread;    DWORD numread;
26    BOOL ret;    BOOL ret;
# Line 37  extern ssize_t os_read(OS_FD fd, char *b Line 37  extern ssize_t os_read(OS_FD fd, char *b
37    return numread;    return numread;
38  }  }
39    
40  #include <winioctl.h>  #include <winioctl.h>
41    
42  void os_ftruncate(OS_FD fd, OFF_T size)  void os_ftruncate(OS_FD fd, OFF_T size, /* bool */ int sparse)
43  {  {
44    uint curpos;    uint curpos;
45    long ofs_low = (long) size;    long ofs_low = (long) size;
46    long ofs_high = (long) (size >> 32);    long ofs_high = (long) (size >> 32);
47    
48          DWORD dw;    if (sparse) {
49          BOOL bRet = DeviceIoControl(fd, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw, NULL);          DWORD dw;
50          if (!bRet) {          BOOL bRet = DeviceIoControl(fd, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw, NULL);
51                  // No sparse files for you, sucker...          if (!bRet) {
52                  // DWORD err = GetLastError();                  // No sparse files for you, sucker...
53          }                  // DWORD err = GetLastError();
54            }
55      }
56    curpos = SetFilePointer (fd, 0, NULL, FILE_CURRENT);    curpos = SetFilePointer (fd, 0, NULL, FILE_CURRENT);
57    if (curpos == 0xFFFFFFFF    if (curpos == 0xFFFFFFFF
58        || SetFilePointer (fd, ofs_low, &ofs_high, FILE_BEGIN) == 0xFFFFFFFF        || SetFilePointer (fd, ofs_low, &ofs_high, FILE_BEGIN) == 0xFFFFFFFF
# Line 98  int64 os_getfilesize(char *path) Line 100  int64 os_getfilesize(char *path)
100    }    }
101  }  }
102    
103  OFF_T os_lseek(OS_FD fd, OFF_T ofs, int cmd)  OFF_T os_lseek(OS_FD fd, OFF_T ofs, int cmd)
104  {  {
105    long ret;    long ret;
106    long ofs_low = ofs;    long ofs_low = ofs;
# Line 113  OFF_T os_lseek(OS_FD fd, OFF_T ofs, int Line 115  OFF_T os_lseek(OS_FD fd, OFF_T ofs, int
115        uerror("os_lseek", Nothing);        uerror("os_lseek", Nothing);
116      }      }
117    }    }
118    return ((OFF_T) ofs_high << 32 | ret);    return ((OFF_T) ofs_high << 32 | ret);
119  }  }
120    
121  #include <winsock2.h>  #include <winsock2.h>

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26