libBigWig
Data Structures | Enumerations | Functions | Variables
bigWigIO.h File Reference
#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_turlOpen (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
 

Detailed Description

These are (typically internal) IO functions, so there's generally no need for you to directly use them!

Enumeration Type Documentation

◆ bigWigFile_type_enum

The enumerated values that indicate the connection type used to access a file.

Function Documentation

◆ urlClose()

void urlClose ( URL_t URL)

Close a local/remote file.

This will perform the cleanup required on a URL_t*, releasing memory as needed.

Parameters
URLA URL_t * pointing to a valid opened file or remote URL.
Warning
URL will no longer point to a valid location in memory!

◆ urlOpen()

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.

Parameters
fnameThe file name or URL to open.
callBackAn 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.
Returns
A URL_t * or NULL on error.

◆ urlRead()

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.

Parameters
URLA URL_t * pointing to a valid opened file or remote URL.
bufThe buffer in memory that you would like filled. It must be able to hold bufSize bytes!
bufSizeThe number of bytes to transfer to buf.
Returns
Returns the number of bytes stored in buf, which should be bufSize on success and something else on error.
Warning
Note that on error, URL for remote files is left in an unusable state. You can get around this by running urlSeek() to a position outside of the range held by the internal buffer.

◆ urlSeek()

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.

Parameters
URLA URL_t * pointing to a valid opened file or remote URL.
posThe position to seek to.
Returns
CURLE_OK on success and a different CURLE_XXX on error. For local files, the error return value is always CURLE_FAILED_INIT

Variable Documentation

◆ GLOBAL_DEFAULTBUFFERSIZE

size_t GLOBAL_DEFAULTBUFFERSIZE

The size of the buffer used for remote files.