QTfrontend/util/FileEngine.cpp
changeset 9170 7c75643d0b66
parent 9161 b2f02b083374
child 9239 aa4b84ab0a77
equal deleted inserted replaced
9169:ef53201e95ec 9170:7c75643d0b66
    52     else {
    52     else {
    53         qWarning("[PHYSFS] Bad file open mode: %d", (int)openMode);
    53         qWarning("[PHYSFS] Bad file open mode: %d", (int)openMode);
    54     }
    54     }
    55 
    55 
    56     if (!m_handle) {
    56     if (!m_handle) {
    57         qWarning("[PHYSFS] Failed to open %s, reason: %s", m_fileName.toUtf8().constData(), PHYSFS_getLastError());
    57         qWarning(QString("[PHYSFS] Failed to open %1, reason: %2").arg(m_fileName).arg(FileEngineHandler::errorStr()).toLocal8Bit().constData());
    58         return false;
    58         return false;
    59     }
    59     }
    60 
    60 
    61     return true;
    61     return true;
    62 }
    62 }
   308 
   308 
   309 
   309 
   310 FileEngineHandler::FileEngineHandler(char *argv0)
   310 FileEngineHandler::FileEngineHandler(char *argv0)
   311 {
   311 {
   312     PHYSFS_init(argv0);
   312     PHYSFS_init(argv0);
       
   313 
       
   314     qDebug(QString("[PHYSFS] Init: %1").arg(errorStr()).toLocal8Bit().constData());
   313 }
   315 }
   314 
   316 
   315 FileEngineHandler::~FileEngineHandler()
   317 FileEngineHandler::~FileEngineHandler()
   316 {
   318 {
   317     PHYSFS_deinit();
   319     PHYSFS_deinit();
   325         return NULL;
   327         return NULL;
   326 }
   328 }
   327 
   329 
   328 void FileEngineHandler::mount(const QString &path)
   330 void FileEngineHandler::mount(const QString &path)
   329 {
   331 {
   330     qDebug(QString("[PHYSFS] Mounting '%1' to '/'").arg(path).toLocal8Bit().data());
       
   331     PHYSFS_mount(path.toUtf8().constData(), NULL, 0);
   332     PHYSFS_mount(path.toUtf8().constData(), NULL, 0);
       
   333     qDebug(QString("[PHYSFS] Mounting '%1' to '/': %2").arg(path).arg(errorStr()).toLocal8Bit().constData());
   332 }
   334 }
   333 
   335 
   334 void FileEngineHandler::mount(const QString & path, const QString & mountPoint)
   336 void FileEngineHandler::mount(const QString & path, const QString & mountPoint)
   335 {
   337 {
   336     qDebug(QString("[PHYSFS] Mounting '%1' to '%2'").arg(path).arg(mountPoint).toLocal8Bit().data());
       
   337     PHYSFS_mount(path.toUtf8().constData(), mountPoint.toUtf8().constData(), 0);
   338     PHYSFS_mount(path.toUtf8().constData(), mountPoint.toUtf8().constData(), 0);
       
   339     qDebug(QString("[PHYSFS] Mounting '%1' to '%2': %3").arg(path).arg(mountPoint).arg(errorStr()).toLocal8Bit().data());
   338 }
   340 }
   339 
   341 
   340 void FileEngineHandler::setWriteDir(const QString &path)
   342 void FileEngineHandler::setWriteDir(const QString &path)
   341 {
   343 {
   342     qDebug(QString("[PHYSFS] Setting write dir to '%1'").arg(path).toLocal8Bit().data());
       
   343     PHYSFS_setWriteDir(path.toUtf8().constData());
   344     PHYSFS_setWriteDir(path.toUtf8().constData());
       
   345     qDebug(QString("[PHYSFS] Setting write dir to '%1': %2").arg(path).arg(errorStr()).toLocal8Bit().data());
   344 }
   346 }
   345 
   347 
   346 void FileEngineHandler::mountPacks()
   348 void FileEngineHandler::mountPacks()
   347 {
   349 {
   348     hedgewarsMountPackages();
   350     hedgewarsMountPackages();
       
   351 }
       
   352 
       
   353 QString FileEngineHandler::errorStr()
       
   354 {
       
   355     QString s = QString::fromUtf8(PHYSFS_getLastError());
       
   356     return s.isEmpty() ? "ok" : s;
   349 }
   357 }
   350 
   358 
   351 
   359 
   352 FileEngineIterator::FileEngineIterator(QDir::Filters filters, const QStringList &nameFilters, const QStringList &entries)
   360 FileEngineIterator::FileEngineIterator(QDir::Filters filters, const QStringList &nameFilters, const QStringList &entries)
   353     : QAbstractFileEngineIterator(filters, nameFilters)
   361     : QAbstractFileEngineIterator(filters, nameFilters)