~ubuntu-branches/debian/squeeze/vlc/squeeze

« back to all changes in this revision

Viewing changes to src/misc/update.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Mutricy
  • Date: 2009-09-20 01:08:41 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090920010841-vc6vme91a70r5w0t
Tags: upstream-1.0.2
Import upstream version 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * update.c: VLC update checking and downloading
3
3
 *****************************************************************************
4
4
 * Copyright © 2005-2008 the VideoLAN team
5
 
 * $Id: f495b74dd1a2a22dde4ecd01da7daba7a1b79466 $
 
5
 * $Id: a0f43346363549d4faf3fbf643d5e0d69597b5e0 $
6
6
 *
7
7
 * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8
8
 *          Rémi Duraffort <ivoire at via.ecp.fr>
35
35
#ifdef HAVE_CONFIG_H
36
36
# include "config.h"
37
37
#endif
38
 
#ifdef HAVE_SYS_STAT_H
39
 
#   include <sys/stat.h>
40
 
#endif
41
38
 
42
39
#include <vlc_common.h>
43
40
#include <vlc_update.h>
1495
1492
 * Download the file given in the update_t
1496
1493
 *
1497
1494
 * \param p_update structure
1498
 
 * \param destination to store the download file
1499
 
 *        This can be an existing dir, a (non)existing target fullpath filename or
1500
 
 *        NULL for the current working dir.
 
1495
 * \param dir to store the download file
1501
1496
 * \return nothing
1502
1497
 */
1503
 
void update_Download( update_t *p_update, const char *destination )
 
1498
void update_Download( update_t *p_update, const char *psz_destdir )
1504
1499
{
1505
1500
    assert( p_update );
1506
1501
 
1520
1515
 
1521
1516
    p_udt->p_update = p_update;
1522
1517
    p_update->p_download = p_udt;
1523
 
    p_udt->psz_destination = destination ? strdup( destination ) : NULL;
 
1518
    p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
1524
1519
 
1525
1520
    vlc_thread_create( p_udt, "download update", update_DownloadReal,
1526
1521
                       VLC_THREAD_PRIORITY_LOW );
1540
1535
    char *psz_tmpdestfile = NULL;
1541
1536
 
1542
1537
    FILE *p_file = NULL;
1543
 
    struct stat p_stat;
1544
1538
    stream_t *p_stream = NULL;
1545
1539
    void* p_buffer = NULL;
1546
1540
    int i_read;
1547
1541
    int canc;
1548
1542
 
1549
1543
    update_t *p_update = p_udt->p_update;
1550
 
    char *psz_destination = p_udt->psz_destination;
 
1544
    char *psz_destdir = p_udt->psz_destdir;
1551
1545
 
1552
1546
    msg_Dbg( p_udt, "Opening Stream '%s'", p_update->release.psz_url );
1553
1547
    canc = vlc_savecancel ();
1573
1567
    }
1574
1568
    psz_tmpdestfile++;
1575
1569
 
1576
 
    if( utf8_stat( psz_destination, &p_stat) == 0 && (p_stat.st_mode & S_IFDIR) )
1577
 
    {
1578
 
        if( asprintf( &psz_destfile, "%s%c%s", psz_destination, DIR_SEP_CHAR, psz_tmpdestfile ) == -1 )
1579
 
            goto end;
1580
 
    }
1581
 
    else if( psz_destination )
1582
 
        psz_destfile = strdup( psz_destination );
1583
 
    else
1584
 
        psz_destfile = strdup( psz_tmpdestfile );
 
1570
    if( asprintf( &psz_destfile, "%s%s", psz_destdir, psz_tmpdestfile ) == -1 )
 
1571
        goto end;
1585
1572
 
1586
1573
    p_file = utf8_fopen( psz_destfile, "w" );
1587
1574
    if( !p_file )
1742
1729
        stream_Delete( p_stream );
1743
1730
    if( p_file )
1744
1731
        fclose( p_file );
 
1732
 
 
1733
    free( psz_destdir );
1745
1734
    free( psz_destfile );
1746
1735
    free( p_buffer );
1747
1736
    free( psz_size );
1748
1737
 
1749
 
    free( p_udt->psz_destination );
1750
1738
    p_udt->p_update->p_download = NULL;
1751
1739
 
1752
1740
    vlc_object_release( p_udt );