Browse Source

faux.file: faux_file_close() returns bool_t instead int

Serj Kalichev 3 years ago
parent
commit
282eb69f9e
2 changed files with 8 additions and 5 deletions
  1. 1 1
      faux/file.h
  2. 7 4
      faux/file/file.c

+ 1 - 1
faux/file.h

@@ -18,7 +18,7 @@ C_DECL_BEGIN
 
 faux_file_t *faux_file_fdopen(int fd);
 faux_file_t *faux_file_open(const char *pathname, int flags, mode_t mode);
-int faux_file_close(faux_file_t *file);
+bool_t faux_file_close(faux_file_t *file);
 int faux_file_fileno(faux_file_t *file);
 bool_t faux_file_eof(const faux_file_t *file);
 

+ 7 - 4
faux/file/file.c

@@ -103,21 +103,24 @@ faux_file_t *faux_file_open(const char *pathname, int flags, mode_t mode)
  * file and frees file object structures.
  *
  * @param [in] f File object to close and free.
- * @return 0 - success, < 0 - error
+ * @return BOOL_TRUE - success, BOOL_FALSE - error
  */
-int faux_file_close(faux_file_t *f)
+bool_t faux_file_close(faux_file_t *f)
 {
 	int fd = -1;
 
 	assert(f);
 	if (!f)
-		return -1;
+		return BOOL_FALSE;
 
 	fd = f->fd;
 	faux_free(f->buf);
 	faux_free(f);
 
-	return close(fd);
+	if (close(fd) < 0)
+		return BOOL_FALSE;
+
+	return BOOL_TRUE;
 }