refactor: constify the inout module (#6328)

* refactor: move tr_preallocation_mode info tr_open_files

* refactor: remove unnecessary error nullptr check

* refactor: use snake_case for private method names in inout.cc

* refactor: extract-method get_fd() from read_or_write_bytes()

* refactor: make function args const where possible

* refactor: simplify read_or_write_bytes()

* refactor: make buflen a uint64_t in read_or_write_piece()

* refactor: move tr_torrentStop() logic from read_or_write_piece() to tr_ioWrite()

* refactor: make tr_ioFoo() functions take a const torrent

* refactor: make tr_cache::close_torrent_files() take a tor_id instead of a torrent
This commit is contained in:
Charles Kerr
2023-12-02 14:16:36 -06:00
committed by GitHub
parent 9e7a860b57
commit 2e46bad22d
16 changed files with 226 additions and 240 deletions

View File

@@ -24,6 +24,13 @@
class tr_open_files
{
public:
enum class Preallocation
{
None,
Sparse,
Full
};
[[nodiscard]] std::optional<tr_sys_file_t> get(tr_torrent_id_t tor_id, tr_file_index_t file_num, bool writable);
[[nodiscard]] std::optional<tr_sys_file_t> get(
@@ -31,7 +38,7 @@ public:
tr_file_index_t file_num,
bool writable,
std::string_view filename,
tr_preallocation_mode allocation,
Preallocation allocation,
uint64_t file_size);
void close_all();