[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

[C] file truncation, smid det sidste af en fil væk



Hej

Kan man ikke det i C?

Jeg har en fil som fx er 4096 bytes stor. Nu vil jeg så gerne mens
filen er åben, søge tilbage til et sted, og så klippe resten af filen
væk. Noget i retning af

	fd = open("foo", O_RDWR | O_CREAT);
	write(fd, &temp, 4096);
	lseek(fd, 2048, SEEK_SET);
	trunc(fd); /* hvad skriver jeg her? */

Hvis svaret er at jeg skal kopiere alt over i en anden fil, så duer 
det ikke. Jeg har max 49 ms til udføre operationen og filen kan nemt 
være 100MB stor.

/hans
-- 
Hamletsgade 4 - 201, DK-2200 København N, Phone: +45 3582 9079
Schou Industries ApS      http://schou.dk/    CVR: 26 13 44 39
--------------------------------------------------------------
I spent probably 20 or 30 hours drawing the penguin stuff, and
I've spent four or five years writing code, and I'm still
known for the penguin a lot more than I am for any of the code.
			-- Larry Ewing, creator of Tux


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *