| 803 | } |
| 804 | |
| 805 | uint SQLiteDB::insertSavedataEntry(const QString &path, const QString &name, int id_parent, int type) |
| 806 | { |
| 807 | int ohfi; |
| 808 | SfoReader reader; |
| 809 | uint date_updated = 0; |
| 810 | const char *title = NULL; |
| 811 | const char *savedata_detail = NULL; |
| 812 | const char *savedata_directory = NULL; |
| 813 | |
| 814 | QString file_name = QFileInfo(name).fileName(); |
| 815 | QByteArray utf8name = file_name.toUtf8(); |
| 816 | |
| 817 | if(file_name.endsWith(".sfo", Qt::CaseInsensitive) && reader.load(path + "/" + name)) { |
| 818 | title = reader.value("TITLE", utf8name.constData()); |
| 819 | savedata_detail = reader.value("SAVEDATA_DETAIL", ""); |
| 820 | savedata_directory = reader.value("SAVEDATA_DIRECTORY", utf8name.constData()); |
| 821 | date_updated = QFileInfo(path + "/" + name).lastModified().toUTC().toSecsSinceEpoch(); |
| 822 | } |
| 823 | |
| 824 | if((ohfi = insertDefaultEntry(path, name, title, id_parent, type)) == 0) { |
| 825 | return 0; |
| 826 | } |
| 827 | |
| 828 | if(!title) { |
| 829 | return ohfi; |
| 830 | } |
| 831 | |
| 832 | QSqlQuery query; |
| 833 | query.prepare("REPLACE INTO savedata" |
| 834 | "(object_id, detail, dir_name, title, date_updated)" |
| 835 | "VALUES (:object_id, :detail, :dir_name, :title, :updated)"); |
| 836 | |
| 837 | query.bindValue(0, id_parent); |
| 838 | query.bindValue(1, savedata_detail); |
| 839 | query.bindValue(2, savedata_directory); |
| 840 | query.bindValue(3, title); |
| 841 | query.bindValue(4, date_updated); |
| 842 | |
| 843 | if(!query.exec()) { |
| 844 | return 0; |
| 845 | } |
| 846 | |
| 847 | return ohfi; |
| 848 | } |
| 849 | |
| 850 | |
| 851 | bool SQLiteDB::insertApplicationEntry(const QString &name, int ohfi, int app_type) |