E_IO_002 — Cannot open file (write)¶
A write attempt on a file failed — the filesystem is read-only, the disk
is full, write permission is denied, or the path is not a directory. It
is raised by MmapBarWriter on flush(), writeBars(), and
writeMetadata().
MmapBarWriter is C++-only — it is not bound in Python, Node.js, Codon,
or QuickJS.
How to fix¶
Check the destination before constructing the writer. The constructor
already calls std::filesystem::create_directories on its symbol
directory, so a merely missing path (parents included) is created for
you; what it cannot do is fix permissions, a full disk, or a read-only
mount.
#include "flox/backtest/mmap_bar_writer.h"
#include <filesystem>
namespace fs = std::filesystem;
fs::path out = "/data/bybit/BTCUSDT/bars";
fs::create_directories(out); // no-op if it exists
auto space = fs::space(out);
if (space.available < 1ull << 30)
{
// less than 1 GiB left: bail out before the writer does
}
flox::MmapBarWriter writer(out);
Common causes¶
- A component of the path already exists as a regular file, so the
symbol directory is never created and every
bars_*.binopen fails. - Disk full —
df -hon the target volume. - Write permission denied (e.g. writing under
/usr, or a read-only mount). - Concurrent writer holding the file with an exclusive lock.
- The same failure on
<symbolDir>/.symbol_metadata, whichwriteMetadata()opens separately from the bar files.