void CTest::CreateSourceTree(void)
{
    // Main directory
    string basedir = GetDir("test_archive_in");
    assert(CDir(basedir).Create());

    // Files
    CreateFile(basedir + "/file0_1.txt",   0, 1000);
    CreateFile(basedir + "/file0_2.txt",  10, 2000);
    CreateFile(basedir + "/file0_3.bin",  20, 3000);
    CreateFile(basedir + "/file0_4.txt", 100, 4000);
    CreateFile(basedir + "/file0_5.bin", 200, 5000);
    CreateFile(basedir + "/file0_6.bin", 300, 6000);
    CreateFile(basedir + "/file0_7.txt", 700, 7000);
    CreateFile(basedir + "/file0_8.dat",  80, 8000);

    // Subdirectory
    assert(CDir(basedir + "/subdir1").Create());
    CreateFile(basedir + "/subdir1/file1_1.txt",   1, 1001);
    CreateFile(basedir + "/subdir1/file1_2.txt",  11, 2001);
    CreateFile(basedir + "/subdir1/file1_3.bin",  21, 3001);

    assert(CDir(basedir + "/subdir2").Create());
    CreateFile(basedir + "/subdir2/file2_1.txt",  12, 1002);
    CreateFile(basedir + "/subdir2/file2_2.txt",  12, 2002);
    CreateFile(basedir + "/subdir2/file2_3.bin",  22, 3002);
    CreateFile(basedir + "/subdir2/file2_4.dat", 102, 4002);
}
void CTest::RunInternalTest(void)
{
    const CArgs& args = GetArgs();
    string test = args["fmt"].AsString();

    // Set a random starting point
    unsigned int seed = (unsigned int)time(0);
    //LOG_POST("Random seed = " << seed);
    srand(seed);

    // Preparing test data
    m_BufLen = 10*100*1024;  // 10MB
    AutoArray<char> src_buf_arr(m_BufLen);
    m_Buf = src_buf_arr.get();
    assert(m_Buf);
    for (size_t i=0; i<m_BufLen; i++) {
        m_Buf[i] = (char)(rand() % 255);
    }
    // Prepare source tree
    CreateSourceTree();

    // Run tests
    if (test == "all"  ||  test == "zip") {
        _TRACE("-------------- Zip ---------------\n");
        RunInternalTestFormat(CArchive::eZip);
    }

    // Cleanup
    CDir(GetDir("test_archive_in")).Remove();
    CDir(GetDir("test_archive_out")).Remove();

}
Esempio n. 3
0
void CMsvcConfigureProjectGenerator::CreateProjectFileItem(bool with_gui) const
{
    string file_path = CDirEntry::ConcatPath(m_ProjectDir,
        with_gui ? m_SrcFileNameGui : m_SrcFileName);
    file_path += m_ProjectItemExt;

    // Create dir if no such dir...
    string dir;
    CDirEntry::SplitPath(file_path, &dir);
    CDir project_dir(dir);
    if ( !project_dir.Exists() ) {
        CDir(dir).CreatePath();
    }
    
    // Prototype of command line for launch project_tree_builder (See above)
    CNcbiOfstream  ofs(file_path.c_str(), IOS_BASE::out | IOS_BASE::trunc);
    if ( !ofs )
        NCBI_THROW(CProjBulderAppException, eFileCreation, file_path);

    GetApp().RegisterGeneratedFile( file_path );
    ofs << "set PTB_FLAGS=";
    if ( m_DllBuild )
        ofs << " -dll";
    if (!m_BuildPtb) {
        ofs << " -nobuildptb";
    }
    if (GetApp().m_AddMissingLibs) {
        ofs << " -ext";
    }
    if (!GetApp().m_ScanWholeTree) {
        ofs << " -nws";
    }
    if (!GetApp().m_BuildRoot.empty()) {
        ofs << " -extroot \"" << GetApp().m_BuildRoot << "\"";
    }
    if (with_gui /*|| GetApp().m_ConfirmCfg*/) {
        ofs << " -cfg";
    }
    if (GetApp().m_ProjTagCmnd) {
        if (GetApp().m_ProjTags != "*") {
            ofs << " -projtag \"" << GetApp().m_ProjTags << "\"";
        } else {
            ofs << " -projtag #";
        }
    }
    ofs << "\n";
    ofs << "set PTB_PROJECT_REQ=" << m_SubtreeToBuild << "\n";
    ofs << "call \"%BUILD_TREE_ROOT%\\ptb.bat\"\n";
    ofs << "if errorlevel 1 exit 1\n";
}
Esempio n. 4
0
/// Find the path to the gene info files, first checking the environment
/// variable GENE_INFO_PATH, then the section BLAST, label
/// GENE_INFO_PATH in the NCBI configuration file. If not found in either
/// location, try the $BLASTDB/gene_info directory. If all fails return the
/// current working directory
/// @sa s_FindPathToWM
static string
s_FindPathToGeneInfoFiles(void)
{
    string retval = kEmptyStr;
    const string kSection("BLAST");
    CNcbiIstrstream empty_stream(kEmptyCStr);
    CRef<CNcbiRegistry> reg(new CNcbiRegistry(empty_stream,
                                              IRegistry::fWithNcbirc));
    CRef<CSimpleEnvRegMapper> mapper(new CSimpleEnvRegMapper(kSection,
                                                             kEmptyStr));
    CRef<CEnvironmentRegistry> env_reg(new CEnvironmentRegistry);
    env_reg->AddMapper(*mapper, CEnvironmentRegistry::ePriority_Max);
    reg->Add(*env_reg, CNcbiRegistry::ePriority_MaxUser);
    retval = reg->Get(kSection, GENE_INFO_PATH_ENV_VARIABLE);

    // Try the features subdirectory in the BLAST database storage location
    if (retval == kEmptyStr) {
        if ( (retval = reg->Get(kSection, "BLASTDB")) != kEmptyStr) {
            retval = CDirEntry::ConcatPath(retval, "gene_info");
            if ( !CDir(retval).Exists() ) {
                retval = kEmptyStr;
            }
        }
    }

    if (retval == kEmptyStr) {
        retval = CDir::GetCwd();
    }
#if defined(NCBI_OS_MSWIN)
	// We address this here otherwise CDirEntry::IsAbsolutePath() fails
	if (NStr::StartsWith(retval, "//")) {
		NStr::ReplaceInPlace(retval, "//", "\\\\");
	}
#endif
    return retval;
}
Esempio n. 5
0
static void s_CreateThirdPartyLibsInstallMakefile
                                            (CMsvcSite&   site, 
                                             const list<string> libs_to_install,
                                             const SConfigInfo& config,
                                             const CBuildType&  build_type)
{
    // Create makefile path
    string makefile_path = GetApp().GetProjectTreeInfo().m_Compilers;
    makefile_path = 
        CDirEntry::ConcatPath(makefile_path, 
                              GetApp().GetRegSettings().m_CompilersSubdir);

    makefile_path = CDirEntry::ConcatPath(makefile_path, build_type.GetTypeStr());
    makefile_path = CDirEntry::ConcatPath(makefile_path, config.GetConfigFullName());
    makefile_path = CDirEntry::ConcatPath(makefile_path, 
                                          "Makefile.third_party.mk");

    // Create dir if no such dir...
    string dir;
    CDirEntry::SplitPath(makefile_path, &dir);
    CDir makefile_dir(dir);
    if ( !makefile_dir.Exists() ) {
        CDir(dir).CreatePath();
    }

    CNcbiOfstream ofs(makefile_path.c_str(), 
                      IOS_BASE::out | IOS_BASE::trunc );
    if ( !ofs )
        NCBI_THROW(CProjBulderAppException, eFileCreation, makefile_path);

    GetApp().RegisterGeneratedFile( makefile_path );
    ITERATE(list<string>, n, libs_to_install) {
        const string& lib = *n;
        SLibInfo lib_info;
        site.GetLibInfo(lib, config, &lib_info);
        if ( !lib_info.m_LibPath.empty() ) {
            string bin_dir = lib_info.m_LibPath;
            string bin_path = lib_info.m_BinPath;
            if (bin_path.empty()) {
                bin_path = site.GetThirdPartyLibsBinSubDir();
            }
            bin_dir = 
                CDirEntry::ConcatPath(bin_dir, bin_path);
            bin_dir = CDirEntry::NormalizePath(bin_dir);
            if ( CDirEntry(bin_dir).Exists() ) {
                //
                string key(lib);
                NStr::ToUpper(key);
                key += site.GetThirdPartyLibsBinPathSuffix();

                ofs << key << " = " << bin_dir << "\n";

                s_ResetLibInstallKey(dir, lib);
                site.SetThirdPartyLibBin(lib, bin_dir);
            } else {
                PTB_WARNING_EX(bin_dir, ePTB_PathNotFound,
                               lib << "|" << config.GetConfigFullName()
                               << " disabled, path not found");
            }
        } else {
            PTB_WARNING_EX(kEmptyStr, ePTB_PathNotFound,
                           lib << "|" << config.GetConfigFullName()
                           << ": no LIBPATH specified");
        }
    }
}