• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
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  */
15 #ifndef INTERFACES_KITS_JS_SRC_MOD_FS_CLASS_WATCHER_FS_WATCH_ENTITY_H
16 #define INTERFACES_KITS_JS_SRC_MOD_FS_CLASS_WATCHER_FS_WATCH_ENTITY_H
17 
18 #include <cstdint>
19 #include <functional>
20 #include <string>
21 
22 #include "i_watcher_callback.h"
23 
24 namespace OHOS::FileManagement::ModuleFileIO {
25 
26 struct WatchEvent {
27     std::string fileName = "";
28     uint32_t event = 0;
29     uint32_t cookie = 0;
30 };
31 
32 struct WatcherInfo {
33     std::string fileName = "";
34     uint32_t events = 0;
35     int32_t wd = -1;
36     std::shared_ptr<IWatcherCallback> callback;
37 
WatcherInfoWatcherInfo38     explicit WatcherInfo(std::shared_ptr<IWatcherCallback> callback) : callback(std::move(callback)) {}
39 
TriggerCallbackWatcherInfo40     void TriggerCallback(const std::string &eventFileName, uint32_t event, uint32_t cookie) const
41     {
42         callback->InvokeCallback(eventFileName, event, cookie);
43     }
44 };
45 
46 struct FsWatchEntity {
47     std::shared_ptr<WatcherInfo> data_;
48 };
49 
50 } // namespace OHOS::FileManagement::ModuleFileIO
51 #endif // INTERFACES_KITS_JS_SRC_MOD_FS_CLASS_WATCHER_FS_WATCH_ENTITY_H
52