1 | /* |
---|
2 | * This file Copyright (C) Mnemosyne LLC |
---|
3 | * |
---|
4 | * This file is licensed by the GPL version 2. Works owned by the |
---|
5 | * Transmission project are granted a special exemption to clause 2 (b) |
---|
6 | * so that the bulk of its code can remain under the MIT license. |
---|
7 | * This exemption does not extend to derived works not owned by |
---|
8 | * the Transmission project. |
---|
9 | * |
---|
10 | * $Id: inout.h 13625 2012-12-05 17:29:46Z jordan $ |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef __TRANSMISSION__ |
---|
14 | #error only libtransmission should #include this header. |
---|
15 | #endif |
---|
16 | |
---|
17 | #ifndef TR_IO_H |
---|
18 | #define TR_IO_H 1 |
---|
19 | |
---|
20 | struct tr_torrent; |
---|
21 | |
---|
22 | /** |
---|
23 | * @addtogroup file_io File IO |
---|
24 | * @{ |
---|
25 | */ |
---|
26 | |
---|
27 | /** |
---|
28 | * Reads the block specified by the piece index, offset, and length. |
---|
29 | * @return 0 on success, or an errno value on failure. |
---|
30 | */ |
---|
31 | int tr_ioRead (struct tr_torrent * tor, |
---|
32 | tr_piece_index_t pieceIndex, |
---|
33 | uint32_t offset, |
---|
34 | uint32_t len, |
---|
35 | uint8_t * setme); |
---|
36 | |
---|
37 | int tr_ioPrefetch (tr_torrent * tor, |
---|
38 | tr_piece_index_t pieceIndex, |
---|
39 | uint32_t begin, |
---|
40 | uint32_t len); |
---|
41 | |
---|
42 | /** |
---|
43 | * Writes the block specified by the piece index, offset, and length. |
---|
44 | * @return 0 on success, or an errno value on failure. |
---|
45 | */ |
---|
46 | int tr_ioWrite (struct tr_torrent * tor, |
---|
47 | tr_piece_index_t pieceIndex, |
---|
48 | uint32_t offset, |
---|
49 | uint32_t len, |
---|
50 | const uint8_t * writeme); |
---|
51 | |
---|
52 | /** |
---|
53 | * @brief Test to see if the piece matches its metainfo's SHA1 checksum. |
---|
54 | */ |
---|
55 | bool tr_ioTestPiece (tr_torrent * tor, |
---|
56 | tr_piece_index_t piece); |
---|
57 | |
---|
58 | |
---|
59 | /** |
---|
60 | * Converts a piece index + offset into a file index + offset. |
---|
61 | */ |
---|
62 | void tr_ioFindFileLocation (const tr_torrent * tor, |
---|
63 | tr_piece_index_t pieceIndex, |
---|
64 | uint32_t pieceOffset, |
---|
65 | tr_file_index_t * fileIndex, |
---|
66 | uint64_t * fileOffset); |
---|
67 | |
---|
68 | |
---|
69 | /* @} */ |
---|
70 | #endif |
---|