Sese Framework
3.0.0
A cross-platform framework
Loading...
Searching...
No Matches
FileNotifier.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
20
21
#pragma once
22
23
#include "
sese/util/ErrorCode.h
"
24
#include "
sese/util/Result.h
"
25
26
#include <functional>
27
#include <memory>
28
29
namespace
sese::system
{
30
34
class
FileNotifier
final {
35
public
:
36
using
Ptr
= std::unique_ptr<FileNotifier>;
37
using
OnCreateCallback
= std::function<void(std::string_view)>;
38
using
OnMoveCallback
= std::function<void(std::string_view, std::string_view)>;
39
using
OnModifyCallback
= std::function<void(std::string_view)>;
40
using
OnDeleteCallback
= std::function<void(std::string_view)>;
41
45
static
Ptr
create
(
const
std::string &path)
noexcept
;
46
47
static
Result<Ptr, ErrorCode>
createEx
(
const
std::string &path)
noexcept
;
48
49
~FileNotifier
() noexcept;
50
52
void
start
() const noexcept;
53
55
void
shutdown
() const noexcept;
56
59
void
setOnCreate
(
OnCreateCallback
&&callback) const noexcept;
60
63
void
setOnMove
(
OnMoveCallback
&&callback) const noexcept;
64
67
void
setOnModify
(
OnModifyCallback
&&callback) const noexcept;
68
71
void
setOnDelete
(
OnDeleteCallback
&&callback) const noexcept;
72
73
private:
74
FileNotifier
() = default;
75
76
class
Impl
;
77
std::unique_ptr<
Impl
>
impl
;
78
};
79
}
// namespace sese::system
sese
system
FileNotifier.h
Generated on Sun Feb 2 2025 15:46:44 for Sese Framework by
1.11.0