2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2005-2022 Mnemosyne LLC.
|
|
|
|
// It may be used under GPLv2 (SPDX: GPL-2.0), GPLv3 (SPDX: GPL-3.0),
|
|
|
|
// or any future license endorsed by Mnemosyne LLC.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2017-11-14 20:21:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
2017-04-19 12:04:45 +00:00
|
|
|
#error only libtransmission should #include this header.
|
2008-11-24 20:17:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-01-16 16:38:16 +00:00
|
|
|
#include "transmission.h"
|
2014-07-28 04:13:38 +00:00
|
|
|
#include "file.h"
|
2007-07-31 14:26:44 +00:00
|
|
|
#include "net.h"
|
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup file_io File IO
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-10-23 03:41:36 +00:00
|
|
|
/***
|
|
|
|
****
|
|
|
|
***/
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2007-11-21 16:16:59 +00:00
|
|
|
/**
|
|
|
|
* Returns an fd to the specified filename.
|
|
|
|
*
|
2008-01-18 19:13:32 +00:00
|
|
|
* A small pool of open files is kept to avoid the overhead of
|
|
|
|
* continually opening and closing the same files when downloading
|
2009-08-15 15:52:10 +00:00
|
|
|
* piece data.
|
2007-11-21 16:16:59 +00:00
|
|
|
*
|
2011-03-03 19:59:12 +00:00
|
|
|
* - if do_write is true, subfolders in torrentFile are created if necessary.
|
|
|
|
* - if do_write is true, the target file is created if necessary.
|
|
|
|
*
|
2008-01-18 19:13:32 +00:00
|
|
|
* on success, a file descriptor >= 0 is returned.
|
2014-07-28 04:13:38 +00:00
|
|
|
* on failure, a TR_BAD_SYS_FILE is returned and errno is set.
|
2007-11-21 16:16:59 +00:00
|
|
|
*
|
|
|
|
* @see tr_fdFileClose
|
|
|
|
*/
|
2021-08-15 09:41:48 +00:00
|
|
|
tr_sys_file_t tr_fdFileCheckout(
|
|
|
|
tr_session* session,
|
|
|
|
int torrent_id,
|
|
|
|
tr_file_index_t file_num,
|
|
|
|
char const* filename,
|
|
|
|
bool do_write,
|
|
|
|
tr_preallocation_mode preallocation_mode,
|
|
|
|
uint64_t preallocation_file_size);
|
2014-07-28 04:13:38 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_sys_file_t tr_fdFileGetCached(tr_session* session, int torrent_id, tr_file_index_t file_num, bool doWrite);
|
2011-04-28 18:40:46 +00:00
|
|
|
|
2007-11-21 16:16:59 +00:00
|
|
|
/**
|
|
|
|
* Closes a file that's being held by our file repository.
|
|
|
|
*
|
2017-04-21 07:40:57 +00:00
|
|
|
* If the file isn't checked out, it's fsync()ed and close()d immediately.
|
2007-11-21 16:16:59 +00:00
|
|
|
* If the file is currently checked out, it will be closed upon its return.
|
|
|
|
*
|
|
|
|
* @see tr_fdFileCheckout
|
|
|
|
*/
|
2017-04-20 16:02:19 +00:00
|
|
|
void tr_fdFileClose(tr_session* session, tr_torrent const* tor, tr_file_index_t file_num);
|
2006-07-16 19:39:23 +00:00
|
|
|
|
2009-06-21 07:36:51 +00:00
|
|
|
/**
|
|
|
|
* Closes all the files associated with a given torrent id
|
|
|
|
*/
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_fdTorrentClose(tr_session* session, int torrentId);
|
2009-06-21 07:36:51 +00:00
|
|
|
|
2007-01-14 12:00:21 +00:00
|
|
|
/***********************************************************************
|
2007-01-21 19:42:11 +00:00
|
|
|
* Sockets
|
2007-01-14 12:00:21 +00:00
|
|
|
**********************************************************************/
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_socket_t tr_fdSocketCreate(tr_session* session, int domain, int type);
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
tr_socket_t tr_fdSocketAccept(tr_session* session, tr_socket_t listening_sockfd, tr_address* addr, tr_port* port);
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_fdSocketClose(tr_session* session, tr_socket_t s);
|
2007-01-14 12:00:21 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* tr_fdClose
|
|
|
|
***********************************************************************
|
|
|
|
* Frees resources allocated by tr_fdInit.
|
|
|
|
**********************************************************************/
|
2017-04-19 12:04:45 +00:00
|
|
|
void tr_fdClose(tr_session* session);
|
2007-01-21 07:16:18 +00:00
|
|
|
|
2009-05-29 19:17:12 +00:00
|
|
|
/* @} */
|