2018-02-03 18:22:01 -08:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
2018-01-10 21:30:31 -08:00
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
2018-02-03 18:22:01 -08:00
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
2018-01-10 21:30:31 -08: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-03 18:22:01 -08: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 01:57:54 -07:00
|
|
|
|
|
|
|
#pragma once
|
2017-03-30 15:46:01 -07:00
|
|
|
#define HAVE_IRCD_FS_H
|
2016-07-25 01:57:54 -07:00
|
|
|
|
2019-01-25 10:35:39 -08:00
|
|
|
// Forward declarations for boost because it is not included here.
|
|
|
|
namespace boost::filesystem {}
|
|
|
|
|
2018-12-29 15:27:58 -08:00
|
|
|
/// Local filesystem interface.
|
2017-10-11 17:43:11 -07: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.
|
2018-12-29 15:27:58 -08:00
|
|
|
///
|
|
|
|
/// Paths are stored in the platform-specific format using plain old character
|
|
|
|
/// strings, which means you should never directly manipulate path strings to
|
|
|
|
/// maintain x-platformness; instead use the (or add more) tools provided by
|
|
|
|
/// this interface (see: path.h).
|
|
|
|
///
|
2017-08-28 14:51:22 -07:00
|
|
|
namespace ircd::fs
|
2016-07-25 01:57:54 -07:00
|
|
|
{
|
2018-01-09 16:48:05 -08:00
|
|
|
struct init;
|
2019-01-25 10:35:39 -08:00
|
|
|
|
|
|
|
// Forward interface to boost::filesystem. We do not include boost
|
|
|
|
// from here; it is used internally only. Some exposed interfaces
|
|
|
|
// may make forward-declared references to boost symbols.
|
|
|
|
namespace filesystem = boost::filesystem;
|
2019-03-15 18:40:16 -07:00
|
|
|
|
2019-04-07 16:28:21 -07:00
|
|
|
// Log facility for ircd::fs
|
|
|
|
extern log::log log;
|
2018-12-29 15:27:58 -08:00
|
|
|
}
|
2016-08-13 20:35:06 -07:00
|
|
|
|
2018-12-29 15:27:58 -08:00
|
|
|
#include "error.h"
|
|
|
|
#include "path.h"
|
|
|
|
#include "iov.h"
|
2019-04-06 12:13:16 -07:00
|
|
|
#include "op.h"
|
2018-12-29 20:02:22 -08:00
|
|
|
#include "opts.h"
|
2019-01-01 18:35:09 -08:00
|
|
|
#include "dev.h"
|
2018-12-29 15:27:58 -08:00
|
|
|
#include "fd.h"
|
2020-08-24 08:49:41 -07:00
|
|
|
#include "map.h"
|
2019-04-07 17:29:23 -07:00
|
|
|
#include "wait.h"
|
2018-12-29 15:27:58 -08:00
|
|
|
#include "read.h"
|
|
|
|
#include "write.h"
|
|
|
|
#include "sync.h"
|
2019-04-10 16:49:47 -07:00
|
|
|
#include "aio.h"
|
2019-08-10 22:06:08 -07:00
|
|
|
#include "iou.h"
|
2020-05-08 17:26:46 -07:00
|
|
|
#include "select.h"
|
2018-12-29 15:27:58 -08:00
|
|
|
#include "stdin.h"
|
|
|
|
#include "support.h"
|
2016-08-31 01:03:44 -07:00
|
|
|
|
2018-12-29 15:27:58 -08:00
|
|
|
namespace ircd::fs
|
|
|
|
{
|
|
|
|
// Observers
|
2018-02-26 20:35:09 -08:00
|
|
|
bool exists(const string_view &path);
|
|
|
|
bool is_dir(const string_view &path);
|
|
|
|
bool is_reg(const string_view &path);
|
2020-10-19 22:22:33 -07:00
|
|
|
bool is_exec(const string_view &path);
|
2017-12-20 17:33:12 -07:00
|
|
|
size_t size(const string_view &path);
|
2018-02-26 20:35:09 -08:00
|
|
|
std::vector<std::string> ls(const string_view &path);
|
2018-12-29 15:27:58 -08:00
|
|
|
std::vector<std::string> ls_r(const string_view &path);
|
2016-08-31 01:03:44 -07:00
|
|
|
|
2018-12-29 15:27:58 -08:00
|
|
|
// Modifiers
|
2018-02-26 20:37:19 -08:00
|
|
|
bool rename(std::nothrow_t, const string_view &old, const string_view &new_);
|
2018-12-29 15:27:58 -08:00
|
|
|
bool rename(const string_view &old, const string_view &new_);
|
2018-02-26 20:37:19 -08:00
|
|
|
bool remove(std::nothrow_t, const string_view &path);
|
|
|
|
bool remove(const string_view &path);
|
2018-02-26 20:35:09 -08:00
|
|
|
bool mkdir(const string_view &path);
|
2017-08-28 14:51:22 -07:00
|
|
|
}
|
2017-10-11 17:50:13 -07:00
|
|
|
|
2018-12-29 15:27:58 -08:00
|
|
|
/// Filesystem interface init / fini held by ircd::main().
|
2017-10-11 17:50:13 -07:00
|
|
|
struct ircd::fs::init
|
|
|
|
{
|
2019-08-10 22:06:08 -07:00
|
|
|
iou::init _iou_;
|
2018-11-27 18:09:12 -08:00
|
|
|
aio::init _aio_;
|
|
|
|
|
2017-10-11 17:50:13 -07:00
|
|
|
init();
|
|
|
|
~init() noexcept;
|
|
|
|
};
|