Changeset 7524 for trunk/libtransmission/torrent.c
- Timestamp:
- Dec 29, 2008, 8:54:36 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/torrent.c
r7476 r7524 1842 1842 char * tmp; 1843 1843 tr_ptrArrayInsertSorted( dirtyFolders, tr_strdup( dir ), vstrcmp ); 1844 1844 1845 tmp = tr_dirname( dir ); 1845 1846 tr_free( dir ); … … 1896 1897 char ** s; 1897 1898 tr_file_index_t f; 1898 tr_ptrArray * torrentFiles = tr_ptrArrayNew( );1899 tr_ptrArray * folders = tr_ptrArrayNew( );1900 tr_ptrArray * dirtyFolders = tr_ptrArrayNew( ); /* dirty == contains non-torrent files */1899 tr_ptrArray torrentFiles = TR_PTR_ARRAY_INIT; 1900 tr_ptrArray folders = TR_PTR_ARRAY_INIT; 1901 tr_ptrArray dirtyFolders = TR_PTR_ARRAY_INIT; /* dirty == contains non-torrent files */ 1901 1902 1902 1903 const char * firstFile = tor->info.files[0].name; … … 1906 1907 1907 1908 for( f=0; f<tor->info.fileCount; ++f ) 1908 tr_ptrArrayInsertSorted( torrentFiles, tor->info.files[f].name, vstrcmp );1909 tr_ptrArrayInsertSorted( &torrentFiles, tor->info.files[f].name, vstrcmp ); 1909 1910 1910 1911 /* build the set of folders and dirtyFolders */ 1911 walkLocalData( tor, root, root, NULL, torrentFiles, folders,dirtyFolders );1912 walkLocalData( tor, root, root, NULL, &torrentFiles, &folders, &dirtyFolders ); 1912 1913 1913 1914 /* close all the files because we're about to delete them */ … … 1919 1920 1920 1921 /* try to remove entire folders first, so that the recycle bin will be tidy */ 1921 s = (char**) tr_ptrArrayPeek( folders, &n );1922 s = (char**) tr_ptrArrayPeek( &folders, &n ); 1922 1923 for( i=0; i<n; ++i ) 1923 if( tr_ptrArrayFindSorted( dirtyFolders, s[i], vstrcmp ) == NULL )1924 if( tr_ptrArrayFindSorted( &dirtyFolders, s[i], vstrcmp ) == NULL ) 1924 1925 fileFunc( s[i] ); 1925 1926 1926 /* now blow away any remaining torrent files, such torrent files in dirty folders */1927 /* now blow away any remaining torrent files, such as torrent files in dirty folders */ 1927 1928 for( f=0; f<tor->info.fileCount; ++f ) { 1928 1929 char * path = tr_buildPath( tor->downloadDir, tor->info.files[f].name, NULL ); … … 1935 1936 * won't prevent the upper folders from being deleted */ 1936 1937 { 1937 tr_ptrArray * cleanFolders = tr_ptrArrayNew( );1938 s = (char**) tr_ptrArrayPeek( folders, &n );1938 tr_ptrArray cleanFolders = TR_PTR_ARRAY_INIT; 1939 s = (char**) tr_ptrArrayPeek( &folders, &n ); 1939 1940 for( i=0; i<n; ++i ) 1940 if( tr_ptrArrayFindSorted( dirtyFolders, s[i], vstrcmp ) == NULL )1941 tr_ptrArrayInsertSorted( cleanFolders, s[i], compareLongestFirst );1942 s = (char**) tr_ptrArrayPeek( cleanFolders, &n );1941 if( tr_ptrArrayFindSorted( &dirtyFolders, s[i], vstrcmp ) == NULL ) 1942 tr_ptrArrayInsertSorted( &cleanFolders, s[i], compareLongestFirst ); 1943 s = (char**) tr_ptrArrayPeek( &cleanFolders, &n ); 1943 1944 for( i=0; i<n; ++i ) 1944 1945 fileFunc( s[i] ); 1945 tr_ptrArray Free(cleanFolders, NULL );1946 tr_ptrArrayDestruct( &cleanFolders, NULL ); 1946 1947 } 1947 1948 1948 1949 /* cleanup */ 1949 tr_ptrArray Free(dirtyFolders, tr_free );1950 tr_ptrArray Free(folders, tr_free );1951 tr_ptrArray Free(torrentFiles, NULL );1950 tr_ptrArrayDestruct( &dirtyFolders, tr_free ); 1951 tr_ptrArrayDestruct( &folders, tr_free ); 1952 tr_ptrArrayDestruct( &torrentFiles, NULL ); 1952 1953 tr_free( root ); 1953 1954 tr_free( tmp ); … … 1963 1964 deleteLocalData( tor, fileFunc ); 1964 1965 else { 1966 /* torrent only has one file */ 1965 1967 char * path = tr_buildPath( tor->downloadDir, tor->info.files[0].name, NULL ); 1968 tr_fdFileClose( path ); 1966 1969 fileFunc( path ); 1967 1970 tr_free( path );
Note: See TracChangeset
for help on using the changeset viewer.