2009-01-07 06:53:29 +00:00
|
|
|
/*
|
2014-01-19 01:09:44 +00:00
|
|
|
* This file Copyright (C) 2007-2014 Mnemosyne LLC
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
2014-01-21 03:10:30 +00:00
|
|
|
* It may be used under the GNU GPL versions 2 or 3
|
2014-01-19 01:09:44 +00:00
|
|
|
* or any future license endorsed by Mnemosyne LLC.
|
2006-07-16 19:39:23 +00:00
|
|
|
*
|
2009-01-07 06:53:29 +00:00
|
|
|
* $Id$
|
|
|
|
*/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
2009-01-07 06:53:29 +00:00
|
|
|
#error only libtransmission should #include this header.
|
2008-11-24 20:17:36 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
#ifndef TR_IO_H
|
|
|
|
#define TR_IO_H 1
|
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
struct tr_torrent;
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup file_io File IO
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2008-01-18 19:13:32 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2008-01-18 19:13:32 +00:00
|
|
|
*/
|
2012-12-05 17:29:46 +00:00
|
|
|
int tr_ioRead (struct tr_torrent * tor,
|
2009-08-13 17:25:26 +00:00
|
|
|
tr_piece_index_t pieceIndex,
|
|
|
|
uint32_t offset,
|
|
|
|
uint32_t len,
|
2012-12-05 17:29:46 +00:00
|
|
|
uint8_t * setme);
|
2008-01-18 19:13:32 +00:00
|
|
|
|
2012-12-05 17:29:46 +00:00
|
|
|
int tr_ioPrefetch (tr_torrent * tor,
|
2011-07-13 03:23:37 +00:00
|
|
|
tr_piece_index_t pieceIndex,
|
|
|
|
uint32_t begin,
|
2012-12-05 17:29:46 +00:00
|
|
|
uint32_t len);
|
2009-11-08 23:43:38 +00:00
|
|
|
|
2008-01-18 19:13:32 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
2008-01-18 19:13:32 +00:00
|
|
|
*/
|
2012-12-05 17:29:46 +00:00
|
|
|
int tr_ioWrite (struct tr_torrent * tor,
|
2009-08-13 17:25:26 +00:00
|
|
|
tr_piece_index_t pieceIndex,
|
|
|
|
uint32_t offset,
|
|
|
|
uint32_t len,
|
2012-12-05 17:29:46 +00:00
|
|
|
const uint8_t * writeme);
|
2007-01-14 12:00:21 +00:00
|
|
|
|
2007-09-20 16:32:01 +00:00
|
|
|
/**
|
2008-12-31 18:08:13 +00:00
|
|
|
* @brief Test to see if the piece matches its metainfo's SHA1 checksum.
|
2008-02-15 16:00:46 +00:00
|
|
|
*/
|
2012-12-05 17:29:46 +00:00
|
|
|
bool tr_ioTestPiece (tr_torrent * tor,
|
|
|
|
tr_piece_index_t piece);
|
2008-02-15 16:00:46 +00:00
|
|
|
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2008-06-07 21:26:41 +00:00
|
|
|
/**
|
|
|
|
* Converts a piece index + offset into a file index + offset.
|
|
|
|
*/
|
2012-12-05 17:29:46 +00:00
|
|
|
void tr_ioFindFileLocation (const tr_torrent * tor,
|
2011-03-03 19:59:12 +00:00
|
|
|
tr_piece_index_t pieceIndex,
|
|
|
|
uint32_t pieceOffset,
|
|
|
|
tr_file_index_t * fileIndex,
|
2012-12-05 17:29:46 +00:00
|
|
|
uint64_t * fileOffset);
|
2008-06-07 21:26:41 +00:00
|
|
|
|
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/* @} */
|
2006-07-16 19:39:23 +00:00
|
|
|
#endif
|