Files#

Functions#

OmniClientRequestId omniClientCreateWithHash(char const *url, char const *hash, bool overwrite, void *userData, OmniClientCreateWithHashCallback callback, const char *message)

Create a new file with the hash known upfront. This can be used to avoid additional uploads of an asset that is already on the server.

OmniClientRequestId omniClientGetLocalFile(char const *url, bool download, void *userData, OmniClientGetLocalFileCallback callback)

Get a local file name for the URL.

OmniClientRequestId omniClientReadFile(char const *url, void *userData, OmniClientReadFileCallback callback)

Read the entire file.

OmniClientRequestId omniClientWriteFile(char const *url, struct OmniClientContent *content, void *userData, OmniClientWriteFileCallback callback, const char *message)

Create a new file, overwriting if it already exists.

OmniClientRequestId omniClientWriteFileEx(char const *url, struct OmniClientContent *content, void *userData, OmniClientWriteFileExCallback callback, const char *message)

Create a new file, overwriting if it already exists.

OmniClientRequestId omniClientWriteFileEx2(char const *url, struct OmniClientContent *content, void *userData, OmniClientWriteFileExCallback callback, struct OmniClientWriteFileEx2Options const *options)

Creates a new file, overwriting if it already exists.

Structs#

OmniClientWriteFileEx2Options

Options passed to omniClientWriteFileEx2 .

OmniClientWriteFileExInfo

This holds extra info provided by omniClientWriteFileEx.

Typedefs#

OmniClientCreateWithHashCallback

This is called with the result of omniClientCreateWithHash .

OmniClientGetLocalFileCallback

This is called with the result of omniClientGetLocalFile .

OmniClientReadFileCallback

This is called with the result of omniClientReadFile .

OmniClientWriteFileCallback

This is called with the result of omniClientWriteFile .

OmniClientWriteFileExCallback

This is called with the result of omniClientWriteFileEx .

Variables#

Functions#

OmniClientRequestId omniClientCreateWithHash(
char const *url,
char const *hash,
bool overwrite,
void *userData,
OmniClientCreateWithHashCallback callback,
const char *message,
)#

Create a new file with the hash known upfront. This can be used to avoid additional uploads of an asset that is already on the server.

Note

If this function is called after omniClientShutdown, kInvalidRequestId will be returned, and the callback will not be called.

Parameters:
  • url – The URL where the file should be created

  • hash – The hash of the file content

  • overwrite – True to overwrite if the file already exists, false to fail

  • userData – User data passed to the callback

  • callback – The callback function to register

  • message – Optional message to apply to the checkpoint created after writing

Returns:

A request ID that can be used with omniClientStop

OmniClientRequestId omniClientGetLocalFile(
char const *url,
bool download,
void *userData,
OmniClientGetLocalFileCallback callback,
)#

Get a local file name for the URL.

If the URL already points to a local file, it is returned directly Otherwise, this (optionally) downloads the file to a local location and returns that location

Call omniClientStop with the returned request id to mark the file as closed in the Hub cache database. This allows Hub to garbage collect the file.

Note

If this function is called after omniClientShutdown, kInvalidRequestId will be returned, and the callback will not be called.

Parameters:
  • url – The URL of the file to get a local path for

  • download – True to download the file, false to just get the local path

  • userData – User data passed to the callback

  • callback – The callback function to register

Returns:

A request ID that can be used with omniClientStop

OmniClientRequestId omniClientReadFile(
char const *url,
void *userData,
OmniClientReadFileCallback callback,
)#

Read the entire file.

The content buffer is normally freed after the callback returns. To prevent this, take ownership of the content buffer by calling omniClientMoveContent. You are then responsible for calling omniClientFreeContent when you’re finished with it. For example:

OmniClientContent myContent = omniClientMoveContent(*content);
omniClientFreeContent(myContent);

Todo:

Add support for streaming reads to reduce memory usage for large files

Note

If this function is called after omniClientShutdown, kInvalidRequestId will be returned, and the callback will not be called.

Parameters:
  • url – The URL of the file to read

  • userData – User data passed to the callback

  • callback – The callback function to register

Returns:

A request ID that can be used with omniClientStop

OmniClientRequestId omniClientWriteFile(
char const *url,
struct OmniClientContent *content,
void *userData,
OmniClientWriteFileCallback callback,
const char *message,
)#

Create a new file, overwriting if it already exists.

This function takes ownership of the content buffer, and frees it when it’s finished with it (which may be some time in the future)

Todo:

Add support for streaming writes to reduce memory usage for large files

Note

If this function is called after omniClientShutdown, kInvalidRequestId will be returned, and the callback will not be called.

Parameters:
  • url – The URL where the file should be written

  • content – The content buffer to write (ownership is transferred)

  • userData – User data passed to the callback

  • callback – The callback function to register

  • message – Optional message to apply to the checkpoint created after writing

Returns:

A request ID that can be used with omniClientStop

OmniClientRequestId omniClientWriteFileEx(
char const *url,
struct OmniClientContent *content,
void *userData,
OmniClientWriteFileExCallback callback,
const char *message,
)#

Create a new file, overwriting if it already exists.

This function takes ownership of the content buffer, and frees it when it’s finished with it (which may be some time in the future). This is the same as omniClientWriteFile except that it also provides extra information about the file that was written.

Todo:

Add support for streaming writes to reduce memory usage for large files

Note

If this function is called after omniClientShutdown, kInvalidRequestId will be returned, and the callback will not be called.

Parameters:
  • url – The URL where the file should be written

  • content – The content buffer to write (ownership is transferred)

  • userData – User data passed to the callback

  • callback – The callback function to register

  • message – Optional message to apply to the checkpoint created after writing

Returns:

A request ID that can be used with omniClientStop

OmniClientRequestId omniClientWriteFileEx2(
char const *url,
struct OmniClientContent *content,
void *userData,
OmniClientWriteFileExCallback callback,
struct OmniClientWriteFileEx2Options const *options,
)#

Creates a new file, overwriting if it already exists.

This function takes ownership of the content buffer, and frees it when it’s finished with it (which may be some time in the future). This is the same as omniClientWriteFileEx except that it also provides the ability to skip the creation of checkpoints.

Todo:

Add support for streaming writes to reduce memory usage for large files

Note

If this function is called after omniClientShutdown, kInvalidRequestId will be returned, and the callback will not be called.

Parameters:
  • url – The URL where the file should be written

  • content – The content buffer to write (ownership is transferred)

  • userData – User data passed to the callback

  • callback – The callback function to register

  • options – Options controlling the write operation

Returns:

A request ID that can be used with omniClientStop

Typedefs#

typedef void (*OmniClientCreateWithHashCallback)(void *userData, OmniClientResult result, char const *version, char const *hash)#

This is called with the result of omniClientCreateWithHash.

typedef void (*OmniClientGetLocalFileCallback)(void *userData, OmniClientResult result, char const *localFilePath)#

This is called with the result of omniClientGetLocalFile.

typedef void (*OmniClientReadFileCallback)(void *userData, OmniClientResult result, char const *version, struct OmniClientContent *content)#

This is called with the result of omniClientReadFile.

typedef void (*OmniClientWriteFileCallback)(void *userData, OmniClientResult result)#

This is called with the result of omniClientWriteFile.

typedef void (*OmniClientWriteFileExCallback)(void *userData, OmniClientResult result, struct OmniClientWriteFileExInfo const *info)#

This is called with the result of omniClientWriteFileEx.

Variables#

const uint16_t kOmniClientWriteFileEx2OptionsVersion = 1#

The version of OmniClientWriteFileEx2Options.