Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
9548b129
Commit
9548b129
authored
Dec 22, 2007
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
another cleaning session
parent
cac92f55
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
77 deletions
+77
-77
src/misc/update.c
src/misc/update.c
+77
-77
No files found.
src/misc/update.c
View file @
9548b129
...
...
@@ -38,16 +38,13 @@
#ifdef UPDATE_CHECK
#include <ctype.h>
/* tolower() */
#include <assert.h>
#include <vlc_update.h>
#include <vlc_block.h>
#include <vlc_stream.h>
#include <vlc_interface.h>
#include <vlc_charset.h>
/*****************************************************************************
* Misc defines
...
...
@@ -70,7 +67,6 @@
#elif defined( WIN32 )
# define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-win-x86"
#elif defined( __APPLE__ )
# define UPDATE_VLC_OS "macosx"
# if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
# define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-mac-ppc"
# else
...
...
@@ -1033,15 +1029,16 @@ void update_DownloadReal( update_download_thread_t *p_udt )
int
i_progress
=
0
;
long
int
l_size
;
long
int
l_downloaded
=
0
;
char
*
psz_status
;
char
*
psz_downloaded
;
char
*
psz_size
;
char
*
psz_destfile
;
char
*
psz_tmpdestfile
;
float
f_progress
;
char
*
psz_status
=
NULL
;
char
*
psz_downloaded
=
NULL
;
char
*
psz_size
=
NULL
;
char
*
psz_destfile
=
NULL
;
char
*
psz_tmpdestfile
=
NULL
;
FILE
*
p_file
=
NULL
;
stream_t
*
p_stream
;
void
*
p_buffer
;
stream_t
*
p_stream
=
NULL
;
void
*
p_buffer
=
NULL
;
int
i_read
;
update_t
*
p_update
=
p_udt
->
p_update
;
...
...
@@ -1049,83 +1046,86 @@ void update_DownloadReal( update_download_thread_t *p_udt )
/* Open the stream */
p_stream
=
stream_UrlNew
(
p_update
->
p_libvlc
,
p_update
->
release
.
psz_url
);
if
(
!
p_stream
)
{
msg_Err
(
p_update
->
p_libvlc
,
"Failed to open %s for reading"
,
p_update
->
release
.
psz_url
);
goto
error
;
}
else
/* Get the stream size */
l_size
=
stream_Size
(
p_stream
);
/* Get the file name and open it*/
psz_tmpdestfile
=
strrchr
(
p_update
->
release
.
psz_url
,
'/'
);
if
(
!
psz_tmpdestfile
)
{
msg_Err
(
p_update
->
p_libvlc
,
"The URL %s is false formated"
,
p_update
->
release
.
psz_url
);
goto
error
;
}
psz_tmpdestfile
++
;
if
(
asprintf
(
&
psz_destfile
,
"%s%s"
,
psz_destdir
,
psz_tmpdestfile
)
==
-
1
)
goto
error
;
p_file
=
utf8_fopen
(
psz_destfile
,
"w"
);
if
(
!
p_file
)
{
msg_Err
(
p_update
->
p_libvlc
,
"Failed to open %s for writing"
,
psz_destfile
);
goto
error
;
}
/* Create a buffer and fill it with the downloaded file */
p_buffer
=
(
void
*
)
malloc
(
1
<<
10
);
if
(
!
p_buffer
)
goto
error
;
psz_size
=
size_str
(
l_size
);
if
(
asprintf
(
&
psz_status
,
"%s
\n
Downloading... O.O/%s %.1f%% done"
,
p_update
->
release
.
psz_url
,
psz_size
,
0
.
0
)
!=
-
1
)
{
i_progress
=
intf_UserProgress
(
p_update
->
p_libvlc
,
"Downloading ..."
,
psz_status
,
0
.
0
,
0
);
free
(
psz_status
);
}
while
(
(
i_read
=
stream_Read
(
p_stream
,
p_buffer
,
1
<<
10
)
)
&&
!
intf_ProgressIsCancelled
(
p_update
->
p_libvlc
,
i_progress
)
)
{
/* Get the stream size and open the output file */
l_size
=
stream_Size
(
p_stream
);
fwrite
(
p_buffer
,
i_read
,
1
,
p_file
);
l_downloaded
+=
i_read
;
psz_downloaded
=
size_str
(
l_downloaded
);
f_progress
=
100
.
0
*
(
float
)
l_downloaded
/
(
float
)
l_size
;
psz_tmpdestfile
=
strrchr
(
p_update
->
release
.
psz_url
,
'/'
);
if
(
!
psz_tmpdestfile
)
if
(
asprintf
(
&
psz_status
,
"%s
\n
Donwloading... %s/%s %.1f%% done"
,
p_update
->
release
.
psz_url
,
psz_size
,
psz_downloaded
,
f_progress
)
!=
-
1
)
{
msg_Err
(
p_update
->
p_libvlc
,
"The URL %s is false formated"
,
p_update
->
release
.
psz_url
);
return
;
intf_ProgressUpdate
(
p_update
->
p_libvlc
,
i_progress
,
psz_status
,
f_progress
,
0
);
free
(
psz_status
)
;
}
else
free
(
psz_downloaded
);
}
/* Finish the progress bar or delete the file if the user had canceled */
fclose
(
p_file
);
p_file
=
NULL
;
if
(
!
intf_ProgressIsCancelled
(
p_update
->
p_libvlc
,
i_progress
)
)
{
if
(
asprintf
(
&
psz_status
,
"%s
\n
Done %s (100.0%%)"
,
p_update
->
release
.
psz_url
,
psz_size
)
!=
-
1
)
{
psz_tmpdestfile
++
;
if
(
asprintf
(
&
psz_destfile
,
"%s%s"
,
psz_destdir
,
psz_tmpdestfile
)
!=
-
1
)
{
p_file
=
utf8_fopen
(
psz_destfile
,
"w"
);
if
(
!
p_file
)
{
msg_Err
(
p_update
->
p_libvlc
,
"Failed to open %s for writing"
,
psz_destfile
);
}
else
{
/* Create a buffer and fill it with the downloaded file */
p_buffer
=
(
void
*
)
malloc
(
1
<<
10
);
if
(
p_buffer
)
{
psz_size
=
size_str
(
l_size
);
if
(
asprintf
(
&
psz_status
,
"%s
\n
Downloading... O.O/%s %.1f%% done"
,
p_update
->
release
.
psz_url
,
psz_size
,
0
.
0
)
!=
-
1
)
{
i_progress
=
intf_UserProgress
(
p_update
->
p_libvlc
,
"Downloading ..."
,
psz_status
,
0
.
0
,
0
);
free
(
psz_status
);
}
while
(
(
i_read
=
stream_Read
(
p_stream
,
p_buffer
,
1
<<
10
)
)
&&
!
intf_ProgressIsCancelled
(
p_update
->
p_libvlc
,
i_progress
)
)
{
fwrite
(
p_buffer
,
i_read
,
1
,
p_file
);
l_downloaded
+=
i_read
;
psz_downloaded
=
size_str
(
l_downloaded
);
if
(
asprintf
(
&
psz_status
,
"%s
\n
Donwloading... %s/%s %.1f%% done"
,
p_update
->
release
.
psz_url
,
psz_size
,
psz_downloaded
,
100
.
0
*
(
float
)
l_downloaded
/
(
float
)
l_size
)
!=
-
1
)
{
intf_ProgressUpdate
(
p_update
->
p_libvlc
,
i_progress
,
psz_status
,
10
.
0
,
0
);
free
(
psz_status
);
}
free
(
psz_downloaded
);
}
free
(
p_buffer
);
/* If the user cancelled the download */
if
(
!
intf_ProgressIsCancelled
(
p_update
->
p_libvlc
,
i_progress
)
)
{
if
(
asprintf
(
&
psz_status
,
"%s
\n
Done %s (100.0%%)"
,
p_update
->
release
.
psz_url
,
psz_size
)
!=
-
1
)
{
intf_ProgressUpdate
(
p_update
->
p_libvlc
,
i_progress
,
psz_status
,
100
.
0
,
0
);
free
(
psz_status
);
}
}
free
(
psz_size
);
}
fclose
(
p_file
);
if
(
intf_ProgressIsCancelled
(
p_update
->
p_libvlc
,
i_progress
)
)
remove
(
psz_destfile
);
}
free
(
psz_destfile
);
}
intf_ProgressUpdate
(
p_update
->
p_libvlc
,
i_progress
,
psz_status
,
100
.
0
,
0
);
free
(
psz_status
);
}
}
free
(
psz_destdir
);
stream_Delete
(
p_stream
);
else
remove
(
psz_destfile
);
error:
if
(
p_stream
)
stream_Delete
(
p_stream
);
if
(
p_file
)
fclose
(
p_file
);
free
(
psz_destdir
);
free
(
psz_destfile
);
free
(
p_buffer
);
free
(
psz_size
);
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment