1 | /* |
---|
2 | * This file Copyright (C) 2007-2014 Mnemosyne LLC |
---|
3 | * |
---|
4 | * It may be used under the GNU GPL versions 2 or 3 |
---|
5 | * or any future license endorsed by Mnemosyne LLC. |
---|
6 | * |
---|
7 | * $Id: inout.h 14724 2016-03-29 16:37:21Z mikedld $ |
---|
8 | */ |
---|
9 | |
---|
10 | #ifndef __TRANSMISSION__ |
---|
11 | #error only libtransmission should #include this header. |
---|
12 | #endif |
---|
13 | |
---|
14 | #pragma once |
---|
15 | |
---|
16 | struct tr_torrent; |
---|
17 | |
---|
18 | /** |
---|
19 | * @addtogroup file_io File IO |
---|
20 | * @{ |
---|
21 | */ |
---|
22 | |
---|
23 | /** |
---|
24 | * Reads the block specified by the piece index, offset, and length. |
---|
25 | * @return 0 on success, or an errno value on failure. |
---|
26 | */ |
---|
27 | int tr_ioRead (struct tr_torrent * tor, |
---|
28 | tr_piece_index_t pieceIndex, |
---|
29 | uint32_t offset, |
---|
30 | uint32_t len, |
---|
31 | uint8_t * setme); |
---|
32 | |
---|
33 | int tr_ioPrefetch (tr_torrent * tor, |
---|
34 | tr_piece_index_t pieceIndex, |
---|
35 | uint32_t begin, |
---|
36 | uint32_t len); |
---|
37 | |
---|
38 | /** |
---|
39 | * Writes the block specified by the piece index, offset, and length. |
---|
40 | * @return 0 on success, or an errno value on failure. |
---|
41 | */ |
---|
42 | int tr_ioWrite (struct tr_torrent * tor, |
---|
43 | tr_piece_index_t pieceIndex, |
---|
44 | uint32_t offset, |
---|
45 | uint32_t len, |
---|
46 | const uint8_t * writeme); |
---|
47 | |
---|
48 | /** |
---|
49 | * @brief Test to see if the piece matches its metainfo's SHA1 checksum. |
---|
50 | */ |
---|
51 | bool tr_ioTestPiece (tr_torrent * tor, |
---|
52 | tr_piece_index_t piece); |
---|
53 | |
---|
54 | |
---|
55 | /** |
---|
56 | * Converts a piece index + offset into a file index + offset. |
---|
57 | */ |
---|
58 | void tr_ioFindFileLocation (const tr_torrent * tor, |
---|
59 | tr_piece_index_t pieceIndex, |
---|
60 | uint32_t pieceOffset, |
---|
61 | tr_file_index_t * fileIndex, |
---|
62 | uint64_t * fileOffset); |
---|
63 | |
---|
64 | |
---|
65 | /* @} */ |
---|