Skip to content

Commit

Permalink
Add option to set file buffer flags via URI parameter when writing files
Browse files Browse the repository at this point in the history
Summary: Until recently, it was difficult to inject file handling customization into file handlers, but we now can. This diff uses that new path to make it possible to customize the android specific default, without having to touch the VRS code.

Reviewed By: jtbraun

Differential Revision: D60793634

fbshipit-source-id: 4b373aa5f83732abaed83abf833c027efb545b2b
  • Loading branch information
Georges Berenger authored and facebook-github-bot committed Aug 6, 2024
1 parent 84d02dc commit dff86fa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vrs/DiskFileChunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <cstdio>

#include <vrs/FileHandler.h>
#include <vrs/helpers/Strings.h>
#include <vrs/os/CompilerAttributes.h>
#include <vrs/os/Utils.h>

Expand Down Expand Up @@ -52,6 +53,10 @@ class DiskFileChunk {
path_ = newPath;
offset_ = 0;
size_ = 0;
uint64_t bufferSize = 0;
if (helpers::getUInt64(options, "io_buffer_size", bufferSize)) {
return setvbuf(file_, nullptr, bufferSize == 0 ? _IONBF : _IOFBF, bufferSize);
}
#if IS_ANDROID_PLATFORM()
const size_t kBufferingSize = 128 * 1024;
return setvbuf(file_, nullptr, _IOFBF, kBufferingSize);
Expand Down

0 comments on commit dff86fa

Please sign in to comment.