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 25401 : compressed_stream(stream *inner, int level) 20 : { 21 25401 : if (inner == NULL) 22 : return NULL; 23 : 24 25401 : const char *filename = mnstr_name(inner); 25 25401 : if (filename == NULL) 26 : return inner; 27 : 28 25401 : const char *ext = strrchr(filename, '.'); 29 25401 : if (ext == NULL) 30 : return inner; 31 25385 : if (strcmp(ext, ".gz") == 0) 32 5 : return gz_stream(inner, level); 33 25380 : if (strcmp(ext, ".bz2") == 0) 34 141 : return bz2_stream(inner, level); 35 25239 : if (strcmp(ext, ".xz") == 0) 36 2 : return xz_stream(inner, level); 37 25237 : if (strcmp(ext, ".lz4") == 0) 38 4 : return lz4_stream(inner, level); 39 : 40 : return inner; 41 : }