/* Copyright (C) 2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include #include #include #include #include namespace Glib { Glib::ustring get_application_name() { return convert_const_gchar_ptr_to_ustring(g_get_application_name()); } void set_application_name(UStringView application_name) { g_set_application_name(application_name.c_str()); } std::string get_prgname() { return convert_const_gchar_ptr_to_stdstring(g_get_prgname()); } void set_prgname(StdStringView prgname) { g_set_prgname(prgname.c_str()); } std::string getenv(StdStringView variable, bool& found) { const char* const value = g_getenv(variable.c_str()); found = (value != nullptr); return convert_const_gchar_ptr_to_stdstring(value); } std::string getenv(StdStringView variable) { return convert_const_gchar_ptr_to_stdstring(g_getenv(variable.c_str())); } bool setenv(StdStringView variable, StdStringView value, bool overwrite) { return g_setenv(variable.c_str(), value.c_str(), overwrite); } void unsetenv(StdStringView variable) { g_unsetenv(variable.c_str()); } std::vector listenv() { return Glib::ArrayHandler::array_to_vector(g_listenv(), Glib::OWNERSHIP_DEEP); } std::string get_user_name() { return convert_const_gchar_ptr_to_stdstring(g_get_user_name()); } std::string get_real_name() { return convert_const_gchar_ptr_to_stdstring(g_get_real_name()); } Glib::ustring get_host_name() { return convert_const_gchar_ptr_to_ustring(g_get_host_name()); } std::string get_home_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_home_dir()); } std::string get_tmp_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_tmp_dir()); } std::string get_current_dir() { return convert_return_gchar_ptr_to_stdstring(g_get_current_dir()); } std::string get_user_special_dir(UserDirectory directory) { return convert_const_gchar_ptr_to_stdstring(g_get_user_special_dir((GUserDirectory)directory)); } std::string get_user_data_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_user_data_dir()); } std::string get_user_config_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_user_config_dir()); } std::vector get_system_data_dirs() { return Glib::ArrayHandler::array_to_vector(g_get_system_data_dirs(), Glib::OWNERSHIP_NONE); } std::vector get_system_config_dirs() { return Glib::ArrayHandler::array_to_vector(g_get_system_config_dirs(), Glib::OWNERSHIP_NONE); } std::string get_user_cache_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_user_cache_dir()); } std::string get_user_runtime_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_user_runtime_dir()); } bool path_is_absolute(StdStringView filename) { return g_path_is_absolute(filename.c_str()) != 0; } std::string path_skip_root(StdStringView filename) { // g_path_skip_root() returns a pointer _into_ the argument string, // or NULL if there was no root component. return convert_const_gchar_ptr_to_stdstring(g_path_skip_root(filename.c_str())); } std::string path_get_basename(StdStringView filename) { return convert_return_gchar_ptr_to_stdstring(g_path_get_basename(filename.c_str())); } std::string path_get_dirname(StdStringView filename) { return convert_return_gchar_ptr_to_stdstring(g_path_get_dirname(filename.c_str())); } std::string canonicalize_filename(StdStringView filename, StdStringView relative_to) { return convert_return_gchar_ptr_to_stdstring(g_canonicalize_filename( filename.c_str(), relative_to.c_str())); } std::string build_filename(const std::vector& elements) { return convert_return_gchar_ptr_to_stdstring( g_build_filenamev(const_cast(Glib::ArrayHandler::vector_to_array(elements).data()))); } std::string build_path(const std::string& separator, const std::vector& elements) { return convert_return_gchar_ptr_to_stdstring( g_build_pathv(separator.c_str(), const_cast(Glib::ArrayHandler::vector_to_array(elements).data()))); } std::string find_program_in_path(StdStringView program) { return convert_return_gchar_ptr_to_stdstring(g_find_program_in_path(program.c_str())); } Glib::ustring format_size(guint64 size, FormatSizeFlags flags) { return convert_return_gchar_ptr_to_ustring(g_format_size_full(size, (GFormatSizeFlags)flags)); } } // namespace Glib