libBigWig
|
#include <curl/curl.h>
Go to the source code of this file.
Data Structures | |
struct | URL_t |
This structure holds the file pointers and buffers needed for raw access to local and remote files. More... | |
Enumerations | |
enum | bigWigFile_type_enum { BWG_FILE = 0, BWG_HTTP = 1, BWG_HTTPS = 2, BWG_FTP = 3 } |
Functions | |
size_t | urlRead (URL_t *URL, void *buf, size_t bufSize) |
Reads data into the given buffer. More... | |
CURLcode | urlSeek (URL_t *URL, size_t pos) |
Seeks to a given position in a local or remote file. More... | |
URL_t * | urlOpen (char *fname, CURLcode(*callBack)(CURL *), const char *mode) |
Open a local or remote file. More... | |
void | urlClose (URL_t *URL) |
Close a local/remote file. More... | |
Variables | |
size_t | GLOBAL_DEFAULTBUFFERSIZE |
These are (typically internal) IO functions, so there's generally no need for you to directly use them!
enum bigWigFile_type_enum |
The enumerated values that indicate the connection type used to access a file.
void urlClose | ( | URL_t * | URL | ) |
Close a local/remote file.
This will perform the cleanup required on a URL_t*, releasing memory as needed.
URL | A URL_t * pointing to a valid opened file or remote URL. |
URL_t* urlOpen | ( | char * | fname, |
CURLcode(*)(CURL *) | callBack, | ||
const char * | mode | ||
) |
Open a local or remote file.
Opens a local or remote file. Currently, http, https, and ftp are the only supported protocols and the URL must then begin with "http://", "https://", or "ftp://" as appropriate.
For remote files, an internal buffer is used to hold file contents, to avoid downloading entire files before starting. The size of this buffer and various variable related to connection timeout are set with bwInit().
Note that you must run urlClose() on this when finished. However, you would typically just use bwOpen() rather than directly calling this function.
fname | The file name or URL to open. |
callBack | An optional user-supplied function. This is applied to remote connections so users can specify things like proxy and password information. |
mode | "r", "w" or NULL. If and only if the mode contains the character "w" will the file be opened for writing. |
size_t urlRead | ( | URL_t * | URL, |
void * | buf, | ||
size_t | bufSize | ||
) |
Reads data into the given buffer.
This function will store bufSize data into buf for both local and remote files. For remote files an internal buffer is used to store a (typically larger) segment of the remote file.
URL | A URL_t * pointing to a valid opened file or remote URL. |
buf | The buffer in memory that you would like filled. It must be able to hold bufSize bytes! |
bufSize | The number of bytes to transfer to buf. |
CURLcode urlSeek | ( | URL_t * | URL, |
size_t | pos | ||
) |
Seeks to a given position in a local or remote file.
For local files, this will set the file position indicator for the file pointer to the desired position. For remote files, it sets the position to start downloading data for the next urlRead(). Note that for remote files that running urlSeek() with a pos within the current buffer will simply modify the internal offset.
URL | A URL_t * pointing to a valid opened file or remote URL. |
pos | The position to seek to. |
size_t GLOBAL_DEFAULTBUFFERSIZE |
The size of the buffer used for remote files.