Loading...
Searching...
No Matches
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.
CURLcode | urlSeek (URL_t *URL, size_t pos)
| Seeks to a given position in a local or remote file.
URL_t * | urlOpen (const char *fname, CURLcode(*callBack)(CURL *), const char *mode)
| Open a local or remote file.
void | urlClose (URL_t *URL)
| Close a local/remote file.

## 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

enum 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

  URL | A 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 | ( | const char * | fname,
|  | CURLcode(* | callBack )(CURL *),
|  | 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

  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.

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

  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.

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

  URL | A URL_t * pointing to a valid opened file or remote URL.
  pos | The 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

extern

The size of the buffer used for remote files.