1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// vim:fileencoding=utf-8:noet
//! Port of `powerline/lib/inotify.py`.
//!
//! Upstream is a 185-line ctypes wrapper around Linux's `inotify(7)`
//! syscalls (`inotify_init1`, `inotify_add_watch`, `inotify_rm_watch`)
//! plus a per-instance polling loop. It exists so the higher-level
//! `lib/watcher/inotify.py` `INotifyFileWatcher` can avoid the
//! `pyinotify` dep.
//!
//! Rust port strategy: when the `inotify` Rust crate gets added as a
//! dependency, the real port will land. Until then we expose:
//! - the `INotifyError` shape so dispatchers can `catch` it
//! - `INotify` and `load_inotify` shims that always return
//! `INotifyError`, causing the watcher dispatcher
//! (`lib/watcher/__init__.py:51-56`) to fall through to the stat
//! backend on every platform.
//!
//! Behavioural parity: macOS upstream raises `INotifyError("INotify
//! not available on OS X")` immediately (py:37); the stat fallback is
//! the default. Our stub matches that behaviour on every platform.
// from __future__ import (unicode_literals, division, absolute_import, print_function) // py:2
// import sys // py:4
// import os // py:5
// import errno // py:6
// import ctypes // py:7
// import struct // py:8
// from ctypes.util import find_library // py:10
// from powerline.lib.encoding import get_preferred_file_name_encoding // py:12
// py:15 __copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
// py:16 __docformat__ = 'restructuredtext en'
/// Port of `class INotifyError(Exception)` from
/// `powerline/lib/inotify.py:19`.
///
/// Raised by `load_inotify()` when inotify is unavailable. Callers
/// (the watcher dispatcher) catch this and fall back to stat-based
/// polling.
;
/// Port of `load_inotify()` from `powerline/lib/inotify.py:25`.
///
/// Initialize the inotify library.
///
/// Rust stub: always returns `Err(INotifyError)` so the watcher
/// dispatcher falls back to stat. Matches upstream's macOS branch
/// (py:37) behaviour on every platform.
/// Port of `class INotify` from `powerline/lib/inotify.py` (the body
/// starts after `load_inotify` returns).
///
/// **Status:** opaque placeholder. The full class needs the `inotify`
/// crate; until then, no instance is ever constructed (`load_inotify`
/// always errors).