/* write a file to utf-8 format */ bool fwriteUtf8(const QString file ,QString xml) { if (file.contains("/", Qt::CaseInsensitive)) { QString ultimacartellaaperta = file.left(file.lastIndexOf("/"))+"/"; QDir dira(ultimacartellaaperta); if (dira.mkpath(ultimacartellaaperta)) { } else { return false; } } QTextCodec *codecx; codecx = QTextCodec::codecForMib(106); QFile f(file); if (f.open(QFile::WriteOnly | QFile::Text)) { QTextStream sw(&f); sw.setCodec(codecx); sw << xml; f.close(); return true; } return false; }
static inline bool Copy_To(QString inputfile, const QString outfile) { bool succ; QString ultimacartellaaperta = outfile.left(outfile.lastIndexOf("/"))+"/"; QDir dira(ultimacartellaaperta); dira.mkpath(ultimacartellaaperta); if (inputfile.startsWith(":/")) { QResource actual(inputfile); /////qDebug() << "rvalid->" << actual.isValid() << "|" << actual.absoluteFilePath(); QFile fr(actual.absoluteFilePath()); succ = fr.copy(outfile); if (!succ) { QMessageBox::warning(0,"Error \"XHTML Editor\" ",QString("Unable to copy \"%1\" ").arg(inputfile)); } return succ; } QFile Imaged(inputfile); succ = Imaged.copy(outfile); if (!succ) { QMessageBox::warning(0,"Error \"XHTML Editor\" ",QString("Unable to copy \"%1\" ").arg(inputfile)); } return succ; }
/* simple mkdir */ bool Cache( const QString dirpath ) { QDir dira(dirpath); if ( dira.mkpath(dirpath) ) { return true; } else { return false; } }
bool Prekazitor::prekazka() { TypPrekazky typ = (TypPrekazky)nahodne((int)TYPY_PREKAZEK); switch (typ) { case DIRA: return dira(); case TRAMPOSKA: return tramposka(); case PARKUR: return parkur(); case PISKACOJUMP: return piskacojump(); case PNEUMATIC: return pneumatic(); case BODLAKY: return bodlaky(); case TAJNA_CHODBA: return tajna_chodba(); default: return false; } }