Expose hFILE_backend and hfile_init to allow custom hFILE implementations

Open
#849 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
c

Research direction

Start by reviewing hfile_internal.h, the custom implementation in vg's hfile_cppstream.cpp, the htslib-plugins workaround, and the discussion in #647. Trace how hFILE_backend and hfile_init are currently used and how headers are installed. Done means the supported public interface for custom hFILE implementations is defined and its compatibility expectations are clear.

Written by the indexing model from the issue text.

Description

I have a custom hFILE backend over C++ streams that I have written for vg: https://github.com/vgteam/vg/blob/39ac300bb735abf8350e3d2a7ec0356a0742fd56/src/stream/hfile_cppstream.cpp

It has built just fine up until now, since vg ships htslib as a submodule and I can just include hfile_internal.h from it and get the definitions of hFILE_backend and hfile_init.

But now I want to refactor vg's IO logic into its own project, with a dependency on whatever htslib the environment provides. The htslib install process does not install hfile_internal.h, so I can't get at the definitions I need.

I see now that my work is somewhat redundant with #647, but it seemed like in that thread people thought the right thing to do was to just make the backend system available to client code instead of adding a new callback system over it.

For now I'm going to adopt the workaround from https://github.com/samtools/htslib-plugins and just ship my own version of the header and hope that hFILE_backend never changes. But really the type should be exposed so that custom htslib-version-independent hFILE implementations are possible.

Dominant language
C
Stars
950
Forks
475
Avg merge
3d 13h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from samtools/htslib

All issues in samtools/htslib

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.