Changeset: 73b0742d16dc for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=73b0742d16dc
Modified Files:
common/stream/stream.c
Branch: makelibstreamgreatagain
Log Message:
Used compressed_stream to implement open_rstream
diffs (78 lines):
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -566,58 +566,41 @@ create_wrapper_stream(const char *name,
stream *
open_rstream(const char *filename)
{
- stream *s;
- const char *ext;
-
if (filename == NULL)
return NULL;
#ifdef STREAM_DEBUG
fprintf(stderr, "open_rstream %s\n", filename);
#endif
- ext = get_extension(filename);
+
+ stream *s = open_stream(filename, "rb");
+ if (s == NULL)
+ return NULL;
- if (strcmp(ext, "gz") == 0)
- return open_gzrstream(filename);
- if (strcmp(ext, "bz2") == 0)
- return open_bzrstream(filename);
- if (strcmp(ext, "xz") == 0)
- return open_xzrstream(filename);
- if (strcmp(ext, "lz4") == 0)
- return open_lz4rstream(filename);
+ stream *c = compressed_stream(s, 0);
+ if (c == NULL)
+ mnstr_close(s);
- if ((s = open_stream(filename, "rb")) == NULL)
- return NULL;
- s->binary = true;
- return s;
+ return c;
}
stream *
open_wstream(const char *filename)
{
- stream *s;
- const char *ext;
-
if (filename == NULL)
return NULL;
#ifdef STREAM_DEBUG
fprintf(stderr, "open_wstream %s\n", filename);
#endif
- ext = get_extension(filename);
+
+ stream *s = open_stream(filename, "wb");
+ if (s == NULL)
+ return NULL;
- if (strcmp(ext, "gz") == 0)
- return open_gzwstream(filename, "wb");
- if (strcmp(ext, "bz2") == 0)
- return open_bzwstream(filename, "wb");
- if (strcmp(ext, "xz") == 0)
- return open_xzwstream(filename, "wb");
- if (strcmp(ext, "lz4") == 0)
- return open_lz4wstream(filename, "wb");
+ stream *c = compressed_stream(s, 0);
+ if (c == NULL)
+ mnstr_close(s);
- if ((s = open_stream(filename, "wb")) == NULL)
- return NULL;
- s->readonly = false;
- s->binary = true;
- return s;
+ return c;
}
stream *
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list