WrapperStr UmlPackage::java_path(const WrapperStr & f) { if (!dir.read) { dir.src = javaDir(); QDir d_root(rootDir(javaLanguage)); if (dir.src.isEmpty()) dir.src = RootDir; else if (QDir::isRelativePath(dir.src)) dir.src = d_root.filePath(dir.src); if (dir.src.isEmpty()) { UmlCom::trace(WrapperStr("<font color=\"red\"><b><b> The generation directory " "must be specified for the package<i> ") + name() + "</i>, edit the <i> generation settings</i> (tab 'directory') " "or edit the package (tab 'Java')</b></font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("UmlPackage::java_path"); } dir.read = TRUE; } QDir d(dir.src); return WrapperStr(d.filePath(f).toLatin1().constData()) + WrapperStr(".") + JavaSettings::sourceExtension(); }
bool UmlPackage::set_roundtrip_expected() { if (javaDir().isEmpty()) package->accept_roundtrip_root(); Progress::tic_it(); const QVector<UmlItem> & ch = UmlItem::children(); UmlItem ** v = ch.data(); UmlItem ** const vsup = v + ch.size(); bool result = isWritable(); for (;v != vsup; v += 1) result &= (*v)->set_roundtrip_expected(); return result; }
Q3CString UmlPackage::file_path(const Q3CString & f) { if (!dir.read) { dir.file = javaDir(); if (! RootDirRead) { RootDirRead = TRUE; RootDir = JavaSettings::rootDir(); if (!RootDir.isEmpty() && // empty -> error QDir::isRelativePath(RootDir)) { QFileInfo f(getProject()->supportFile()); QDir d(f.dirPath()); RootDir = d.filePath(RootDir); } } QDir d_root(RootDir); if (dir.file.isEmpty()) dir.file = RootDir; else if (QDir::isRelativePath(dir.file)) dir.file = d_root.filePath(dir.file); if (dir.file.isEmpty()) { UmlCom::trace(Q3CString("<font color=\"red\"><b><b> The generation directory " "must be specified for the package<i> ") + name() + "</i>, edit the <i> generation settings</i> (tab 'directory') " "or edit the package (tab 'Java')</b></font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("UmlPackage::file_path"); } dir.read = TRUE; } QDir d(dir.file); if (! d.exists()) { // create directory including the intermediates Q3CString s = dir.file; int index = 0; QChar sep = QDir::separator(); if (sep != '/') { while ((index = s.find(sep, index)) != -1) s.replace(index++, 1, "/"); } s = QDir::cleanDirPath(s) + "/"; index = s.find("/"); int index2; while ((index2 = s.find("/", index + 1)) != -1) { Q3CString s2 = s.left(index2); QDir sd(s2); if (!sd.exists()) { if (!sd.mkdir(s2)) { UmlCom::trace(Q3CString("<font color=\"red\"><b> cannot create directory <i>") + s2 + "</i></b></font><br>"); UmlCom::bye(n_errors() + 1); UmlCom::fatal_error("UmlPackage::file_path"); } } index = index2; } } return Q3CString(d.filePath(f).toAscii().constData()) + Q3CString(".") + JavaSettings::sourceExtension(); }