libER 0.1.4.2
ELDEN RING API library
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
from::file_request Class Reference

Asynchronous file loading using the file capsule system. More...

#include <file.hpp>

Public Types

enum  file_request_type : char { LOAD = 0 , RELOAD = 1 , UNLOAD = 2 }
 Supported request types. More...
 
using loader_type = FD4::FD4FileCap *(*)(CS::CSFile *, const wchar_t *, void *, void *, void *, void *)
 File capsule loader callback signature, for internal use.
 

Public Member Functions

 file_request (const std::filesystem::path &file, file_request_type type)
 Construct a new file request.
 
 file_request (std::filesystem::path &&file, file_request_type type)
 Construct a new file request (path move constructor).
 
 file_request (const file_request &)=delete
 
 file_request (file_request &&) noexcept=delete
 
file_requestoperator= (const file_request &)=delete
 
file_requestoperator= (file_request &&) noexcept=delete
 
bool ready () const noexcept
 Check if the file request is ready.
 
liber::optref< FD4::FD4FileCapget () const noexcept
 Block until the file request is ready and get the result.
 
liber::optref< FD4::FD4FileCapcheck () const noexcept
 Get the request result whether it had finished or not.
 

Detailed Description

Asynchronous file loading using the file capsule system.

Request a file to be loaded/unloaded/reloaded from disk or a .bdt ELDEN RING archive. The operation is executed asynchronously and the result may be acquired from the request whenever it is ready.

Note
Has a throwing constructor: if a file on disk is not found, or if a file extension is not supported, an std::filesystem::filesystem_error is thrown.

Member Enumeration Documentation

◆ file_request_type

Supported request types.

LOAD: Load the requested file. If a file with the same name is already loaded, return it instead.

RELOAD: Load the requested file. If a file with the same name is already loaded, unload it and use the path provided instead.

UNLOAD: Unload the requested file. Does nothing if no files with a matching name are loaded.

Constructor & Destructor Documentation

◆ file_request() [1/2]

from::file_request::file_request ( const std::filesystem::path &  file,
file_request_type  type 
)
inline

Construct a new file request.

By default, the base working directory for relative paths is ELDEN RING/Game.

Paths with an ELDEN RING virtual filesystem root will be treated as such, and the requested file will be loaded from a .bdt archive.

See also
from::file_request::file_request_type
Parameters
filea path to the file
typethe request type
Exceptions
std::filesystem::filesystem_errorif a file on disk is not found, or if a file extension is not supported

◆ file_request() [2/2]

from::file_request::file_request ( std::filesystem::path &&  file,
file_request_type  type 
)
inline

Construct a new file request (path move constructor).

By default, the base working directory for relative paths is ELDEN RING/Game.

Paths with an ELDEN RING virtual filesystem root will be treated as such, and the requested file will be loaded from a .bdt archive.

See also
from::file_request::file_request_type
Parameters
filea path to the file
typethe request type
Exceptions
std::filesystem::filesystem_errorif a file on disk is not found, or if a file extension is not supported

Member Function Documentation

◆ check()

liber::optref< FD4::FD4FileCap > from::file_request::check ( ) const
inlinenoexcept

Get the request result whether it had finished or not.

The absense of a value does not indicate that the request is still not ready, as it simply may have failed to find the file. Use from::file_request::ready for that purpose instead.

Returns
liber::optref<FD4::FD4FileCap>

◆ get()

liber::optref< FD4::FD4FileCap > from::file_request::get ( ) const
inlinenoexcept

Block until the file request is ready and get the result.

Note
Polling may be preferrable to blocking in an environment where a deadlock may occur. Never call this method from a task.

A file request finishing does not mean it contains a value; it's possible the file was not found.

See also
Polling options: from::file_request::ready, from::file_request::check
Returns
liber::optref<FD4::FD4FileCap>

◆ ready()

bool from::file_request::ready ( ) const
inlinenoexcept

Check if the file request is ready.

Does not block.

Note
A file request finishing does not mean it contains a value; it's possible the file was not found.
Returns
true
false

The documentation for this class was generated from the following file: