Beispiel #1
0
// Return true while success.
bool FindFiles::processFile(OovStringRef const filePath)
    {
    bool success = true;
    FilePath ext(filePath, FP_File);

    bool isSource = (isCppHeader(ext) || isCppSource(ext) || isJavaSource(ext));
    if(mSourceFilesOnly ? isSource : true)
        {
        FILE *fp = fopen(filePath.getStr(), "r");
        if(fp)
            {
            char buf[1000];
            int lineNum = 0;
            while(fgets(buf, sizeof(buf), fp))
                {
                lineNum++;
                char const *match=NULL;
                if(mCaseSensitive)
                    {
                    match = strstr(buf, mSrchStr.c_str());
                    }
                else
                    {
                    match = strcasestr(buf, mSrchStr.c_str());
                    }
                if(match)
                    {
                    mNumMatches++;
                    OovString matchStr = filePath;
                    matchStr += ':';
                    matchStr.appendInt(lineNum);
                    matchStr += "   ";
                    matchStr += buf;
//                  matchStr += '\n';
                    Gui::appendText(mView, matchStr);
                    }
                }
            fclose(fp);
            }
        }
    return success;
    }
Beispiel #2
0
bool CMaker::writeFile(OovStringRef const destName, OovStringRef const str)
    {
    bool success = true;
    if(str.numBytes() > 0)
        {
        File file(destName, "w");
        if(file.isOpen())
            {
            success = file.putString("# Generated by oovCMaker\n");
            if(success)
                {
                success = file.putString(str);
                }
            }
        }
    if(!success)
        {
        OovString errStr = "Unable to write file ";
        errStr += destName;
        OovError::report(ET_Error, errStr);
        }
    return success;
    }
Beispiel #3
0
enum ComponentTypesFile::eCompTypes ComponentTypesFile::getComponentTypeFromTypeName(
        OovStringRef const compTypeName)
    {
    eCompTypes ct = CT_Unknown;
    if(compTypeName.numBytes() != 0)
        {
        if(compTypeName[0] == 'P')
            ct = CT_Program;
        else if(compTypeName[0] == 'U')
            ct = CT_Unknown;
        else if(compTypeName[1] == 't')
            ct = CT_StaticLib;
        else if(compTypeName[1] == 'h')
            ct = CT_SharedLib;
        else if(compTypeName[0] == 'J')
            {
            if(compTypeName[4] == 'L' || compTypeName[5] == 'L')
                { ct = CT_JavaJarLib; }
            else
                { ct = CT_JavaJarProg; }
            }
        }
    return ct;
    }
Beispiel #4
0
void FileRename(OovStringRef const  oldPath, OovStringRef const  newPath)
{
    rename(oldPath.getStr(), newPath.getStr());
}
Beispiel #5
0
void FileDelete(OovStringRef const path)
{
    unlink(path.getStr());
}
Beispiel #6
0
std::string FilePathFixFilePath(OovStringRef const fullFn)
{
    return fullFn.getStr();
}
Beispiel #7
0
OovString FilePathMakeExeFilename(OovStringRef const  rootFn)
{
    return rootFn.getStr();
}
Beispiel #8
0
void CMaker::makeComponentFile(OovStringRef const compName,
    ComponentTypesFile::eCompTypes compType,
    OovStringVec const &sources, OovStringRef const destName)
    {
    OovString str;
    if(mVerbose)
        printf("Processing %s\n      %s\n", compName.getStr(), destName.getStr());
    if(compType == ComponentTypesFile::CT_Program)
        {
        if(mVerbose)
            printf("  Executable\n");

        addCommandAndNames(CT_Exec, compName, sources, str);

        addLibsAndIncs(compName, str);

        str += "install(TARGETS ";
        str += compName;
        str += "\n  EXPORT ";
        str += mProjectName;
        str += "Targets";
        str += "\n  RUNTIME DESTINATION \"${INSTALL_BIN_DIR}\" COMPONENT lib)\n";
        }
    else if(compType == ComponentTypesFile::CT_SharedLib)
        {
        if(mVerbose)
            printf("  SharedLib\n");
        addCommandAndNames(CT_Shared, compName, sources, str);

        addLibsAndIncs(compName, str);

        str += "install(TARGETS ";
        str += compName;
        str += "\n  LIBRARY DESTINATION \"${INSTALL_LIB_DIR}\" COMPONENT lib)\n";
        }
    else if(compType == ComponentTypesFile::CT_StaticLib)
        {
        if(mVerbose)
            printf("  Library\n");
        OovStringVec headers = mCompTypes.getComponentIncludes(compName);
        discardDirs(headers);

        OovStringVec allFiles = headers;
        allFiles.insert(allFiles.end(), sources.begin(), sources.end() );
        std::sort(allFiles.begin(), allFiles.end(), compareNoCase);
        if(sources.size() == 0)
            {
            addCommandAndNames(CT_Interface, compName, allFiles, str);
            str += "set_target_properties(";
            str += compName;
            str += " PROPERTIES LINKER_LANGUAGE CXX)\n";
            }
        else
            addCommandAndNames(CT_Static, compName, allFiles, str);

        addCommandAndNames(CT_TargHeaders, compName, headers, str);


        str += "install(TARGETS ";
        str += compName;
        str += "\n  EXPORT ";
        str += mProjectName;
        str += "Targets";
        str += "\n  ARCHIVE DESTINATION \"${INSTALL_LIB_DIR}\" COMPONENT lib";
        str += "\n  PUBLIC_HEADER DESTINATION \"${INSTALL_INCLUDE_DIR}/";
        str += mProjectName;
        str += "\" COMPONENT dev)\n";
        }
    writeFile(destName, str);
    }
Beispiel #9
0
OovStatusReturn FileRename(OovStringRef const  oldPath, OovStringRef const  newPath)
    {
    return OovStatus(rename(oldPath.getStr(), newPath.getStr()) == 0, SC_File);
    }
Beispiel #10
0
OovStatusReturn FileDelete(OovStringRef const path)
    {
    return OovStatus(unlink(path.getStr()) == 0 || errno == ENOENT, SC_File);
    }
Beispiel #11
0
void OovIpc::sendMessage(OovStringRef msg)
    {
    printf("%s", msg.getStr());
    fflush(stdout);
    }