[...] QString filename = QFileDialog::getOpenFileName(this, "Choose a Volume File", "./Volumes", "Volume Info File (*.nfo);;All Files (*.*)"); if (filename.isEmpty()) return; if (filename.contains(".nfo", Qt::CaseInsensitive)) { if (m_volModel) // photon +++ do it the right way, otherwise it'll segfault //m_volModel->addVolume((char*)filename.toStdString().c_str()); m_volModel->addVolume(QFile::encodeName(filename).data()); // photon --- } [...] ------------------------------------------------------------------------------- void VolumeListModel::addVolume(char filename[]) { beginInsertRows(QModelIndex(), m_dataManager->m_volumes.size(), m_dataManager->m_volumes.size()); m_dataManager->addVolume(filename); endInsertRows(); } ------------------------------------------------------------------------------- void DataManager::addVolume(char filename[256]) { VolInfo newVol = m_dataLoader.loadVolume(filename); [...] ------------------------------------------------------------------------------- VolInfo DataLoader::loadVolume(char filename[256]) { VolInfo vol; seperateName(filename, vol.name); createAbsPath(m_currPath, filename, vol.filename); seperatePath(vol.filename, vol.directory); [...] ------------------------------------------------------------------------------- /** * Seperates the filname from additional path information * @param input The input file destination, which might include an absolut or relative path. * @param name The result which is only the name of the file without path information */ void DataLoader::seperateName(char* input, char* name) { //typisches c++ sting/char gewichse, zum kotzen! std::string s(input); int pos = s.find_last_of("\\/"); if(pos == std::string::npos) { strcpy(name, input); } else { pos++; s.copy(name, s.length()-pos, pos); name[s.length()-pos]='\0'; } } /** * Seperates the path without the filename from an absolut file destination. * @param input The absolut file destination (complete path and filename), * @param path The result which is only the complete path, without the filename. */ void DataLoader::seperatePath(char* input, char* path) { strcpy(path, input); char* pos = strrchr(path, '\\'); if (pos == NULL) pos = strrchr(path, '/'); if (pos != NULL) *(pos+1) = '\0'; else path[0] = '\0'; } /** * Creates the absolute destination to the file, including the filename * @param wd The actual working directory. * @param rp The relative path to the file, including the filename. * @param out The complete path to the file, including the filename. */ void DataLoader::createAbsPath(char* wd, char* rp, char* out) { // rp already absolut if(rp[1] == ':' && (rp[2] == '\\' || rp[2] == '/')) { strcpy(out, rp); return; } // build up absolut path from working directory wd // and relativ path rp which may contain "..\" strcpy(out, wd); char* outPtr = out + strlen(out) - 1; char* rpPtr = rp; char* startPtr = rp; // remove possible backslash at the end if (*outPtr == '\\') *outPtr = '\0'; do { startPtr = strstr(startPtr, "..\\"); if (startPtr != NULL) { startPtr += 3; rpPtr = startPtr; outPtr = strrchr(out, '\\'); *(outPtr) = '\0'; } } while(startPtr != NULL); if (out[strlen(out)-1] != '\\') strcat(out, "\\"); strcat(out, rpPtr); }