From 0df58b9ab4808701cec2a66b770c190262401233 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 20 Oct 2009 04:43:51 +0000 Subject: [PATCH] (trunk libT) change the new public API a little bit -- clearer, but a little wordier --- libtransmission/inout.c | 2 +- libtransmission/session.c | 12 ++++++------ libtransmission/session.h | 2 +- libtransmission/torrent.h | 26 +++++++++++++++++--------- libtransmission/transmission.h | 19 +++++++++---------- 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/libtransmission/inout.c b/libtransmission/inout.c index bad14be33..08999d4f3 100644 --- a/libtransmission/inout.c +++ b/libtransmission/inout.c @@ -107,7 +107,7 @@ readOrWriteBytes( const tr_torrent * tor, { base = tor->currentDir; - if( tr_sessionIsPartialFilenamesEnabled( tor->session ) ) + if( tr_sessionIsIncompleteFileNamingEnabled( tor->session ) ) subpath = tr_torrentBuildPartial( tor, fileIndex ); else subpath = tr_strdup( file->name ); diff --git a/libtransmission/session.c b/libtransmission/session.c index 96d92d056..4d8983d9e 100644 --- a/libtransmission/session.c +++ b/libtransmission/session.c @@ -446,7 +446,7 @@ tr_sessionGetSettings( tr_session * s, struct tr_benc * d ) tr_bencDictAddStr ( d, TR_PREFS_KEY_PROXY_USERNAME, s->proxyUsername ); tr_bencDictAddReal( d, TR_PREFS_KEY_RATIO, s->desiredRatio ); tr_bencDictAddBool( d, TR_PREFS_KEY_RATIO_ENABLED, s->isRatioLimited ); - tr_bencDictAddBool( d, TR_PREFS_KEY_RENAME_PARTIAL_FILES, tr_sessionIsPartialFilenamesEnabled( s ) ); + tr_bencDictAddBool( d, TR_PREFS_KEY_RENAME_PARTIAL_FILES, tr_sessionIsIncompleteFileNamingEnabled( s ) ); tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_AUTH_REQUIRED, tr_sessionIsRPCPasswordEnabled( s ) ); tr_bencDictAddStr ( d, TR_PREFS_KEY_RPC_BIND_ADDRESS, tr_sessionGetRPCBindAddress( s ) ); tr_bencDictAddBool( d, TR_PREFS_KEY_RPC_ENABLED, tr_sessionIsRPCEnabled( s ) ); @@ -704,7 +704,7 @@ tr_sessionInitImpl( void * vdata ) found = tr_bencDictFindBool( &settings, TR_PREFS_KEY_RENAME_PARTIAL_FILES, &boolVal ); assert( found ); - tr_sessionSetPartialFilenamesEnabled( session, boolVal ); + tr_sessionSetIncompleteFileNamingEnabled( session, boolVal ); found = tr_bencDictFindBool( &settings, TR_PREFS_KEY_PROXY_ENABLED, &boolVal ); assert( found ); @@ -937,20 +937,20 @@ tr_sessionGetDownloadDir( const tr_session * session ) ***/ void -tr_sessionSetPartialFilenamesEnabled( tr_session * session, tr_bool b ) +tr_sessionSetIncompleteFileNamingEnabled( tr_session * session, tr_bool b ) { assert( tr_isSession( session ) ); assert( tr_isBool( b ) ); - session->isPartialNamesEnabled = b; + session->isIncompleteFileNamingEnabled = b; } tr_bool -tr_sessionIsPartialFilenamesEnabled( const tr_session * session ) +tr_sessionIsIncompleteFileNamingEnabled( const tr_session * session ) { assert( tr_isSession( session ) ); - return session->isPartialNamesEnabled; + return session->isIncompleteFileNamingEnabled; } /*** diff --git a/libtransmission/session.h b/libtransmission/session.h index 3d4c42c8c..2cb883f47 100644 --- a/libtransmission/session.h +++ b/libtransmission/session.h @@ -51,7 +51,7 @@ struct tr_session tr_bool isClosed; tr_bool isWaiting; tr_bool useLazyBitfield; - tr_bool isPartialNamesEnabled; + tr_bool isIncompleteFileNamingEnabled; tr_bool isRatioLimited; tr_bool isIncompleteDirEnabled; diff --git a/libtransmission/torrent.h b/libtransmission/torrent.h index 76cad8d52..be5bd777e 100644 --- a/libtransmission/torrent.h +++ b/libtransmission/torrent.h @@ -360,20 +360,28 @@ static TR_INLINE const char * tr_torrentName( const tr_torrent * tor ) void tr_torrentFileCompleted( tr_torrent * tor, tr_file_index_t fileNo ); -/* Like tr_torrentFindFile(), but splits the filename into base - * (tr_torrent.incompleteDir or tr_torrent.downloadDir) and subpath */ +/** + * @brief Like tr_torrentFindFile(), but splits the filename into base and subpath; + * + * If the file is found, "tr_buildPath( base, subpath, NULL )" + * will generate the complete filename. + * + * @return true if the file is found, false otherwise. + * + * @param base if the torrent is found, this will be either + * tor->downloadDir or tor->incompleteDir + * @param subpath on success, this pointer is assigned a newly-allocated + * string holding the second half of the filename. + */ tr_bool tr_torrentFindFile2( const tr_torrent *, tr_file_index_t fileNo, const char ** base, char ** subpath ); -/* Returns a newly-allocated string that's been munged to the form - * that denotes to humans that it's a partial file. - * This is like the filenames in tr_torrent.info.files -- - * it's not a complete filename by itself, but a fragment that - * can be passed to tr_buildPath() */ +/* Returns a newly-allocated version of the tr_file.name string + * that's been modified to denote that it's not a complete file yet. + * In the current implementation this is done by appending ".part" + * a la Firefox. */ char* tr_torrentBuildPartial( const tr_torrent *, tr_file_index_t fileNo ); - - #endif diff --git a/libtransmission/transmission.h b/libtransmission/transmission.h index 32fe31d80..188082370 100644 --- a/libtransmission/transmission.h +++ b/libtransmission/transmission.h @@ -361,18 +361,17 @@ tr_bool tr_sessionIsIncompleteDirEnabled( const tr_session * session ); /** - * @brief When enabled, unfinished torrent content files created after - * this call will have ".part" appended to their filename + * @brief When enabled, newly-created files will have ".part" appended + * to their filename until the file is fully downloaded * * This is not retroactive -- toggling this will not rename existing files. * It only applies to new files created by Transmission after this API call. * - * @param session - * @param enable + * @see tr_sessionIsIncompleteFileNamingEnabled() */ -void tr_sessionSetPartialFilenamesEnabled( tr_session * session, tr_bool ); +void tr_sessionSetIncompleteFileNamingEnabled( tr_session * session, tr_bool ); -tr_bool tr_sessionIsPartialFilenamesEnabled( const tr_session * session ); +tr_bool tr_sessionIsIncompleteFileNamingEnabled( const tr_session * session ); /** * @brief Set whether or not RPC calls are allowed in this session. @@ -1129,10 +1128,10 @@ int tr_torrentGetFileDL( const tr_torrent * torrent, tr_file_index_t file ); /** @brief Set a batch of files to be downloaded or not. */ -void tr_torrentSetFileDLs( tr_torrent * torrent, - tr_file_index_t * files, - tr_file_index_t fileCount, - tr_bool do_download ); +void tr_torrentSetFileDLs( tr_torrent * torrent, + tr_file_index_t * files, + tr_file_index_t fileCount, + tr_bool do_download ); const tr_info * tr_torrentInfo( const tr_torrent * torrent );