From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28009 invoked by alias); 22 May 2004 20:27:59 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 27990 invoked from network); 22 May 2004 20:27:59 -0000 Received: from unknown (HELO fep3.cogeco.net) (216.221.81.25) by sourceware.org with SMTP; 22 May 2004 20:27:59 -0000 Received: from docbill002 (d150-157-40.home.cgocable.net [24.150.157.40]) by fep3.cogeco.net (Postfix) with ESMTP id 87EE634FE for ; Sat, 22 May 2004 16:27:52 -0400 (EDT) Message-ID: <00af01c4403b$42c1c5e0$64fda287@docbill002> From: "Bill C. Riemers" To: References: <6.1.0.6.0.20040521150946.03262f68@pop.theworld.com> <20040521192359.GA6832@coe.bosbc.com> <20040521203759.GB7790@coe.bosbc.com> <00ba01c43f74$50560f30$64fda287@docbill002> Subject: Re: ftruncate64() question? Date: Sun, 23 May 2004 06:58:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2004-05/txt/msg00766.txt.bz2 > What's wrong with ftruncate? ftruncate fails with files larger >= 2GB because off_t gets interpreted as 32 bit signed integer... I can find some archived cygwin messages referencing bug fixes to ftruncate64 in the cygwin.dll. However, using ftruncate64 results in an unresolved symbol. In fact based on those messages, I inserted the following code in my program as a workaround for a truncate64() function: #if defined(__CYGWIN__)||defined(__GW32__) __int64 truncate64(const char *filename,__int64 newFileSize) { DWORD dw; HANDLE h=CreateFile(filename,GENERIC_WRITE,0,NULL,OPEN_ALWAYS,0,NULL); DeviceIoControl(h,FSCTL_SET_SPARSE,NULL,0,NULL,0,&dw,NULL); SetFilePointerEx(h,(LARGE_INTEGER)newFileSize,NULL,FILE_BEGIN); SetEndOfFile(h); CloseHandle(h); return newFileSize; } #endif This seems to work up to file sizes of 16TeraBytes, which for my purposes is more than adiquate. Bill -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/