Example #1
0
void ManGenerator::startDoxyAnchor(const char *,const char *manName,
                                   const char *, const char *name,
                                   const char *)
{
    // something to be done?
    if( !Config_getBool("MAN_LINKS") ) 
    {
	return; // no
    }

    // the name of the link file is derived from the name of the anchor:
    // - truncate after an (optional) ::
    QCString baseName = name;
    int i=baseName.findRev("::");
    if (i!=-1) baseName=baseName.right(baseName.length()-i-2);

    //printf("Converting man link '%s'->'%s'->'%s'\n",
    //       name,baseName.data(),buildFileName(baseName).data());
    
    // - remove dangerous characters and append suffix, then add dir prefix
    QCString fileName=dir+"/"+buildFileName( baseName );
    QFile linkfile( fileName );
    // - only create file if it doesn't exist already
    if ( !linkfile.open( IO_ReadOnly ) ) 
    {
	if ( linkfile.open( IO_WriteOnly ) ) 
        {
	      FTextStream linkstream;
	      linkstream.setDevice(&linkfile);
	      //linkstream.setEncoding(QTextStream::UnicodeUTF8);
	      linkstream << ".so " << getSubdir() << "/" << buildFileName( manName ) << endl;
	}
    }
    linkfile.close();
}
void ManGenerator::startDoxyAnchor(const char *,const char *manName,
                                   const char *, const char *name,
                                   const char *)
{
    // something to be done?
    if( !Config_getBool("MAN_LINKS") ) 
    {
	return; // no
    }

    // the name of the link file is derived from the name of the anchor:
    // - truncate after an (optional) ::
    QCString baseName = name;
    int i=baseName.findRev(':');
    if (i!=-1) baseName=baseName.right(baseName.length()-i-1);
    
    // - remove dangerous characters and append suffix, then add dir prefix
    QCString fileName=dir+"/"+buildFileName( baseName );
    QFile linkfile( fileName );
    // - only create file if it doesn't exist already
    if ( !linkfile.open( IO_ReadOnly ) ) 
    {
	if ( linkfile.open( IO_WriteOnly ) ) 
        {
	      QTextStream linkstream;
	      linkstream.setDevice(&linkfile);
#if QT_VERSION >= 200
	      linkstream.setEncoding(QTextStream::Latin1);
#endif
	      linkstream << ".so man" << getExtension() << "/" << buildFileName( manName ) << endl;
	}
    }
    linkfile.close();
}
bool PosixFileSystem::rename(const Path& from,const Path& to)
{
   String fa = buildFileName(_volume,from);
   String fb = buildFileName(_volume,to);
   
   if (!rename(fa.c_str(),fb.c_str()))
      return true;
      
   return false;
}
Example #4
0
 qint64 partFileSize( int counter ) {
     QFileInfo fi( buildFileName( counter ) );
     if ( fi.exists() )
         return fi.size();
     else
         return 0;
 }
FileNodeRef PosixFileSystem::create(const Path& path, FileNode::Mode mode)
{
   // The file will be created on disk when it's opened.
   if (mode & FileNode::File)
      return new PosixFile(path,buildFileName(_volume,path));

   // Default permissions are read/write/search/executate by everyone,
   // though this will be modified by the current umask
   if (mode & FileNode::Directory)
   {
      String file = buildFileName(_volume,path);
      
      if (mkdir(file.c_str(),S_IRWXU | S_IRWXG | S_IRWXO))
         return new PosixDirectory(path,file);
   }
   
   return 0;
}
Example #6
0
void *HomeDirPlugin::processEvent(Event *e)
{
    if (e->type() == EventHomeDir){
        string *cfg = (string*)(e->param());
        *cfg = buildFileName(cfg->c_str());
        return (void*)(cfg->c_str());
    }
    return NULL;
}
Example #7
0
 bool openFile( int counter ) {
     file.close();
     file.setFileName( buildFileName( counter ) );
     currentFilePos = 0;
     if( file.open( m_splitter->openMode() ) ) {
         return true;
     }
     else {
         m_splitter->close();
         return false;
     }
 }
Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *errorMessage) const
{
    const FormClassWizardDialog *wizardDialog = qobject_cast<const FormClassWizardDialog *>(w);
    const Designer::FormClassWizardParameters params = wizardDialog->parameters();

    if (params.uiTemplate().isEmpty()) {
        *errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents");
        return Core::GeneratedFiles();
    }

    // header
    const QString formFileName = buildFileName(params.path(), params.uiFile(), formSuffix());
    const QString headerFileName = buildFileName(params.path(), params.headerFile(), headerSuffix());
    const QString sourceFileName = buildFileName(params.path(), params.sourceFile(), sourceSuffix());

    Core::GeneratedFile headerFile(headerFileName);
    headerFile.setEditorKind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND));

    // Source
    Core::GeneratedFile sourceFile(sourceFileName);
    sourceFile.setEditorKind(QLatin1String(CppEditor::Constants::CPPEDITOR_KIND));

    // UI
    Core::GeneratedFile uiFile(formFileName);
    uiFile.setContents(params.uiTemplate());
    uiFile.setEditorKind(QLatin1String(Constants::C_FORMEDITOR));

    QString source, header;
    Designer::FormClassWizardGenerationParameters generationParameters;
    generationParameters.fromSettings(Core::ICore::instance()->settings());
    params.generateCpp(generationParameters, &header, &source);
    sourceFile.setContents(source);
    headerFile.setContents(header);

    if (Designer::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << '\n' << header << '\n' << source;

    return  Core::GeneratedFiles() << headerFile << sourceFile << uiFile;
}
Example #9
0
Core::GeneratedFiles FormClassWizard::generateFiles(const QWizard *w, QString *errorMessage) const
{
    const FormClassWizardDialog *wizardDialog = qobject_cast<const FormClassWizardDialog *>(w);
    const Designer::FormClassWizardParameters params = wizardDialog->parameters();

    if (params.uiTemplate.isEmpty()) {
        *errorMessage = QLatin1String("Internal error: FormClassWizard::generateFiles: empty template contents");
        return Core::GeneratedFiles();
    }

    // header
    const QString formFileName = buildFileName(params.path, params.uiFile, formSuffix());
    const QString headerFileName = buildFileName(params.path, params.headerFile, headerSuffix());
    const QString sourceFileName = buildFileName(params.path, params.sourceFile, sourceSuffix());

    Core::GeneratedFile headerFile(headerFileName);
    headerFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    // Source
    Core::GeneratedFile sourceFile(sourceFileName);
    sourceFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    // UI
    Core::GeneratedFile uiFile(formFileName);
    uiFile.setContents(params.uiTemplate);
    uiFile.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    QString source, header;

    QtDesignerFormClassCodeGenerator::generateCpp(params, &header, &source);
    sourceFile.setContents(source);
    headerFile.setContents(header);

    if (Designer::Constants::Internal::debug)
        qDebug() << Q_FUNC_INFO << '\n' << header << '\n' << source;

    return  Core::GeneratedFiles() << headerFile << sourceFile << uiFile;
}
Example #10
0
string HomeDirPlugin::buildFileName(const char *name)
{
    QString s;
    QString fname = QFile::decodeName(name);
#ifdef WIN32
    if ((fname[1] != ':') && (fname.left(2) != "\\\\")){
#else
    if (fname[0] != '/'){
#endif
        s += QFile::decodeName(m_homeDir.c_str());
#ifdef WIN32
        s += '\\';
#else
        s += '/';
#endif
    }
    s += fname;
    string res;
    res = QFile::encodeName(s);
    return res;
}

void *HomeDirPlugin::processEvent(Event *e)
{
    if (e->type() == EventHomeDir){
        string *cfg = (string*)(e->param());
        *cfg = buildFileName(cfg->c_str());
        return (void*)(cfg->c_str());
    }
    return NULL;
}

#ifdef WIN32
#include <windows.h>

/**
 * DLL's entry point
 **/
int WINAPI DllMain(HINSTANCE, DWORD, LPVOID)
{
    return TRUE;
}

/**
 * This is to prevent the CRT from loading, thus making this a smaller
 * and faster dll.
 **/
extern "C" BOOL __stdcall _DllMainCRTStartup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
    return DllMain( hinstDLL, fdwReason, lpvReserved );
}
bool PosixFileSystem::remove(const Path& path)
{
   // Should probably check for outstanding files or directory objects.
   String file = buildFileName(_volume,path);

   struct stat info;
   int error = stat(file.c_str(),&info);
   if (error < 0)
      return false;

   if (S_ISDIR(info.st_mode))
      return !rmdir(file);
   
   return !unlink(file);
}
FileNodeRef PosixFileSystem::resolve(const Path& path)
{
   String file = buildFileName(_volume,path);
   struct stat info;
   if (stat(file.c_str(),&info) == 0)
   {
      // Construct the appropriate object
      if (S_ISREG(info.st_mode))
         return new PosixFile(path,file);
         
      if (S_ISDIR(info.st_mode))
         return new PosixDirectory(path,file);
   }
   
   return 0;
}
Example #13
0
Core::GeneratedFiles LibraryWizard::generateFiles(const QWizard *w,
                                                 QString *errorMessage) const
{
    Q_UNUSED(errorMessage)
    const LibraryWizardDialog *dialog = qobject_cast<const LibraryWizardDialog *>(w);
    const QtProjectParameters projectParams = dialog->parameters();
    const QString projectPath = projectParams.projectPath();
    const LibraryParameters params = dialog->libraryParameters();

    const QString sharedLibExportMacro = QtProjectParameters::exportMacro(projectParams.fileName);

    Core::GeneratedFiles rc;
    // Class header + source
    const QString sourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix());
    Core::GeneratedFile source(sourceFileName);
    source.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    const QString headerFileFullName = buildFileName(projectPath, params.headerFileName, headerSuffix());
    const QString headerFileName = Utils::FileName::fromString(headerFileFullName).fileName();
    QString pluginJsonFileFullName;
    QString pluginJsonFileName;
    if (projectParams.type == QtProjectParameters::Qt4Plugin) {
        pluginJsonFileFullName = buildFileName(projectPath, projectParams.fileName, QLatin1String("json"));
        pluginJsonFileName = Utils::FileName::fromString(pluginJsonFileFullName).fileName();
    }

    Core::GeneratedFile header(headerFileFullName);

    // Create files: global header for shared libs
    QString globalHeaderFileName;
    if (projectParams.type == QtProjectParameters::SharedLibrary) {
        const QString globalHeaderName = buildFileName(projectPath, projectParams.fileName.toLower() + QLatin1String(sharedHeaderPostfixC), headerSuffix());
        Core::GeneratedFile globalHeader(globalHeaderName);
        globalHeaderFileName = Utils::FileName::fromString(globalHeader.path()).fileName();
        globalHeader.setContents(CppTools::AbstractEditorSupport::licenseTemplate(globalHeaderFileName)
                                 + LibraryParameters::generateSharedHeader(globalHeaderFileName, projectParams.fileName, sharedLibExportMacro));
        rc.push_back(globalHeader);
    }

    // Generate code
    QString headerContents, sourceContents;
    params.generateCode(projectParams.type, projectParams.fileName,  headerFileName,
                        globalHeaderFileName, sharedLibExportMacro, pluginJsonFileName,
                        /* indentation*/ 4, &headerContents, &sourceContents);

    source.setContents(CppTools::AbstractEditorSupport::licenseTemplate(sourceFileName, params.className)
                       + sourceContents);
    header.setContents(CppTools::AbstractEditorSupport::licenseTemplate(headerFileFullName, params.className)
                       + headerContents);
    rc.push_back(source);
    rc.push_back(header);
    // Create files: profile
    const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix());
    Core::GeneratedFile profile(profileName);
    profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
    QString profileContents;
    {
        QTextStream proStr(&profileContents);
        QtProjectParameters::writeProFileHeader(proStr);
        projectParams.writeProFile(proStr);
        proStr << "\nSOURCES += " << Utils::FileName::fromString(source.path()).fileName()
               << "\n\nHEADERS += " << headerFileName;
        if (!globalHeaderFileName.isEmpty())
            proStr << "\\\n        " << globalHeaderFileName << '\n';
        if (!pluginJsonFileName.isEmpty())
            proStr << "\nDISTFILES += " << pluginJsonFileName << '\n';
        writeLinuxProFile(proStr);
    }
    profile.setContents(profileContents);
    rc.push_back(profile);

    if (!pluginJsonFileName.isEmpty()) {
        Core::GeneratedFile jsonFile(pluginJsonFileFullName);
        jsonFile.setContents(QLatin1String("{\n    \"Keys\" : [ ]\n}\n"));
        rc.push_back(jsonFile);
    }
    return rc;
}
Example #14
0
 QString currentFileName() {
     return buildFileName( counter );
 }
Example #15
0
Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
                                                 QString *errorMessage) const
{
    const GuiAppWizardDialog *dialog = qobject_cast<const GuiAppWizardDialog *>(w);
    const QtProjectParameters projectParams = dialog->projectParameters();
    const QString projectPath = projectParams.projectPath();
    const GuiAppParameters params = dialog->parameters();
    const QString license = CppTools::AbstractEditorSupport::licenseTemplate();

    // Generate file names. Note that the path for the project files is the
    // newly generated project directory.
    const QString templatePath = templateDir();
    // Create files: main source
    QString contents;
    const QString mainSourceFileName = buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix());
    Core::GeneratedFile mainSource(mainSourceFileName);
    if (!parametrizeTemplate(templatePath, QLatin1String("main.cpp"), params, &contents, errorMessage))
        return Core::GeneratedFiles();
    mainSource.setContents(CppTools::AbstractEditorSupport::licenseTemplate(mainSourceFileName)
                           + contents);
    // Create files: form source with or without form
    const QString formSourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix());
    const QString formHeaderName = buildFileName(projectPath, params.headerFileName, headerSuffix());
    Core::GeneratedFile formSource(formSourceFileName);
    Core::GeneratedFile formHeader(formHeaderName);
    formSource.setAttributes(Core::GeneratedFile::OpenEditorAttribute);

    QSharedPointer<Core::GeneratedFile> form;
    if (params.designerForm) {
        // Create files: form
        const QString formName = buildFileName(projectPath, params.formFileName, formSuffix());
        form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName));
        if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage))
            return Core::GeneratedFiles();
        form->setContents(contents);
        if (!generateFormClass(params, *form, &formSource, &formHeader, errorMessage))
            return Core::GeneratedFiles();
    } else {
        const QString formSourceTemplate = QLatin1String("mywidget.cpp");
        if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage))
            return Core::GeneratedFiles();
        formSource.setContents(CppTools::AbstractEditorSupport::licenseTemplate(formSourceFileName)
                               + contents);
        // Create files: form header
        const QString formHeaderTemplate = QLatin1String("mywidget.h");
        if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage))
            return Core::GeneratedFiles();
        formHeader.setContents(CppTools::AbstractEditorSupport::licenseTemplate(formHeaderName)
                               + contents);
    }
    // Create files: profile
    const QString profileName = buildFileName(projectPath, projectParams.fileName, profileSuffix());
    Core::GeneratedFile profile(profileName);
    profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute);
    contents.clear();
    {
        QTextStream proStr(&contents);
        QtProjectParameters::writeProFileHeader(proStr);
        projectParams.writeProFile(proStr);
        proStr << "\n\nSOURCES += " << QFileInfo(mainSourceFileName).fileName()
               << "\\\n        " << QFileInfo(formSource.path()).fileName()
               << "\n\nHEADERS  += " << QFileInfo(formHeader.path()).fileName();
        if (params.designerForm)
            proStr << "\n\nFORMS    += " << QFileInfo(form->path()).fileName();
        if (params.isMobileApplication) {
            // Generate a development Symbian UID for the application:
            QString uid3String = QLatin1String("0xe") + QUuid::createUuid().toString().mid(1, 7);

            proStr << "\n\nCONFIG += mobility"
                   << "\nMOBILITY = "
                   << "\n\nsymbian {"
                   << "\n    TARGET.UID3 = " << uid3String
                   << "\n    # TARGET.CAPABILITY += "
                   << "\n    TARGET.EPOCSTACKSIZE = 0x14000"
                   << "\n    TARGET.EPOCHEAPSIZE = 0x020000 0x800000"
                   << "\n}";
        }
        proStr << '\n';
    }
    profile.setContents(contents);
    // List
    Core::GeneratedFiles rc;
    rc << mainSource << formSource << formHeader;
    if (params.designerForm)
        rc << *form;
    rc << profile;
    return rc;
}
void ImageExporterOutputWidget::handleSave(bool)
{
    m_context->makeCurrent();
    m_imageExporter->save(buildFileName(), std::max(1, m_resolution->width()), std::max(1, m_resolution->height()));
    m_context->doneCurrent();
}
Example #17
0
static
PGPError pgpInitSDKPrefsDir( PGPContextRef context )
{
    char            *pszTemp = NULL;
    char            rootPath[MAX_PATH] = {'\0'};
    char            filename[MAX_PATH] = {'\0'};
    FILE            *fp = NULL;
    PGPUInt16       len = 0;
    PGPError        err = kPGPError_NoErr;
    PGPKeySetRef    keyset = kPGPInvalidRef;

#ifdef PGP_UNIX
    PFLFileSpecRef  dirspec = kPGPInvalidRef;
    PGPMemoryMgrRef mmgr = kPGPInvalidRef;
    PFLFileSpecRef  sdkpflPrefs = kPGPInvalidRef;
    PGPBoolean	    exists = FALSE;
    
    err = PGPNewMemoryMgr(0, &mmgr);
    if(IsPGPError(err))
        return err;

    err = pgpGetPrefsSpec( mmgr, &sdkpflPrefs );
    if(IsPGPError(err)) 
    {
        PGPFreeMemoryMgr(mmgr);
        return err;
    }

    err = PFLGetParentDirectory(sdkpflPrefs, &dirspec);
    if(IsPGPError(err))
    {
        PFLFreeFileSpec(sdkpflPrefs);
        PGPFreeMemoryMgr(mmgr);
        return err;
    }
    err = PFLFileSpecExists(dirspec, &exists);
    pgpAssertNoErr(err);

    if(!exists) /* need to create directory */
    {
        char    *dirname;

        err = PFLGetFullPathFromFileSpec( dirspec, &dirname );
        pgpAssertNoErr(err);
        if(mkdir(dirname, 0700) == -1)
        {
            fprintf(stderr, LANG("mkdir (%s) failed..\n\n"), dirname);
            err = kPGPError_CantOpenFile;
        }
        PGPFreeData(dirname);
    }
    if(dirspec != kPGPInvalidRef)
        PGPFreeFileSpec(dirspec);
    if(sdkpflPrefs != kPGPInvalidRef)
        PFLFreeFileSpec(sdkpflPrefs);
    if(mmgr != kPGPInvalidRef)
        PGPFreeMemoryMgr(mmgr);


#endif /* PGP_UNIX */

    err = PGPsdkLoadDefaultPrefs(context);
    pgpAssertNoErr(err);
    err = PGPOpenDefaultKeyRings(context, 
                    kPGPKeyRingOpenFlags_Create | 
                    kPGPKeyRingOpenFlags_Mutable, &keyset);
    if(IsntPGPError(err))
    {
        PGPFreeKeySet(keyset);
    }
    else
        return err;

    /* now check to see if configuration file exists, if not, create it */
    buildFileName(filename, "pgp.cfg");
    if((fp = fopen(filename, "r")) != NULL)
        fclose(fp);
    else
    {
        /* file doesn't exist, create it */
        touchFile(filename, 0600);
    }
    return err;
}
Example #18
0
Core::GeneratedFiles GuiAppWizard::generateFiles(const QWizard *w,
                                                 QString *errorMessage) const
{
    const GuiAppWizardDialog *dialog = qobject_cast<const GuiAppWizardDialog *>(w);
    const QtProjectParameters projectParams = dialog->projectParameters();
    const QString projectPath = projectParams.projectPath();
    const GuiAppParameters params = dialog->parameters();

    // Generate file names. Note that the path for the project files is the
    // newly generated project directory.
    const QString templatePath = templateDir();
    // Create files: main source
    QString contents;
    const QString mainSourceFileName = buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix());
    Core::GeneratedFile mainSource(mainSourceFileName);
    if (!parametrizeTemplate(templatePath, QLatin1String("main.cpp"), params, &contents, errorMessage))
        return Core::GeneratedFiles();
    mainSource.setContents(contents);
    // Create files: form source
    const QString formSourceTemplate = params.designerForm ? QLatin1String("mywidget_form.cpp") : QLatin1String("mywidget.cpp");
    const QString formSourceFileName = buildFileName(projectPath, params.sourceFileName, sourceSuffix());
    Core::GeneratedFile formSource(formSourceFileName);
    if (!parametrizeTemplate(templatePath, formSourceTemplate, params, &contents, errorMessage))
        return Core::GeneratedFiles();
    formSource.setContents(contents);
    // Create files: form header
    const QString formHeaderName = buildFileName(projectPath, params.headerFileName, headerSuffix());
    const QString formHeaderTemplate = params.designerForm ? QLatin1String("mywidget_form.h") : QLatin1String("mywidget.h");
    Core::GeneratedFile formHeader(formHeaderName);
    if (!parametrizeTemplate(templatePath, formHeaderTemplate, params, &contents, errorMessage))
        return Core::GeneratedFiles();
    formHeader.setContents(contents);
    // Create files: form
    QSharedPointer<Core::GeneratedFile> form;
    if (params.designerForm) {
        const QString formName = buildFileName(projectPath, params.formFileName, formSuffix());
        form = QSharedPointer<Core::GeneratedFile>(new Core::GeneratedFile(formName));
        if (!parametrizeTemplate(templatePath, QLatin1String("widget.ui"), params, &contents, errorMessage))
            return Core::GeneratedFiles();
        form->setContents(contents);
    }
    // Create files: profile
    const QString profileName = buildFileName(projectPath, projectParams.name, profileSuffix());
    Core::GeneratedFile profile(profileName);
    contents.clear();
    {
        QTextStream proStr(&contents);
        QtProjectParameters::writeProFileHeader(proStr);
        projectParams.writeProFile(proStr);
        proStr << "\n\nSOURCES += " << QFileInfo(mainSourceFileName).fileName()
               << "\\\n        " << QFileInfo(formSource.path()).fileName()
               << "\n\nHEADERS  += " << QFileInfo(formHeader.path()).fileName();
        if (params.designerForm)
            proStr << "\n\nFORMS    += " << QFileInfo(form->path()).fileName();
        proStr << '\n';
    }
    profile.setContents(contents);
    // List
    Core::GeneratedFiles rc;
    rc << mainSource << formSource << formHeader;
    if (params.designerForm)
        rc << *form;
    rc << profile;
    return rc;
}
Example #19
0
void ManGenerator::startFile(const char *,const char *manName,const char *)
{
  startPlainFile( buildFileName( manName ) );
  firstCol=TRUE;
}
Path PosixFileSystem::mapTo(const Path& path)
{
   return buildFileName(_volume,path);
}