Ejemplo n.º 1
0
/*----------------------------------------------------------------------
|   TestRemoveEmptyDirectory
+---------------------------------------------------------------------*/
void
TestRemoveEmptyDirectory()
{
    NPT_DirectoryEntryInfo info;
    NPT_String             path;
    NPT_Result             res;

    // read path from environment variable
    res = NPT_GetEnvironment("NEPTUNE_TEST_ROOT", path);
    CHECK(NPT_SUCCEEDED(res));

    // find the next directory path that does not exist
    res = FindNextAvailableDirectory(path, path);
    CHECK(NPT_SUCCEEDED(res));

    // create directory object
    res = NPT_DirectoryCreate(path, true);
    CHECK(NPT_SUCCEEDED(res));

    // remove empty directory
    res = NPT_DirectoryRemove(path, false);
    CHECK(NPT_SUCCEEDED(res));

    // verify directory does not exist any more
    res = NPT_DirectoryEntry::GetInfo(path, &info);
    CHECK(res == NPT_ERROR_NO_SUCH_ITEM);
}
Ejemplo n.º 2
0
/*----------------------------------------------------------------------
|   NPT_LogManager::Configure
+---------------------------------------------------------------------*/
NPT_Result
NPT_LogManager::Configure(const char* config_sources) 
{
    // exit if we're already initialized
    if (m_Configured) return NPT_SUCCESS;

    // we need to be disabled while we configure ourselves
    NPT_LogManagerAutoDisabler autodisabler;
    
    // set some default config values
    SetConfigValue(".handlers", NPT_LOG_ROOT_DEFAULT_HANDLER);

    // see if the config sources have been set to non-default values
    if (config_sources == NULL) {
        config_sources = NPT_CONFIG_DEFAULT_LOG_CONFIG_SOURCE;
    }
    NPT_String config_sources_system;
    if (NPT_SUCCEEDED(NPT_GetSystemLogConfig(config_sources_system))) {
        config_sources = config_sources_system;
    }
    NPT_String config_sources_env;
    if (NPT_SUCCEEDED(NPT_GetEnvironment(NPT_CONFIG_LOG_CONFIG_ENV, config_sources_env))) {
        config_sources = config_sources_env;
    }

    /* load all configs */
    NPT_String config_source;
    const char* cursor = config_sources; 
    const char* source = config_sources;
    for (;;) {
        if (*cursor == '\0' || *cursor == '|') {
            if (cursor != source) {
                config_source.Assign(source, (NPT_Size)(cursor-source));
                config_source.Trim(" \t");
                ParseConfigSource(config_source);
            }
            if (*cursor == '\0') break;
        }
        cursor++;
    }

    /* create the root logger */
    LogManager.m_Root = new NPT_Logger("", *this);
    LogManager.m_Root->m_Level = NPT_CONFIG_DEFAULT_LOG_LEVEL;
    LogManager.m_Root->m_LevelIsInherited = false;
    ConfigureLogger(LogManager.m_Root);

    // we're initialized now
    m_Configured = true;

    return NPT_SUCCESS;
}
Ejemplo n.º 3
0
/*----------------------------------------------------------------------
|   TestRemoveDirectory
+---------------------------------------------------------------------*/
void
TestRemoveDirectory()
{
    NPT_DirectoryEntryInfo info;
    NPT_String             path;
    NPT_Result             res;

    // read path from environment variable
    res = NPT_GetEnvironment("NEPTUNE_TEST_ROOT", path);
    CHECK(NPT_SUCCEEDED(res));

    // find the next directory path that does not exist
    res = FindNextAvailableDirectory(path, path);
    CHECK(NPT_SUCCEEDED(res));

    // create directory object
    res = NPT_DirectoryCreate(path, true);
    CHECK(NPT_SUCCEEDED(res));

    // create some subdirectories
    res = CreateEntry(path, "foof1", true);
    CHECK(NPT_SUCCEEDED(res));
    res = CreateEntry(path, "foof2", true);
    CHECK(NPT_SUCCEEDED(res));
    res = CreateEntry(path, "foof2.dir", true);
    CHECK(NPT_SUCCEEDED(res));

    // create some files
    res = CreateEntry(path, "foo1", false);
    CHECK(NPT_SUCCEEDED(res));
    res = CreateEntry(path, "foo2.", false);
    CHECK(NPT_SUCCEEDED(res));
    res = CreateEntry(path, "foo2.e", false);
    CHECK(NPT_SUCCEEDED(res));
    res = CreateEntry(path, "foo2.e3", false);
    CHECK(NPT_SUCCEEDED(res));
    res = CreateEntry(path, "foo2.gas", false);
    CHECK(NPT_SUCCEEDED(res));
    res = CreateEntry(path, "foo4.tee", false);
    CHECK(NPT_SUCCEEDED(res));

    // remove directory
    res = NPT_DirectoryRemove(path, true);
    CHECK(NPT_SUCCEEDED(res));

    // verify directory does not exist any more
    res = NPT_DirectoryEntry::GetInfo(path, &info);
    CHECK(res == NPT_ERROR_NO_SUCH_ITEM);
}
Ejemplo n.º 4
0
/*----------------------------------------------------------------------
|   NPT_System::GetMachineName
+---------------------------------------------------------------------*/
NPT_Result
NPT_System::GetMachineName(NPT_String& name)
{
    return NPT_GetEnvironment("USER", name);
}
Ejemplo n.º 5
0
/*----------------------------------------------------------------------
|   NPT_System::GetMachineName
+---------------------------------------------------------------------*/
NPT_Result
NPT_System::GetMachineName(NPT_String& name)
{
    return NPT_GetEnvironment("COMPUTERNAME", name);
}