Changeset 11574


Ignore:
Timestamp:
Dec 22, 2010, 7:04:11 AM (11 years ago)
Author:
charles
Message:

(trunk gtk) #3844 "error popup when adding a relative path" -- fixed. initial patch by ijuxda.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/add-dialog.c

    r11572 r11574  
    1616#include <string.h>
    1717
     18#include <libtransmission/transmission.h>
     19#include <libtransmission/utils.h> /* tr_is_same_file() */
     20
    1821#include "add-dialog.h"
    1922#include "conf.h"
     
    188191        tr_torrent * torrent;
    189192
    190         if( filename && ( !data->filename || strcmp( filename, data->filename ) ) )
     193        if( filename && ( !data->filename || !tr_is_same_file( filename, data->filename ) ) )
    191194        {
    192195            g_free( data->filename );
     
    222225    char * fname = gtk_file_chooser_get_filename( GTK_FILE_CHOOSER( b ) );
    223226
    224     if( fname && ( !data->downloadDir || strcmp( fname, data->downloadDir ) ) )
     227    if( fname && ( !data->downloadDir || !tr_is_same_file( fname, data->downloadDir ) ) )
    225228    {
    226229        g_free( data->downloadDir );
  • trunk/libtransmission/torrent.c

    r11570 r11574  
    27822782};
    27832783
    2784 static tr_bool
    2785 isSameLocation( const char * path1, const char * path2 )
    2786 {
    2787     struct stat s1, s2;
    2788     const int err1 = stat( path1, &s1 );
    2789     const int err2 = stat( path2, &s2 );
    2790 
    2791     if( !err1 && !err2 ) {
    2792         tr_dbg( "path1 dev:inode is %"PRIu64":%"PRIu64"; "
    2793                 "path2 dev:inode is %"PRIu64":%"PRIu64,
    2794                 (uint64_t)s1.st_dev, (uint64_t)s1.st_ino,
    2795                 (uint64_t)s2.st_dev, (uint64_t)s2.st_ino );
    2796         return ( s1.st_dev == s2.st_dev )
    2797             && ( s1.st_ino == s2.st_ino );
    2798     }
    2799 
    2800     /* either one, or the other, or both don't exist... */
    2801     tr_dbg( "stat(%s) returned %d\n", path1, err1 );
    2802     tr_dbg( "stat(%s) returned %d\n", path2, err2 );
    2803     return FALSE;
    2804 }
    2805 
    28062784static void
    28072785setLocation( void * vdata )
     
    28212799    tr_mkdirp( location, 0777 );
    28222800
    2823     if( !isSameLocation( location, tor->currentDir ) )
     2801    if( !tr_is_same_file( location, tor->currentDir ) )
    28242802    {
    28252803        tr_file_index_t i;
  • trunk/libtransmission/utils.c

    r11548 r11574  
    15881588}
    15891589
     1590tr_bool
     1591tr_is_same_file( const char * filename1, const char * filename2 )
     1592{
     1593    struct stat sb1, sb2;
     1594
     1595    return !stat( filename1, &sb1 )
     1596        && !stat( filename2, &sb2 )
     1597        && ( sb1.st_dev == sb2.st_dev )
     1598        && ( sb1.st_ino == sb2.st_ino );
     1599}
     1600
    15901601/***
    15911602****
  • trunk/libtransmission/utils.h

    r11548 r11574  
    518518                 tr_bool * renamed ) TR_GNUC_NONNULL(1,2);
    519519
     520/** @brief Test to see if the two filenames point to the same file. */
     521tr_bool tr_is_same_file( const char * filename1, const char * filename2 );
     522
    520523/** @brief convenience function to remove an item from an array */
    521524void tr_removeElementFromArray( void         * array,
Note: See TracChangeset for help on using the changeset viewer.