]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fb-temp.c
Cleanup of file fastbufs.
[libucw.git] / lib / fb-temp.c
index 54daad1b51270e9e447be81079b448fe14e0defb..1975c8cc3f62c9c31b63d1863beb937591dd1b40 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     UCW Library -- Temporary Fastbufs
  *
- *     (c) 2002--2006 Martin Mares <mj@ucw.cz>
+ *     (c) 2002--2007 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -43,16 +43,19 @@ temp_file_name(char *buf)
 }
 
 struct fastbuf *
-bopen_tmp(uns buflen)
+bopen_tmp_file(struct fb_params *params)
 {
-  char buf[TEMP_FILE_NAME_LEN];
-  struct fastbuf *f;
+  char name[TEMP_FILE_NAME_LEN];
+  temp_file_name(name);
+  struct fastbuf *fb = bopen_file(name, O_RDWR | O_CREAT | O_TRUNC, params);
+  bconfig(fb, BCONFIG_IS_TEMP_FILE, 1);
+  return fb;
+}
 
-  // FIXME: This needs cleanup and merging with other bopen functions.
-  temp_file_name(buf);
-  f = bopen(buf, O_RDWR | O_CREAT | O_TRUNC, buflen);
-  bconfig(f, BCONFIG_IS_TEMP_FILE, 1);
-  return f;
+struct fastbuf *
+bopen_tmp(uns buflen)
+{
+  return bopen_tmp_file(&(struct fb_params){ .type = FB_STD, .buffer_size = buflen });
 }
 
 void bfix_tmp_file(struct fastbuf *fb, const char *name)