/*****************************************************************************
* theme_repository.cpp
*****************************************************************************
- * Copyright (C) 2004 VideoLAN
+ * Copyright (C) 2004 the VideoLAN team
* $Id$
*
* Authors: Cyril Deguet <asmax@via.ecp.fr>
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "theme_repository.hpp"
#include "../commands/cmd_dialogs.hpp"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
-#elif defined( WIN32 )
+#elif defined( WIN32 ) && !defined( UNDER_CE )
# include <direct.h>
#endif
-#if (!defined( WIN32 ) || defined(__MINGW32__))
-/* Mingw has its own version of dirent */
+#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
if( pDir == NULL )
{
// An error occurred
- msg_Dbg( getIntf(), "Cannot open directory %s", rDir.c_str() );
+ msg_Dbg( getIntf(), "cannot open directory %s", rDir.c_str() );
return;
}
// Get the first directory entry
- pDirContent = readdir( pDir );
+ pDirContent = (dirent*)readdir( pDir );
// While we still have entries in the directory
while( pDirContent != NULL )
{
string name = pDirContent->d_name;
- if( name.size() > 4 && name.substr( name.size() - 4, 4 ) == ".vlt" )
+ string extension;
+ if( name.size() > 4 )
+ {
+ extension = name.substr( name.size() - 4, 4 );
+ }
+ if( extension == ".vlt" || extension == ".wsz" )
{
string path = rDir + sep + name;
msg_Dbg( getIntf(), "found skin %s", path.c_str() );
// Add the theme in the popup menu
- val.psz_string = (char*)path.c_str();
- text.psz_string = (char*)name.substr(0, name.size() - 4).c_str();
+ string shortname = name.substr( 0, name.size() - 4 );
+ val.psz_string = new char[path.size() + 1];
+ text.psz_string = new char[shortname.size() + 1];
+ strcpy( val.psz_string, path.c_str() );
+ strcpy( text.psz_string, shortname.c_str() );
var_Change( getIntf(), "intf-skins", VLC_VAR_ADDCHOICE, &val,
&text );
+ delete[] val.psz_string;
+ delete[] text.psz_string;
}
- pDirContent = readdir( pDir );
+ pDirContent = (dirent*)readdir( pDir );
}
closedir( pDir );
CmdChangeSkin *pCmd = new CmdChangeSkin( pThis->getIntf(),
newval.psz_string );
AsyncQueue *pQueue = AsyncQueue::instance( pThis->getIntf() );
- pQueue->remove( "change skin" );
pQueue->push( CmdGenericPtr( pCmd ) );
}