FastqPuri
Macros | Functions
fopen_gen.h File Reference

Uncompress/compress input/output files using pipes. More...

#include <stdio.h>
Include dependency graph for fopen_gen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define READ_END   0
 
#define WRITE_END   1
 
#define PERMISSIONS   0640
 

Functions

int setCloexec (int fd)
 
FILE * fopen_gen (const char *path, const char *mode)
 Generalized fopen function. fopen_gen is to be used as fopen. Can be used in read and in write mode. When used in read mode with a compressed extension, the file will be first decompressed and then read. When used in write mode with a compressed extension, the output will be compressed. More...
 

Detailed Description

Uncompress/compress input/output files using pipes.

Hook the standard file opening functions, open, fopen and fopen64. If the extension of the file being opened indicates the file is compressed (.gz, .bz2, .xz), when opening in the reading mode a pipe to a program is opened that decompresses that file (gunzip, bunzip2 or xzdec) and return a handle to the open pipe. When opening in the writing mode (only for .gz, .bam), a pipe to a program is opened that compresses the output.

Author
Paula Perez paula.nosp@m.pere.nosp@m.zrubi.nosp@m.o@gm.nosp@m.ail.c.nosp@m.om
Date
03.08.2017
Warning
vfork vs fork to be checked!
Note
- original copyright note - (reading mode, original C++ code) author: Shaun Jackman sjack.nosp@m.man@.nosp@m.bcgsc.nosp@m..ca, https://github.com/bcgsc,
filename: Uncompress.cpp

Function Documentation

◆ fopen_gen()

FILE* fopen_gen ( const char *  path,
const char *  mode 
)

Generalized fopen function. fopen_gen is to be used as fopen. Can be used in read and in write mode. When used in read mode with a compressed extension, the file will be first decompressed and then read. When used in write mode with a compressed extension, the output will be compressed.

Returns
a FILE pointer