2018-02-04 03:22:01 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
2018-01-11 06:30:31 +01:00
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
2018-02-04 03:22:01 +01:00
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
2018-01-11 06:30:31 +01: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
|
2018-02-04 03:22:01 +01:00
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
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-10-12 02:43:11 +02:00
|
|
|
///
|
|
|
|
/// IRCd has wrapped operations for the local filesystem to maintain a
|
|
|
|
/// cross-platform implementation of asynchronous file IO in conjunction with
|
|
|
|
/// the ircd::ctx userspace context system. These operations will yield your
|
|
|
|
/// ircd::ctx when necessary to not block the event loop on the main thread
|
|
|
|
/// during IOs.
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd::fs
|
2016-07-25 10:57:54 +02:00
|
|
|
{
|
2018-01-10 01:48:05 +01:00
|
|
|
struct aio;
|
|
|
|
struct init;
|
2018-08-12 20:56:53 +02:00
|
|
|
enum index :int;
|
2018-08-23 12:31:36 +02:00
|
|
|
struct error; // custom exception; still inherits from ircd::error
|
2016-08-14 05:35:06 +02:00
|
|
|
|
2018-08-12 20:56:53 +02:00
|
|
|
constexpr size_t PATH_MAX { 2048 };
|
2016-09-24 03:44:30 +02:00
|
|
|
|
2018-08-12 20:56:53 +02:00
|
|
|
extern aio *aioctx;
|
|
|
|
|
|
|
|
string_view get(index) noexcept;
|
|
|
|
string_view name(index) noexcept;
|
2018-05-25 04:11:05 +02:00
|
|
|
std::string make_path(const vector_view<const string_view> &);
|
2018-08-17 19:20:40 +02:00
|
|
|
std::string make_path(const vector_view<const std::string> &);
|
2016-08-31 10:03:44 +02:00
|
|
|
|
2018-02-27 05:35:09 +01:00
|
|
|
bool exists(const string_view &path);
|
|
|
|
bool is_dir(const string_view &path);
|
|
|
|
bool is_reg(const string_view &path);
|
2017-12-21 01:33:12 +01:00
|
|
|
size_t size(const string_view &path);
|
|
|
|
|
2018-02-27 05:35:09 +01:00
|
|
|
std::vector<std::string> ls(const string_view &path);
|
|
|
|
std::vector<std::string> ls_recursive(const string_view &path);
|
2016-08-31 10:03:44 +02:00
|
|
|
|
2018-02-27 05:37:19 +01:00
|
|
|
bool rename(std::nothrow_t, const string_view &old, const string_view &new_);
|
|
|
|
void rename(const string_view &old, const string_view &new_);
|
|
|
|
bool remove(std::nothrow_t, const string_view &path);
|
|
|
|
bool remove(const string_view &path);
|
|
|
|
|
2018-02-27 05:35:09 +01:00
|
|
|
void chdir(const string_view &path);
|
|
|
|
bool mkdir(const string_view &path);
|
2017-08-23 22:56:52 +02:00
|
|
|
|
2018-08-12 20:56:53 +02:00
|
|
|
std::string cwd();
|
2017-08-28 23:51:22 +02:00
|
|
|
}
|
2017-10-12 02:50:13 +02:00
|
|
|
|
2018-08-13 01:44:55 +02:00
|
|
|
/// Index of default paths. Must be aligned with fs::syspaths (see: fs.cc)
|
2018-08-12 20:56:53 +02:00
|
|
|
enum ircd::fs::index
|
|
|
|
:int
|
|
|
|
{
|
|
|
|
PREFIX,
|
|
|
|
BIN,
|
|
|
|
CONF,
|
|
|
|
DB,
|
|
|
|
LOG,
|
|
|
|
MODULES,
|
|
|
|
|
|
|
|
_NUM_
|
|
|
|
};
|
|
|
|
|
2018-08-23 12:31:36 +02:00
|
|
|
#include "error.h"
|
2018-05-30 10:38:20 +02:00
|
|
|
#include "fd.h"
|
2018-01-11 06:30:31 +01:00
|
|
|
#include "read.h"
|
2018-02-06 08:28:33 +01:00
|
|
|
#include "write.h"
|
2018-08-19 07:58:43 +02:00
|
|
|
#include "fsync.h"
|
2018-03-23 23:37:01 +01:00
|
|
|
#include "stdin.h"
|
2018-01-11 06:30:31 +01:00
|
|
|
|
2017-10-12 02:50:13 +02:00
|
|
|
struct ircd::fs::init
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
~init() noexcept;
|
|
|
|
};
|