.. _program_listing_file_include_tools.h: Program Listing for File tools.h ================================ |exhale_lsh| :ref:`Return to documentation for file ` (``include/tools.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * Copyright 2021 Matthieu Gautier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ #ifndef KIWIX_TOOLS_H #define KIWIX_TOOLS_H #include #include #include #include #include "common.h" namespace kiwix { struct IpAddress { std::string addr; std::string addr6; }; typedef std::pair LangNameCodePair; typedef std::vector FeedLanguages; typedef std::vector FeedCategories; std::string getCurrentDirectory(); std::string getExecutablePath(bool realPathOnly = false); bool isRelativePath(const std::string& path); std::string appendToDirectory(const std::string& basePath, const std::string& relativePath); std::string removeLastPathElement(const std::string& path); std::string getLastPathElement(const std::string& path); std::string computeAbsolutePath(const std::string& path, const std::string& relativePath); std::string computeRelativePath(const std::string& path, const std::string& absolutePath); void sleep(unsigned int milliseconds); std::vector split(const std::string& str, const std::string& delims, bool dropEmpty=true, bool keepDelim = false); std::string converta2toa3(const std::string& a2code); std::string getFileContent(const std::string& path); bool fileExists(const std::string& path); bool fileReadable(const std::string& path); std::string getMimeTypeForFile(const std::string& filename); std::map getNetworkInterfacesIPv4Or6(); std::map getNetworkInterfaces(); IpAddress getBestPublicIps(); std::string getBestPublicIp(); std::string beautifyFileSize(uint64_t number); FeedLanguages readLanguagesFromFeed(const std::string& content); FeedCategories readCategoriesFromFeed(const std::string& content); std::string getLanguageSelfName(const std::string& lang); std::string getSlugifiedFileName(const std::string& filename); } #endif // KIWIX_TOOLS_H