2016-07-25 10:57:54 +02:00
|
|
|
/*
|
2016-09-28 02:24:31 +02:00
|
|
|
* Copyright (C) 2016 Charybdis Development Team
|
|
|
|
* Copyright (C) 2016 Jason Volk <jason@zemos.net>
|
2016-07-25 10:57:54 +02:00
|
|
|
*
|
2016-09-28 02:24:31 +02:00
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice is present in all copies.
|
2016-07-25 10:57:54 +02:00
|
|
|
*
|
2016-09-28 02:24:31 +02:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
|
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
2016-07-25 10:57:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2017-03-31 00:46:01 +02:00
|
|
|
#define HAVE_IRCD_FS_H
|
2016-07-25 10:57:54 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Directory paths and filenames for UNIX systems.
|
|
|
|
* IRCD_PREFIX is set using ./configure --prefix, see INSTALL.
|
|
|
|
* Do not change these without corresponding changes in the build system.
|
|
|
|
*
|
|
|
|
* IRCD_PREFIX = prefix for all directories,
|
|
|
|
* DPATH = root directory of installation,
|
|
|
|
* BINPATH = directory for binary files,
|
|
|
|
* ETCPATH = directory for configuration files,
|
|
|
|
* LOGPATH = directory for logfiles,
|
|
|
|
* MODPATH = directory for modules,
|
|
|
|
* AUTOMODPATH = directory for autoloaded modules
|
|
|
|
*/
|
|
|
|
|
2017-09-12 18:37:44 +02:00
|
|
|
/// Tools for working with the local filesystem.
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd::fs
|
2016-07-25 10:57:54 +02:00
|
|
|
{
|
2017-08-28 23:51:22 +02:00
|
|
|
IRCD_EXCEPTION(ircd::error, error)
|
|
|
|
IRCD_EXCEPTION(error, filesystem_error)
|
2016-08-14 05:35:06 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
constexpr auto DPATH = IRCD_PREFIX;
|
|
|
|
constexpr auto BINPATH = IRCD_PREFIX "/bin";
|
|
|
|
constexpr auto MODPATH = RB_MODULE_DIR;
|
|
|
|
constexpr auto ETCPATH = RB_ETC_DIR;
|
|
|
|
constexpr auto LOGPATH = RB_LOG_DIR;
|
|
|
|
constexpr auto UHPATH = RB_HELP_DIR "/users";
|
|
|
|
constexpr auto HPATH = RB_HELP_DIR "/opers";
|
|
|
|
constexpr auto SPATH = RB_BIN_DIR "/" BRANDING_NAME; // ircd executable
|
|
|
|
constexpr auto CPATH = RB_ETC_DIR "/ircd.conf"; // ircd.conf file
|
|
|
|
constexpr auto MPATH = RB_ETC_DIR "/ircd.motd"; // MOTD file
|
|
|
|
constexpr auto LPATH = RB_LOG_DIR "/ircd.log"; // ircd logfile
|
|
|
|
constexpr auto OPATH = RB_ETC_DIR "/opers.motd"; // oper MOTD file
|
|
|
|
constexpr auto DBPATH = PKGLOCALSTATEDIR "/db"; // database prefix
|
|
|
|
constexpr auto BDBPATH = PKGLOCALSTATEDIR "/ban.db"; // bandb file
|
2016-07-25 10:57:54 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
// Below are the elements for default paths.
|
|
|
|
enum index
|
|
|
|
{
|
|
|
|
PREFIX,
|
|
|
|
BIN,
|
|
|
|
ETC,
|
|
|
|
LOG,
|
|
|
|
LIBEXEC,
|
|
|
|
MODULES,
|
|
|
|
USERHELP,
|
|
|
|
OPERHELP,
|
|
|
|
IRCD_CONF,
|
|
|
|
IRCD_EXEC,
|
|
|
|
IRCD_MOTD,
|
|
|
|
IRCD_LOG,
|
|
|
|
IRCD_OMOTD,
|
|
|
|
BANDB,
|
|
|
|
DB,
|
|
|
|
_NUM_
|
|
|
|
};
|
2016-08-31 08:25:25 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
const char *get(index) noexcept;
|
|
|
|
const char *name(index) noexcept;
|
2016-09-24 03:44:30 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
std::string make_path(const std::initializer_list<std::string> &);
|
2016-08-31 10:03:44 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
bool exists(const std::string &path);
|
|
|
|
bool is_dir(const std::string &path);
|
|
|
|
bool is_reg(const std::string &path);
|
2016-08-31 10:03:44 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
std::vector<std::string> ls(const std::string &path);
|
|
|
|
std::vector<std::string> ls_recursive(const std::string &path);
|
2016-08-31 10:03:44 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
std::string cwd();
|
|
|
|
void chdir(const std::string &path);
|
|
|
|
bool mkdir(const std::string &path);
|
2017-08-23 22:56:52 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
std::string read(const std::string &name);
|
|
|
|
}
|