Changeset 13834


Ignore:
Timestamp:
Jan 22, 2013, 4:57:45 AM (8 years ago)
Author:
jordan
Message:

(libT) #1220 'change file and folder names': fold tr_torrentRename() into tr_torrentRenamePath(); it's not useful enough on its own to be a separate function

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r13830 r13834  
    34423442
    34433443static void
    3444 torrentRenameDone (tr_torrent * tor UNUSED,
    3445                    const char * oldpath UNUSED,
    3446                    const char * newname UNUSED,
    3447                    int          error,
    3448                    void       * user_data)
    3449 {
    3450   *(int*)user_data = error;
    3451 }
    3452 
    3453 static void
    34543444torrentRenamePath (void * vdata)
    34553445{
     
    34943484              /* update tr_info.name if user changed the toplevel */
    34953485              if ((n == tor->info.fileCount) && (strchr(oldpath,'/')==NULL))
    3496                 tr_torrentRename (tor, newname, torrentRenameDone, &error);
     3486                {
     3487                  tr_free (tor->info.name);
     3488                  tor->info.name = tr_strdup (newname);
     3489                }
    34973490
    34983491              tr_torrentSetDirty (tor);
     
    35383531  tr_runInEventThread (tor->session, torrentRenamePath, data);
    35393532}
    3540 
    3541 /**
    3542 ***
    3543 **/
    3544 
    3545 static void
    3546 torrentRename (void * vdata)
    3547 {
    3548   int error = 0;
    3549   struct rename_data * data = vdata;
    3550   tr_torrent * const tor = data->tor;
    3551   char * const oldname = tor->info.name;
    3552 
    3553   tor->info.name = data->newname;
    3554   tr_torrentSetDirty (tor);
    3555   tor->anyDate = tr_time ();
    3556 
    3557   /* callback */
    3558   if (data->callback != NULL)
    3559     (*data->callback)(tor, oldname, data->newname, error, data->callback_user_data);
    3560 
    3561   /* cleanup */
    3562   tr_free (oldname);
    3563   tr_free (data);
    3564 }
    3565 
    3566 void
    3567 tr_torrentRename (tr_torrent                   * tor,
    3568                   const char                   * newname,
    3569                   tr_torrent_rename_done_func    callback,
    3570                   void                         * callback_user_data)
    3571 {
    3572   struct rename_data * data;
    3573 
    3574   data = tr_new0 (struct rename_data, 1);
    3575   data->tor = tor;
    3576   data->newname = tr_strdup (newname);
    3577   data->callback = callback;
    3578   data->callback_user_data = callback_user_data;
    3579 
    3580   tr_runInEventThread (tor->session, torrentRename, data);
    3581 }
  • trunk/libtransmission/transmission.h

    r13829 r13834  
    11101110 * @callback_data: the pointer to pass in the callback's user_data arg
    11111111 *
    1112  * As a special case, renaming the root file in a torrent will call
    1113  * tr_torrentRename (tor, newname).
     1112 * As a special case, renaming the root file in a torrent will allso
     1113 * update tr_info.name.
    11141114 *
    11151115 * EXAMPLES
     
    11201120 *
    11211121 *   1. tr_torrentRenamePath (tor, "frobnitz-linux", "foo") will rename
    1122  *      the "frotbnitz-linux" folder as "foo", update info.files[*].name,
    1123  *      and also call tr_torrentRename(tor,"foo").
     1122 *      the "frotbnitz-linux" folder as "foo", and update both info.name
     1123 *      and info.files[*].name.
    11241124 *
    11251125 *   2. tr_torrentRenamePath (tor, "frobnitz-linux/checksum", "foo") will
     
    11471147                           tr_torrent_rename_done_func   callback,
    11481148                           void                        * callback_user_data);
    1149 
    1150 
    1151 /**
    1152  * @brief Changes the torrent's name.
    1153  * @see-also tr_torrentRenamePath
    1154  *
    1155  * This function changes tr_info.name.
    1156  *
    1157  * Changing tr_info's contents requires a session lock, so this function
    1158  * returns asynchronously to avoid blocking. If you don't want to be notified
    1159  * when the function has finished, you can pass NULL as the callback arg.
    1160  */
    1161 void tr_torrentRename (tr_torrent                   * tor,
    1162                        const char                   * newname,
    1163                        tr_torrent_rename_done_func    callback,
    1164                        void                         * callback_user_data);
    11651149
    11661150enum
     
    17781762
    17791763    /* The original name that came in this torrent's metainfo.
    1780      * This may differ from "name" if tr_torrentRename() is called.
    17811764     * CLIENT CODE: NOT USE THIS FIELD. */
    17821765    char             * originalName;
Note: See TracChangeset for help on using the changeset viewer.