Line data Source code
1 : /* 2 : * SPDX-License-Identifier: MPL-2.0 3 : * 4 : * This Source Code Form is subject to the terms of the Mozilla Public 5 : * License, v. 2.0. If a copy of the MPL was not distributed with this 6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 : * 8 : * Copyright 2024 MonetDB Foundation; 9 : * Copyright August 2008 - 2023 MonetDB B.V.; 10 : * Copyright 1997 - July 2008 CWI. 11 : */ 12 : 13 : #include "monetdb_config.h" 14 : #include "stream.h" 15 : #include "stream_internal.h" 16 : 17 : 18 : stream * 19 26719 : compressed_stream(stream *inner, int level) 20 : { 21 26719 : if (inner == NULL) 22 : return NULL; 23 : 24 26719 : const char *filename = mnstr_name(inner); 25 26719 : if (filename == NULL) 26 : return inner; 27 : 28 26719 : const char *ext = strrchr(filename, '.'); 29 26719 : if (ext == NULL) 30 : return inner; 31 26703 : if (strcmp(ext, ".gz") == 0) 32 6 : return gz_stream(inner, level); 33 26697 : if (strcmp(ext, ".bz2") == 0) 34 141 : return bz2_stream(inner, level); 35 26556 : if (strcmp(ext, ".xz") == 0) 36 2 : return xz_stream(inner, level); 37 26554 : if (strcmp(ext, ".lz4") == 0) 38 4 : return lz4_stream(inner, level); 39 : 40 : return inner; 41 : }