WCM Forum

WCM Forum (http://www.wcm.at/forum/index.php)
-   Programmierung (http://www.wcm.at/forum/forumdisplay.php?f=17)
-   -   Linux library - file functions (http://www.wcm.at/forum/showthread.php?t=56556)

JosefS 15.05.2002 20:00

Linux library - file functions
 
Hallo!

Würd auch ins linux-forum passen, aber ich denk mir, hier ist es besser aufgehoben:

ich brauche unbedingt eine funktion (linux - c), mit welcher ich den bisherigen inhalt einer datei löschen kann, während ich sie geöffnet habe, also:

Code:

m_fhFile = open( "storage", O_RDONLY );
 read( m_fhFile, cpMain, m_nMaxChar );

 //Hier dann das löschen, was ich gerade gelesen hab/eigentlich die komplette datei leeren

 close( m_fhDatei );

kennt jemand so eine funktion?

_m3 15.05.2002 20:59

man 2 open
Zitat:

O_TRUNC
If the file already exists and is a regular file and the open mode
allows writing (i.e., is O_RDWR or O_WRONLY) it will be truncated to
length 0. If the file is a FIFO or terminal device file, the O_TRUNC
flag is ignored. Otherwise the effect of O_TRUNC is unspecified. (On
many Linux versions it will be ignored; on other versions it will
return an error.)
bzw.

man rewind

HTH


Alle Zeitangaben in WEZ +2. Es ist jetzt 23:24 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© 2009 FSL Verlag