UrlFileCacheInterface Class Reference

#include <urlfile_cache.h>

Detailed Description

UrlFileCacheInterface offers helper functions to allow to access to files with unsupported URLSCHEMEs. E.g. preset:// wont work with openexr because this lib needs a valid utf8 character path and InputStreams cannot be used to virtualize the read. In that case you would write:

maxon::UrlFileCacheEntry fileCacheEntry;
{
url = fileCacheEntry.GetCacheUrl();
}
ifnoerr (maxon::BaseArray<Char> buffer = url.GetSystemPath().GetCString(maxon::StringEncodings::Utf8()))
return exr_load(buffer.GetFirst(), &wbm);
else
return IMAGERESULT::MISC_ERROR;
const char ** buffer
Definition: abstract.h:327
const char const char * name
Definition: abstract.h:195
maxon::Url MaxonConvert(const Filename &fn, MAXONCONVERTMODE convertMode)
@ READ
Check for file read operation.
static MAXON_METHOD Bool IsAccessible(const maxon::Url &url)
static MAXON_METHOD Result< UrlFileCacheEntry > FindOrCreateUrl(const Url &sourceUrl, const TimeValue &maxCacheTime=Seconds(1.0), URLFILECACHEFLAGS flags=URLFILECACHEFLAGS::NONE)
Definition: url.h:952
IMAGERESULT
Definition: ge_prepass.h:3914
#define ifnoerr(...)
The opposite of iferr.
Definition: errorbase.h:393
#define iferr_return
Definition: resultbase.h:1519

Static Public Member Functions

static MAXON_METHOD Bool IsAccessible (const maxon::Url &url)
 
static MAXON_METHOD Result< UrlFileCacheEntry > FindOrCreateUrl (const Url &sourceUrl, const TimeValue &maxCacheTime=Seconds(1.0), URLFILECACHEFLAGS flags=URLFILECACHEFLAGS::NONE)
 
static MAXON_METHOD Result< void > FlushCache (const Url &url)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (UrlFileCacheInterface, MAXON_REFERENCE_NONE, "net.maxon.interface.urlfilecache")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( UrlFileCacheInterface  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.interface.urlfilecache"   
)
private

◆ IsAccessible()

static MAXON_METHOD Bool IsAccessible ( const maxon::Url url)
static

Check if the url scheme is directly accessible via fopen().

Parameters
[in]urlUrl to check.
Returns
true if the url can accessed directly. false if the url needs a cached copy. in that case use UrlFileCacheInterface::FindOrCreateUrl() to create or find the cache file.

◆ FindOrCreateUrl()

static MAXON_METHOD Result<UrlFileCacheEntry> FindOrCreateUrl ( const Url sourceUrl,
const TimeValue maxCacheTime = Seconds(1.0),
URLFILECACHEFLAGS  flags = URLFILECACHEFLAGS::NONE 
)
static

Finds or creates a new UrlFileCacheEntry for the given source Url.

Parameters
[in]sourceUrlUrl to be cached.
[in]maxCacheTimeTime to wait until to delete the cache file after it's not needed anymore.
[in]flagsSee URLFILECACHEFLAGS.
Returns
A UrlFileCacheEntry which ensures the existence of the cache file as long as any reference to this handle exists.

◆ FlushCache()

static MAXON_METHOD Result<void> FlushCache ( const Url url)
static

Flushes the url from the cache. Existing UrlFileCacheEntries keep alive until the last handle vanishes. Calling the FindOrCreateUrl will create a new cache file for this url.