]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fb-file.c
gettid: fixed a compilation bug on gentoo
[libucw.git] / lib / fb-file.c
index a7290cbf8688f9de261a38c4e50dbb9584eee91e..1f6dcb2eeab3632f709c04659cbc6dc6a8062af6 100644 (file)
@@ -91,9 +91,10 @@ bfd_config(struct fastbuf *f, uns item, int value)
     }
 }
 
-static struct fastbuf *
-bfdopen_internal(int fd, uns buflen, byte *name)
+struct fastbuf *
+bfdopen_internal(int fd, byte *name, uns buflen)
 {
+  ASSERT(buflen);
   int namelen = strlen(name) + 1;
   struct fb_file *F = xmalloc(sizeof(struct fb_file) + buflen + namelen);
   struct fastbuf *f = &F->fb;
@@ -117,34 +118,19 @@ bfdopen_internal(int fd, uns buflen, byte *name)
 struct fastbuf *
 bopen_try(byte *name, uns mode, uns buflen)
 {
-  int fd = sh_open(name, mode, 0666);
-  if (fd < 0)
-    return NULL;
-  struct fastbuf *b = bfdopen_internal(fd, buflen, name);
-  if (mode & O_APPEND)
-    bfd_seek(b, 0, SEEK_END);
-  return b;
+  return bopen_file_try(name, mode, &(struct fb_params){ .type = FB_STD, .buffer_size = buflen });
 }
 
 struct fastbuf *
 bopen(byte *name, uns mode, uns buflen)
 {
-  if (!buflen)
-    return bopen_mm(name, mode);
-  struct fastbuf *b = bopen_try(name, mode, buflen);
-  if (!b)
-    die("Unable to %s file %s: %m",
-       (mode & O_CREAT) ? "create" : "open", name);
-  return b;
+  return bopen_file(name, mode, &(struct fb_params){ .type = FB_STD, .buffer_size = buflen });
 }
 
 struct fastbuf *
 bfdopen(int fd, uns buflen)
 {
-  byte x[32];
-
-  sprintf(x, "fd%d", fd);
-  return bfdopen_internal(fd, buflen, x);
+  return bopen_fd(fd, &(struct fb_params){ .type = FB_STD, .buffer_size = buflen });
 }
 
 struct fastbuf *