source: trunk/libtransmission/fdlimit.h @ 9328

Last change on this file since 9328 was 9328, checked in by charles, 13 years ago

(trunk) #1483: move completed torrents to a user-specified directory + #629: different file extension for incomplete files

  • Property svn:keywords set to Date Rev Author Id
File size: 4.1 KB
Line 
1/******************************************************************************
2 * $Id: fdlimit.h 9328 2009-10-19 05:05:00Z charles $
3 *
4 * Copyright (c) 2005-2008 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#ifndef __TRANSMISSION__
26#error only libtransmission should #include this header.
27#endif
28
29#include "transmission.h"
30#include "net.h"
31
32/**
33 * @addtogroup file_io File IO
34 * @{
35 */
36
37void tr_fdInit( size_t openFileLimit,
38                size_t globalPeerLimit );
39
40int tr_open_file_for_scanning( const char * filename );
41
42int tr_open_file_for_writing( const char * filename );
43
44void tr_close_file( int fd );
45
46tr_bool tr_preallocate_file( const char * filename, uint64_t length );
47
48int64_t tr_lseek( int fd, int64_t offset, int whence );
49
50
51/**
52 * Returns an fd to the specified filename.
53 *
54 * A small pool of open files is kept to avoid the overhead of
55 * continually opening and closing the same files when downloading
56 * piece data.
57 *
58 * - if `folder' doesn't exist, errno is set to ENOENT.
59 * - if doWrite is true, subfolders in torrentFile are created if necessary.
60 * - if doWrite is true, the target file is created if necessary.
61 *
62 * on success, a file descriptor >= 0 is returned.
63 * on failure, a -1 is returned and errno is set.
64 *
65 * @see tr_fdFileClose
66 */
67int  tr_fdFileCheckout( int                      torrentId,
68                        tr_file_index_t          fileNum,
69                        const char             * folder,
70                        const char             * torrentFile,
71                        tr_bool                  doWrite,
72                        tr_preallocation_mode    preallocationMode,
73                        uint64_t                 desiredFileSize );
74
75int tr_fdFileGetCached( int                      torrentId,
76                        tr_file_index_t          fileNum,
77                        tr_bool                  doWrite );
78
79/**
80 * Closes a file that's being held by our file repository.
81 *
82 * If the file isn't checked out, it's closed immediately.
83 * If the file is currently checked out, it will be closed upon its return.
84 *
85 * @see tr_fdFileCheckout
86 */
87void     tr_fdFileClose( const tr_torrent * tor, tr_file_index_t fileNo );
88
89
90/**
91 * Closes all the files associated with a given torrent id
92 */
93void tr_fdTorrentClose( int torrentId );
94
95
96/***********************************************************************
97 * Sockets
98 **********************************************************************/
99int      tr_fdSocketCreate( int domain, int type );
100
101int      tr_fdSocketAccept( int           b,
102                            tr_address  * addr,
103                            tr_port     * port );
104
105void     tr_fdSocketClose( int s );
106
107/***********************************************************************
108 * tr_fdClose
109 ***********************************************************************
110 * Frees resources allocated by tr_fdInit.
111 **********************************************************************/
112void     tr_fdClose( void );
113
114
115void     tr_fdSetPeerLimit( uint16_t n );
116
117uint16_t tr_fdGetPeerLimit( void );
118
119/* @} */
Note: See TracBrowser for help on using the repository browser.