public void Seek(SafeFileHandle handle, long position, SeekOrigin origin) { var low = (int)(position & 0xffffffff); var high = (int)(position >> 32); var f = WinNative.SetFilePointer(handle, low, out high, WinNative.EMoveMethod.Begin); if (f == WinNative.INVALID_SET_FILE_POINTER) { throw new Win32Exception(); } }
public void SetFileSize(SafeFileHandle handle, long count) { var low = (int)(count & 0xffffffff); var high = (int)(count >> 32); WinNative.SetFilePointer(handle, low, out high, WinNative.EMoveMethod.Begin); if (!WinNative.SetEndOfFile(handle)) { throw new Win32Exception(); } FSync(handle); }
public static void Seek(SafeFileHandle handle, long position, SeekOrigin origin) { #if !__MonoCS__ && !USE_UNIX_IO var low = (int)(position & 0xffffffff); var high = (int)(position >> 32); var f = WinNative.SetFilePointer(handle, low, out high, WinNative.EMoveMethod.Begin); if (f == WinNative.INVALID_SET_FILE_POINTER) { throw new Win32Exception(); } #else int r = 0; do { r = (int)Syscall.lseek(handle.DangerousGetHandle().ToInt32(), position, SeekFlags.SEEK_SET); } while (UnixMarshal.ShouldRetrySyscall(r)); UnixMarshal.ThrowExceptionForLastErrorIf(r); #endif }
public static void SetFileSize(SafeFileHandle handle, long count) { #if !__MonoCS__ && !USE_UNIX_IO var low = (int)(count & 0xffffffff); var high = (int)(count >> 32); WinNative.SetFilePointer(handle, low, out high, WinNative.EMoveMethod.Begin); if (!WinNative.SetEndOfFile(handle)) { throw new Win32Exception(); } #else int r; do { r = Syscall.ftruncate(handle.DangerousGetHandle().ToInt32(), count); } while (UnixMarshal.ShouldRetrySyscall(r)); UnixMarshal.ThrowExceptionForLastErrorIf(r); #endif FSync(handle); }