Added isc_file_truncate routine

This commit is contained in:
Danny Mayer 2001-09-04 03:10:33 +00:00
parent dcc35bf6a4
commit 7c7b389ae0

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: file.c,v 1.24 2001/09/01 00:05:38 gson Exp $ */
/* $Id: file.c,v 1.25 2001/09/04 03:10:33 mayer Exp $ */
#include <config.h>
@ -488,3 +488,21 @@ isc_file_absolutepath(const char *filename, char *path, size_t pathlen) {
return (ISC_R_NOSPACE);
return (ISC_R_SUCCESS);
}
isc_result_t
isc_file_truncate(const char *filename, isc_offset_t size) {
int fh;
REQUIRE(filename != NULL && size >= 0);
if ((fh = open(filename, _O_RDWR | _O_BINARY)) < 0)
return (isc__errno2result(errno));
if(_chsize(fh, size) != 0) {
close(fh);
return (isc__errno2result(errno));
}
close(fh);
return (ISC_R_SUCCESS);
}