From: "Bill C. Riemers" <cygwin@docbill.net>
To: <cygwin@cygwin.com>
Subject: Re: ftruncate64() question?
Date: Sun, 23 May 2004 06:58:00 -0000 [thread overview]
Message-ID: <00af01c4403b$42c1c5e0$64fda287@docbill002> (raw)
In-Reply-To: <Pine.CYG.4.58.0405211604310.3524@fordpc.vss.fsi.com>
> 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/
next prev parent reply other threads:[~2004-05-22 20:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-21 15:33 where is at at? Clemson, Chris
2004-05-21 16:04 ` Dave Korn
2004-05-21 16:23 ` Andrew DeFaria
2004-05-21 19:15 ` Igor Pechtchanski
2004-05-21 20:04 ` Dave Korn
2004-05-21 20:17 ` Larry Hall
2004-05-21 20:19 ` Christopher Faylor
2004-05-21 20:29 ` Igor Pechtchanski
2004-05-21 20:38 ` Joshua Daniel Franklin
2004-05-21 20:43 ` [OT] " Igor Pechtchanski
2004-05-21 22:21 ` Christopher Faylor
2004-05-22 0:51 ` ftruncate64() question? Bill C. Riemers
2004-05-22 1:39 ` Brian Ford
2004-05-22 19:09 ` Larry Hall
2004-05-25 2:11 ` [OT] " Igor Pechtchanski
2004-05-25 2:42 ` Christopher Faylor
2004-05-25 8:55 ` Larry Hall
2004-05-23 6:58 ` Bill C. Riemers [this message]
2004-05-23 9:36 ` Christopher Faylor
2004-05-23 21:14 ` Hannu E K Nevalainen
2004-05-24 9:25 ` Bill C. Riemers
2004-05-24 9:37 ` Christopher Faylor
2004-05-24 16:16 ` spambot? Bill C. Riemers
2004-05-24 16:31 ` spambot? Larry Hall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='00af01c4403b$42c1c5e0$64fda287@docbill002' \
--to=cygwin@docbill.net \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).