1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +00:00
transmission/libtransmission/inout.h

52 lines
1.3 KiB
C
Raw Normal View History

/*
* This file Copyright (C) 2007-2014 Mnemosyne LLC
2006-07-16 19:39:23 +00:00
*
* It may be used under the GNU GPL versions 2 or 3
* or any future license endorsed by Mnemosyne LLC.
2006-07-16 19:39:23 +00:00
*
*/
2006-07-16 19:39:23 +00:00
#pragma once
#ifndef __TRANSMISSION__
#error only libtransmission should #include this header.
#endif
struct tr_torrent;
2006-07-16 19:39:23 +00:00
/**
* @addtogroup file_io File IO
* @{
*/
/**
* Reads the block specified by the piece index, offset, and length.
2008-10-03 04:49:06 +00:00
* @return 0 on success, or an errno value on failure.
*/
int tr_ioRead(struct tr_torrent* tor, tr_piece_index_t pieceIndex, uint32_t offset, uint32_t len, uint8_t* setme);
int tr_ioPrefetch(tr_torrent* tor, tr_piece_index_t pieceIndex, uint32_t begin, uint32_t len);
/**
* Writes the block specified by the piece index, offset, and length.
2008-10-03 04:49:06 +00:00
* @return 0 on success, or an errno value on failure.
*/
int tr_ioWrite(struct tr_torrent* tor, tr_piece_index_t pieceIndex, uint32_t offset, uint32_t len, uint8_t const* writeme);
2007-01-14 12:00:21 +00:00
/**
* @brief Test to see if the piece matches its metainfo's SHA1 checksum.
*/
bool tr_ioTestPiece(tr_torrent* tor, tr_piece_index_t piece);
2006-07-16 19:39:23 +00:00
/**
* Converts a piece index + offset into a file index + offset.
*/
void tr_ioFindFileLocation(
tr_torrent const* tor,
tr_piece_index_t pieceIndex,
uint32_t pieceOffset,
tr_file_index_t* fileIndex,
uint64_t* fileOffset);
/* @} */