isc_file_truncate()

This commit is contained in:
Mark Andrews 2001-08-30 04:55:36 +00:00
parent 91579a2424
commit 59251c9e9c
2 changed files with 17 additions and 2 deletions

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: file.h,v 1.24 2001/07/16 18:33:00 gson Exp $ */
/* $Id: file.h,v 1.25 2001/08/30 04:55:34 marka Exp $ */
#ifndef ISC_FILE_H
#define ISC_FILE_H 1
@ -241,6 +241,12 @@ isc_file_absolutepath(const char *filename, char *path, size_t pathlen);
* (see write_open() in BIND 8's ns_config.c).
*/
isc_result_t
isc_file_truncate(const char *filename, isc_offset_t size);
/*
* Truncate/Extend the file specified to 'size' bytes.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_FILE_H */

View file

@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: file.c,v 1.38 2001/07/16 18:33:01 gson Exp $ */
/* $Id: file.c,v 1.39 2001/08/30 04:55:36 marka Exp $ */
#include <config.h>
@ -313,3 +313,12 @@ isc_file_absolutepath(const char *filename, char *path, size_t pathlen) {
strcat(path, filename);
return (ISC_R_SUCCESS);
}
isc_result_t
isc_file_truncate(const char *filename, isc_offset_t size) {
isc_result_t result = ISC_R_SUCCESS;
if (truncate(filename, size) < 0)
result = isc__errno2result(errno);
return (result);
}