MiKTeX 26.5-next
A scalable TeX distribution
Loading...
Searching...
No Matches
FileSystemWatcher.h
1/* miktex/Core/FileSystemWatcher.h:
2
3 Copyright (C) 2021-2022 Christian Schenk
4
5 This file is part of the MiKTeX Core Library.
6
7 The MiKTeX Core Library is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2, or
10 (at your option) any later version.
11
12 The MiKTeX Core Library is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with the MiKTeX Core Library; if not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22#pragma once
23
24#include <miktex/Core/config.h>
25
26#include <memory>
27#include <ostream>
28#include <string>
29#include <vector>
30
31#include <miktex/Util/PathName>
32
33MIKTEX_CORE_BEGIN_NAMESPACE;
34
35enum class FileSystemChangeAction
36{
37 Added,
38 Modified,
39 Removed,
40};
41
42inline std::string FileSystemChangeActionToString(FileSystemChangeAction action)
43{
44 switch (action)
45 {
46 case FileSystemChangeAction::Added:
47 return "added";
48 case FileSystemChangeAction::Modified:
49 return "modified";
50 case FileSystemChangeAction::Removed:
51 return "removed";
52 default:
53 return "?";
54 }
55}
56
57inline std::ostream& operator<<(std::ostream& os, const FileSystemChangeAction& action)
58{
59 return os << FileSystemChangeActionToString(action);
60}
61
63{
64 FileSystemChangeAction action;
66};
67
68class MIKTEXNOVTABLE FileSystemWatcherCallback
69{
70public:
71 virtual void MIKTEXTHISCALL OnChange(const FileSystemChangeEvent& ev) = 0;
72};
73
74class MIKTEXNOVTABLE FileSystemWatcher
75{
76public:
77 virtual MIKTEXTHISCALL ~FileSystemWatcher() noexcept = 0;
78
79public:
80 virtual void MIKTEXTHISCALL AddDirectories(const std::vector<MiKTeX::Util::PathName>& directories) = 0;
81
82public:
83 virtual bool MIKTEXTHISCALL Start() = 0;
84
85public:
86 virtual bool MIKTEXTHISCALL Stop() = 0;
87
88public:
89 virtual void MIKTEXTHISCALL Subscribe(FileSystemWatcherCallback* callback) = 0;
90
91public:
92 virtual void MIKTEXTHISCALL Unsubscribe(FileSystemWatcherCallback* callback) = 0;
93
94public:
95 static MIKTEXCORECEEAPI(std::unique_ptr<FileSystemWatcher>) Create();
96};
97
98MIKTEX_CORE_END_NAMESPACE;
Definition FileSystemWatcher.h:69
Definition FileSystemWatcher.h:75
Instances of this class can be used to store path names.
Definition PathName.h:64
Definition FileSystemWatcher.h:63