#include <errno.h>
#include <sys/types.h>
+#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
p_module->b_loaded = false;
}
-/*****************************************************************************
- * CacheFind: finds the cache entry corresponding to a file
- *****************************************************************************/
-module_t *CacheFind( module_bank_t *p_bank,
- const char *path, time_t mtime, off_t size )
+/**
+ * Looks up a plugin file in a list of cached plugins.
+ */
+module_t *CacheFind (module_bank_t *p_bank,
+ const char *path, const struct stat *st)
{
module_cache_t **cache = p_bank->pp_loaded_cache;
size_t n = p_bank->i_loaded_cache;
for( size_t i = 0; i < n; i++ )
if( !strcmp( cache[i]->path, path )
- && cache[i]->mtime == mtime
- && cache[i]->size == size )
+ && cache[i]->mtime == st->st_mtime
+ && cache[i]->size == st->st_size)
{
module_t *module = cache[i]->p_module;
cache[i]->p_module = NULL;
static void AllocatePluginDir( vlc_object_t *, module_bank_t *, const char *,
unsigned, cache_mode_t );
static int AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *,
- time_t, off_t, cache_mode_t );
+ const struct stat *, cache_mode_t );
static module_t * AllocatePlugin( vlc_object_t *, const char *, bool );
#endif
static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) );
&& !strncasecmp (path + pathlen - strlen ("_plugin"LIBEXT),
"_plugin"LIBEXT, strlen ("_plugni"LIBEXT)))
/* ^^ We only load files matching "lib*_plugin"LIBEXT */
- AllocatePluginFile (p_this, p_bank, path, st.st_mtime, st.st_size,
- mode);
+ AllocatePluginFile (p_this, p_bank, path, &st, mode);
free (path);
}
* and module_unneed. It can be removed by DeleteModule.
*****************************************************************************/
static int AllocatePluginFile( vlc_object_t * p_this, module_bank_t *p_bank,
- const char *path, time_t mtime, off_t size,
+ const char *path, const struct stat *st,
cache_mode_t mode )
{
module_t * p_module = NULL;
p_module->psz_object_name, p_module->psz_longname ); */
/* Check our plugins cache first then load plugin if needed */
if( mode == CACHE_USE )
- p_module = CacheFind( p_bank, path, mtime, size );
+ p_module = CacheFind( p_bank, path, st );
if( p_module == NULL )
p_module = AllocatePlugin( p_this, path, true );
if( p_module == NULL )
if( pp_cache[p_bank->i_cache] == NULL )
return -1;
pp_cache[p_bank->i_cache]->path = strdup( path );
- pp_cache[p_bank->i_cache]->mtime = mtime;
- pp_cache[p_bank->i_cache]->size = size;
+ pp_cache[p_bank->i_cache]->mtime = st->st_mtime;
+ pp_cache[p_bank->i_cache]->size = st->st_size;
pp_cache[p_bank->i_cache]->p_module = p_module;
p_bank->pp_cache = pp_cache;
p_bank->i_cache++;
void CacheDelete(vlc_object_t *, const char *);
size_t CacheLoad (vlc_object_t *, const char *, module_cache_t ***);
void CacheSave (vlc_object_t *, const char *, module_cache_t *const *, size_t);
-module_t * CacheFind (module_bank_t *, const char *, time_t, off_t);
+module_t * CacheFind (module_bank_t *, const char *, const struct stat *);
#endif /* !LIBVLC_MODULES_H */