Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
271b3d59
Commit
271b3d59
authored
Jan 30, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save plugins cache into corresponding plugins directory
parent
d640dbaf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
35 deletions
+31
-35
src/modules/cache.c
src/modules/cache.c
+27
-32
src/modules/modules.c
src/modules/modules.c
+3
-2
src/modules/modules.h
src/modules/modules.h
+1
-1
No files found.
src/modules/cache.c
View file @
271b3d59
...
...
@@ -58,7 +58,7 @@ static int CacheLoadConfig ( module_t *, FILE * );
/* Sub-version number
* (only used to avoid breakage in dev version when cache structure changes) */
#define CACHE_SUBVERSION_NUM 1
0
#define CACHE_SUBVERSION_NUM 1
1
/* Format string for the cache filename */
#define CACHENAME_FORMAT \
...
...
@@ -96,7 +96,7 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
FILE
*
file
;
int
j
,
i_size
,
i_read
;
char
p_cachestring
[
sizeof
(
"cache "
COPYRIGHT_MESSAGE
)];
unsigned
i_cache
;
size_t
i_cache
;
module_cache_t
**
pp_cache
=
NULL
;
int32_t
i_file_size
,
i_marker
;
...
...
@@ -197,7 +197,7 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
if
(
i_cache
)
{
unsigned
i_already
=
p_bank
->
i_loaded_cache
;
size_t
i_already
=
p_bank
->
i_loaded_cache
;
pp_cache
=
realloc
(
p_bank
->
pp_loaded_cache
,
(
i_already
+
i_cache
)
*
sizeof
(
*
pp_cache
)
);
if
(
unlikely
(
pp_cache
==
NULL
)
)
...
...
@@ -231,7 +231,7 @@ void CacheLoad( vlc_object_t *p_this, module_bank_t *p_bank, const char *dir )
} \
}
for
(
unsigned
i
=
0
;
i
<
i_cache
;
i
++
)
for
(
size_t
i
=
0
;
i
<
i_cache
;
i
++
)
{
uint16_t
i_size
;
int
i_submodules
;
...
...
@@ -433,52 +433,49 @@ static int CacheLoadConfig( module_t *p_module, FILE *file )
return
VLC_EGENERIC
;
}
static
int
CacheSaveBank
(
FILE
*
file
,
module_
bank_t
*
p_bank
);
static
int
CacheSaveBank
(
FILE
*
file
,
module_
cache_t
*
const
*
,
size_t
);
/*****************************************************************************
* SavePluginsCache: saves the plugins cache to a file
*****************************************************************************/
void
CacheSave
(
vlc_object_t
*
p_this
,
module_bank_t
*
p_bank
)
void
CacheSave
(
vlc_object_t
*
p_this
,
const
char
*
dir
,
module_cache_t
*
const
*
pp_cache
,
size_t
n
)
{
char
*
psz_cachedir
=
config_GetUserDir
(
VLC_CACHE_DIR
);
if
(
!
psz_cachedir
)
/* XXX: this should never happen */
char
*
filename
,
*
tmpname
;
config_CreateDir
(
p_this
,
dir
);
if
(
asprintf
(
&
filename
,
"%s"
DIR_SEP
CACHENAME_FORMAT
,
dir
,
CACHENAME_VALUES
)
==
-
1
)
return
;
if
(
asprintf
(
&
tmpname
,
"%s.%"
PRIu32
,
filename
,
(
uint32_t
)
getpid
())
==
-
1
)
{
msg_Err
(
p_this
,
"unable to get cache directory"
);
free
(
filename
);
return
;
}
char
psz_filename
[
sizeof
(
DIR_SEP
)
+
32
+
strlen
(
psz_cachedir
)];
config_CreateDir
(
p_this
,
psz_cachedir
);
snprintf
(
psz_filename
,
sizeof
(
psz_filename
),
"%s"
DIR_SEP
CACHENAME_FORMAT
,
psz_cachedir
,
CACHENAME_VALUES
);
free
(
psz_cachedir
);
char
psz_tmpname
[
sizeof
(
psz_filename
)
+
12
];
snprintf
(
psz_tmpname
,
sizeof
(
psz_tmpname
),
"%s.%"
PRIu32
,
psz_filename
,
(
uint32_t
)
getpid
());
FILE
*
file
=
utf8_fopen
(
psz_tmpname
,
"wb"
);
FILE
*
file
=
utf8_fopen
(
tmpname
,
"wb"
);
if
(
file
==
NULL
)
goto
error
;
msg_Dbg
(
p_this
,
"saving plugins cache %s"
,
psz_file
name
);
if
(
CacheSaveBank
(
file
,
p
_bank
))
msg_Dbg
(
p_this
,
"saving plugins cache %s"
,
tmp
name
);
if
(
CacheSaveBank
(
file
,
p
p_cache
,
n
))
goto
error
;
#ifndef WIN32
utf8_rename
(
psz_tmpname
,
psz_
filename
);
/* atomically replace old cache */
utf8_rename
(
tmpname
,
filename
);
/* atomically replace old cache */
fclose
(
file
);
#else
utf8_unlink
(
psz_
filename
);
utf8_unlink
(
filename
);
fclose
(
file
);
utf8_rename
(
psz_tmpname
,
psz_
filename
);
utf8_rename
(
tmpname
,
filename
);
#endif
return
;
/* success! */
error:
msg_Warn
(
p_this
,
"could not write plugins cache %s (%m)"
,
psz_filename
);
msg_Warn
(
p_this
,
"cannot write %s (%m)"
,
tmpname
);
free
(
filename
);
free
(
tmpname
);
if
(
file
!=
NULL
)
{
clearerr
(
file
);
...
...
@@ -489,7 +486,8 @@ error:
static
int
CacheSaveConfig
(
FILE
*
,
const
module_t
*
);
static
int
CacheSaveSubmodule
(
FILE
*
,
const
module_t
*
);
static
int
CacheSaveBank
(
FILE
*
file
,
module_bank_t
*
p_bank
)
static
int
CacheSaveBank
(
FILE
*
file
,
module_cache_t
*
const
*
pp_cache
,
size_t
i_cache
)
{
uint32_t
i_file_size
=
0
;
...
...
@@ -516,9 +514,6 @@ static int CacheSaveBank (FILE *file, module_bank_t *p_bank)
if
(
fwrite
(
&
i_file_size
,
sizeof
(
i_file_size
),
1
,
file
)
!=
1
)
goto
error
;
module_cache_t
**
pp_cache
=
p_bank
->
pp_cache
;
uint32_t
i_cache
=
p_bank
->
i_cache
;
if
(
fwrite
(
&
i_cache
,
sizeof
(
i_cache
),
1
,
file
)
!=
1
)
goto
error
;
...
...
src/modules/modules.c
View file @
271b3d59
...
...
@@ -214,8 +214,6 @@ void module_LoadPlugins( vlc_object_t * p_this )
p_module_bank
->
b_cache
=
var_InheritBool
(
p_this
,
"plugins-cache"
);
AllocateAllPlugins
(
p_this
,
p_module_bank
);
if
(
p_module_bank
->
b_cache
)
CacheSave
(
p_this
,
p_bank
);
config_UnsortConfig
();
config_SortConfig
();
}
...
...
@@ -865,6 +863,7 @@ static void AllocateAllPlugins( vlc_object_t *p_this, module_bank_t *p_bank )
if
(
!
path
)
continue
;
size_t
offset
=
p_module_bank
->
i_loaded_cache
;
if
(
b_reset
)
CacheDelete
(
p_this
,
path
);
else
...
...
@@ -875,6 +874,8 @@ static void AllocateAllPlugins( vlc_object_t *p_this, module_bank_t *p_bank )
/* Don't go deeper than 5 subdirectories */
AllocatePluginDir
(
p_this
,
p_bank
,
path
,
5
);
CacheSave
(
p_this
,
path
,
p_module_bank
->
pp_loaded_cache
+
offset
,
p_module_bank
->
i_loaded_cache
-
offset
);
free
(
path
);
}
...
...
src/modules/modules.h
View file @
271b3d59
...
...
@@ -160,7 +160,7 @@ void module_Unload (module_handle_t);
void
CacheMerge
(
vlc_object_t
*
,
module_t
*
,
module_t
*
);
void
CacheDelete
(
vlc_object_t
*
,
const
char
*
);
void
CacheLoad
(
vlc_object_t
*
,
module_bank_t
*
,
const
char
*
);
void
CacheSave
(
vlc_object_t
*
,
module_bank_t
*
);
void
CacheSave
(
vlc_object_t
*
,
const
char
*
,
module_cache_t
*
const
*
,
size_t
);
module_cache_t
*
CacheFind
(
module_bank_t
*
,
const
char
*
,
int64_t
,
int64_t
);
#endif
/* !__LIBVLC_MODULES_H */
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