Пример #1
0
/**
 * xfce_get_homedir:
 *
 * Similar to g_get_homedir() in functionality but will never return NULL.
 * While g_get_homedir() may return NULL under certain circumstances, this
 * function is garantied to never ever return NULL, but always return a
 * valid character pointer with the absolute path to the user's home directory.
 *
 * The returned string is owned by libxfce4util and must not be freed by
 * the caller.
 *
 * Return value: the path to the current user's home directory.
 **/
const gchar*
xfce_get_homedir (void)
{
  G_LOCK (_lock);
  if (!xfce_homedir)
    internal_initialize ();
  G_UNLOCK (_lock);

  return xfce_homedir;
}
Пример #2
0
bool AbstractAudioSource::initialize( uint32_t frequency )
{
    std::lock_guard<std::recursive_mutex> lock( m_mutex );
    m_frequency = frequency;
    bool res = internal_initialize( frequency );
    if( res ) {
        m_frequency = frequency;
        m_initialized = true;
    }
    else {
        m_frequency = 0;
        m_initialized = false;
    }
    return res;
}
Пример #3
0
/**
 * xfce_get_userdir:
 *
 * Safe way to retrieve the path to the user's ".xfce4" directory. The path
 * to the current user's ".xfce4" directory is either taken from the
 * environment variable XFCE4HOME if defined, or if unset, is gained by
 * concatenating the path to the user's home directory and the ".xfce4".
 * That says, it will, by default, return the path "$HOME/.xfce4", where
 * $HOME is replaced with the absolute path to the user's home directory.
 *
 * The returned string is managed by libxfce4util and must not be freed by
 * the caller.
 *
 * Return value: the path to the current user's ".xfce4" directory.
 */
const gchar*
xfce_get_userdir (void)
{
  G_LOCK(_lock);
  if (!xfce_userdir)
    {
      internal_initialize();

      /* verify that the directory exists or is created */
      if (!g_file_test (xfce_userdir, G_FILE_TEST_IS_DIR))
        xfce_mkdirhier (xfce_userdir, 0700, NULL);
    }
  G_UNLOCK(_lock);

  return xfce_userdir;
}
Пример #4
0
long eprom24x_core::initialize(EPROM24x_DEVICE eprom_device,
			       uint8_t i2c_address,
			       const char *i2c_dev)
{
  try {
    MUTEX_LOCK(m_init_mutex);

    // Check if already initialized
    if (m_initialized) {
      THROW_RXP(EPROM24x_INTERNAL_ERROR, EPROM24x_ALREADY_INITIALIZED,
		"Already initialized");
    }

    // Check input values
    if (!i2c_dev) {
      THROW_RXP(EPROM24x_INTERNAL_ERROR, EPROM24x_BAD_ARGUMENT,
		"i2c_dev is null pointer");
    }

    // Do the actual initialization
    internal_initialize(eprom_device, i2c_address, i2c_dev);

    // Initialization completed
    m_initialized = true;
    MUTEX_UNLOCK(m_init_mutex);

    return EPROM24x_SUCCESS;
  }
  catch (eprom24x_exception &rxp) {
    MUTEX_UNLOCK(m_init_mutex);
    return set_error(rxp);
  }
  catch (...) {
    MUTEX_UNLOCK(m_init_mutex);
    return set_error(RXP(EPROM24x_INTERNAL_ERROR, EPROM24x_UNEXPECTED_EXCEPTION, NULL));
  }
}