vibe.d beta banner
get vibe.d
0.10.0

Asynchronous I/O that doesn’t get in your way, written in D

Function createCachedFileStream

Creates a new CachedStream instance.

CachedFileStream!InputStream createCachedFileStream(InputStream) (
  InputStream source,
  Flag!"writable" writable = No.writable
)
if (isInputStream!InputStream);

CachedFileStream!InputStream createCachedFileStream(InputStream) (
  InputStream source,
  NativePath cached_file_path,
  Flag!"writable" writable = No.writable
)
if (isInputStream!InputStream);

Data will be read as needed from the source stream sequentially and gets stored in the local file for random access. Note that the reported size of the stream may change for source streams that do not report their full size through the leastSize property.

Also note that when making the cached file writable, parts of the file that have not yet been read from the source stream will get overwritten after write operations to the cached file. Write operations should ideally only be made after reading the complete source stream.

Parameters

NameDescription
source The source input stream to read from
writable Optional flag to make the cached file writable
cached_file_path Explicit path for storing the cached file - if not given, uses a temporary file that gets deleted upon close
Authors

Sönke Ludwig

Copyright

© 2023 Sönke Ludwig

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.