3 * SOFTWARE COPYRIGHT NOTICE AGREEMENT
4 * This software and its documentation are copyright 2008 by the
5 * Broad Institute/Massachusetts Institute of Technology. All rights are reserved.
7 * This software is supplied without any warranty or guaranteed support whatsoever.
8 * Neither the Broad Institute nor MIT can be responsible for its use, misuse,
23 //typedef int8_t bool;
27 char open_mode; // 'r' or 'w'
28 bool owned_file, is_uncompressed;
37 int uncompressed_block_size;
38 int compressed_block_size;
39 void* uncompressed_block;
40 void* compressed_block;
41 int64_t block_address;
52 * Open an existing file descriptor for reading or writing.
53 * Mode must be either "r" or "w".
54 * A subsequent bgzf_close will not close the file descriptor.
55 * Returns null on error.
57 BGZF* bgzf_fdopen(int fd, const char* __restrict mode);
60 * Open the specified file for reading or writing.
61 * Mode must be either "r" or "w".
62 * Returns null on error.
64 BGZF* bgzf_open(const char* path, const char* __restrict mode);
67 * Close the BGZ file and free all associated resources.
68 * Does not close the underlying file descriptor if created with bgzf_fdopen.
69 * Returns zero on success, -1 on error.
71 int bgzf_close(BGZF* fp);
74 * Read up to length bytes from the file storing into data.
75 * Returns the number of bytes actually read.
76 * Returns zero on end of file.
77 * Returns -1 on error.
79 int bgzf_read(BGZF* fp, void* data, int length);
82 * Write length bytes from data to the file.
83 * Returns the number of bytes written.
84 * Returns -1 on error.
86 int bgzf_write(BGZF* fp, const void* data, int length);
89 * Return a virtual file pointer to the current location in the file.
90 * No interpetation of the value should be made, other than a subsequent
91 * call to bgzf_seek can be used to position the file at the same point.
92 * Return value is non-negative on success.
93 * Returns -1 on error.
95 int64_t bgzf_tell(BGZF* fp);
98 * Set the file to read from the location specified by pos, which must
99 * be a value previously returned by bgzf_tell for this file (but not
100 * necessarily one returned by this file handle).
101 * The where argument must be SEEK_SET.
102 * Seeking on a file opened for write is not supported.
103 * Returns zero on success, -1 on error.
105 int64_t bgzf_seek(BGZF* fp, int64_t pos, int where);