Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8Bit

Are there any K (or Q) wrappers for getenv, setenv/putenv?
([GS]etEnvironmentVariable on Windows). I can't see any but I'm likely
looking in the wrong place ;-)

For info, I attach the implementation I've been using in QDVI

Thoughts? Perhaps it should be turned into a class?


Content-Type: text/x-c++src; name="environment.cpp"
Content-Transfer-Encoding: 8Bit
Content-Disposition: attachment; filename="environment.cpp"

// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-
* \file environment.cpp
* Distributed under the GNU GPL version 2 or (at your option)
* any later version. See accompanying file COPYING or copy at
* http://www.gnu.org/copyleft/gpl.html
* \author Angus Leeming
* \author João Luis M. Assirati
* \author Lars Gullik Bjønnes


#include "environment.h"
#include "os.h"



namespace kvs {

QString const getEnv(const QString& envname)
const char* const ch = ::getenv(envname.toLocal8Bit());
return !ch ? QString() : ch;

bool setEnv(const QString& name, QString const& value)
#if defined (HAVE_SETENV)
const int retval = ::setenv(name.toLocal8Bit(), value.local8Bit(), true);

#elif defined (HAVE_PUTENV)
static QMap varmap;

const QByteArray envstr = QString(name + '=' + value).toLocal8Bit();
const char* const envcstr = envstr;
const int retval = :utenv(const_cast(envcstr));
varmap[name] = envstr;

#error No environment-setting function has been defined.
return retval == 0;

QStringList const getEnvPath(const QString& name)
#if defined _WIN32
const char path_separator = ';';
const char path_separator = ':';

return getEnv(name).split(path_separator);

} // namespace kvs

Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<