🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.c
Article #308588

Re: Opcje fopen

#308588
From: Borneq
Date: Sun, 22 May 2016 06:22
24 lines
1678 bytes
W dniu 21.05.2016 o 12:15, Borneq pisze:
> W dniu 21.05.2016 o 11:57, Mateusz Viste pisze:
>> Alternatywnie istnieje też taka opcja (dużo szybsza):
>> http://linux.die.net/man/2/ftruncate
>>
>> ...ale to już nie jest ANSI C.
>
> nie musi to być czyste ANSI C, ale aby działało zarówno w Linuxie
> (docelowo) jak i pod Windows (do testów).
>
pod Windows próbuję:
void truncate(char *path, uint64_t position)
{
	LARGE_INTEGER lr;
	lr.QuadPart = position;
	OFSTRUCT ofstruct;
	HANDLE hFile = OpenFile(path, &ofstruct, OF_WRITE);
	SetFilePointer(hFile, lr.LowPart, &lr.HighPart, FILE_BEGIN);
	SetEndOfFile(hFile);
	CloseHandle(hFile);
}

Ale błąd bo OpenFile() chce podawać HFILE a nie HANDLE, natomiast 
pozostałe funkcje chcą HANDLE.
Technical Details
Message-ID: <nhrj79$qv6$1@node1.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
References: <nhpa0p$hiu$1@node1.news.atman.pl> <57403116$0$9698$426a74cc@news.free.fr> <nhpcfo$giu$1@node2.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Borneq <borneq@antyspam.hidden.pl>
Newsgroups: pl.comp.lang.c
Subject: Re: Opcje fopen
Date: Sun, 22 May 2016 08:22:33 +0200
Organization: ATMAN - ATM S.A.
Lines: 24
Message-ID: <nhrj79$qv6$1@node1.news.atman.pl>
References: <nhpa0p$hiu$1@node1.news.atman.pl> <57403116$0$9698$426a74cc@news.free.fr> <nhpcfo$giu$1@node2.news.atman.pl>
NNTP-Posting-Host: 91.239.205.105
Mime-Version: 1.0
X-Trace: node1.news.atman.pl 1463898153 27622 91.239.205.105 (22 May 2016 06:22:33 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Sun, 22 May 2016 06:22:33 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0
In-Reply-To: <nhpcfo$giu$1@node2.news.atman.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit