Function initProject

Synopsis

#include <src/init.hpp>

void initProject(Output *output, const char *name, const char *file, const char *path)

Description

No description yet.

Source

Lines 28-57 in src/init.cpp. Line 5 in src/init.hpp.

void initProject(Output* output, const char* name, const char* file, const char* path)
{
    if (fileExists(file))
    {
        output->error("Error: project %s already exists\n", file);
        return;
    }

    createPathForFile(file);

    std::ofstream out(file);
    if (!out)
    {
        output->error("Error opening project file %s for writing\n", file);
        return;
    }

    std::string cwd = getCurrentDirectory();
    std::string npath = normalizePath(cwd.c_str(), path);

    out << "path " << npath << std::endl << std::endl;

    for (size_t i = 0; i + 1 < sizeof(kDefaultLanguages) / sizeof(kDefaultLanguages[0]); i += 2)
    {
        out << "# " << kDefaultLanguages[i] << std::endl;
        out << "include \\.(" << kDefaultLanguages[i + 1] << ")$" << std::endl;
    }

    output->print("Project file %s created, run `qgrep update %s` to build\n", file, name);
}





Add Discussion as Guest

Log in