Skip to content

Commit c72afec

Browse files
committed
Merge pull request #3 from tsurai/master
Fixed move keyword collision and made cloneable
2 parents 7619840 + 6206288 commit c72afec

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

src/ffi.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub use libc::read;
5353
/// [execve(2)]: http://man7.org/linux/man-pages/man2/execve.2.html
5454
/// [open(2)]: http://man7.org/linux/man-pages/man2/open.2.html
5555
/// [fcntl(2)]: http://man7.org/linux/man-pages/man2/fcntl.2.html
56-
pub static IN_CLOEXEC : c_int = 0o2000000;
56+
pub const IN_CLOEXEC : c_int = 0o2000000;
5757

5858
/// Flag: Set the O_NONBLOCK file status flag
5959
///
@@ -81,15 +81,15 @@ pub static IN_CLOEXEC : c_int = 0o2000000;
8181
/// [read(2)]: http://man7.org/linux/man-pages/man2/read.2.html
8282
/// [write(2)]: http://man7.org/linux/man-pages/man2/write.2.html
8383
/// [fcntl(2)]: http://man7.org/linux/man-pages/man2/fcntl.2.html
84-
pub static IN_NONBLOCK: c_int = 0o4000;
84+
pub const IN_NONBLOCK: c_int = 0o4000;
8585

8686
/// Event: File was accessed.
8787
///
8888
/// When monitoring a directory, the event may occur both for the
8989
/// directory itself and the files within.
90-
pub static IN_ACCESS : uint32_t = 0x00000001;
90+
pub const IN_ACCESS : uint32_t = 0x00000001;
9191

92-
pub static IN_MODIFY : uint32_t = 0x00000002;
92+
pub const IN_MODIFY : uint32_t = 0x00000002;
9393

9494
/// Event: Metadata has changed.
9595
///
@@ -109,53 +109,53 @@ pub static IN_MODIFY : uint32_t = 0x00000002;
109109
/// [link(2)]: http://man7.org/linux/man-pages/man2/link.2.html
110110
/// [unlink(2)]: http://man7.org/linux/man-pages/man2/link.2.html
111111
/// [chown(2)]: http://man7.org/linux/man-pages/man2/link.2.html
112-
pub static IN_ATTRIB : uint32_t = 0x00000004;
112+
pub const IN_ATTRIB : uint32_t = 0x00000004;
113113

114114
/// Event: File opened for writing was closed.
115115
///
116116
/// When monitoring a directory, the event may occur both for the
117117
/// directory itself and the files within.
118-
pub static IN_CLOSE_WRITE : uint32_t = 0x00000008;
118+
pub const IN_CLOSE_WRITE : uint32_t = 0x00000008;
119119

120120
/// Event: File not opened for writing was closed.
121121
///
122122
/// When monitoring a directory, the event may occur both for the
123123
/// directory itself and the files within.
124-
pub static IN_CLOSE_NOWRITE: uint32_t = 0x00000010;
124+
pub const IN_CLOSE_NOWRITE: uint32_t = 0x00000010;
125125

126126
/// Event: File was opened.
127127
///
128128
/// When monitoring a directory, the event may occur both for the
129129
/// directory itself and the files within.
130-
pub static IN_OPEN : uint32_t = 0x00000020;
130+
pub const IN_OPEN : uint32_t = 0x00000020;
131131

132132
/// Event: File or directory was moved away.
133133
///
134134
/// When monitoring a directory, the event may occur *only* for
135135
/// the files within, not the directory itself.
136-
pub static IN_MOVED_FROM : uint32_t = 0x00000040;
136+
pub const IN_MOVED_FROM : uint32_t = 0x00000040;
137137

138138
/// Event: File or directory was moved in.
139139
///
140140
/// When monitoring a directory, the event may occur *only* for
141141
/// the files within, not the directory itself.
142-
pub static IN_MOVED_TO : uint32_t = 0x00000080;
142+
pub const IN_MOVED_TO : uint32_t = 0x00000080;
143143

144144
/// Event: File or directory was created.
145145
///
146146
/// This may also include hard links, symlinks, and UNIX sockets.
147147
///
148148
/// When monitoring a directory, the event may occur *only* for
149149
/// the files within, not the directory itself.
150-
pub static IN_CREATE : uint32_t = 0x00000100;
150+
pub const IN_CREATE : uint32_t = 0x00000100;
151151

152152
/// Event: File or directory was deleted.
153153
///
154154
/// This may also include hard links, symlinks, and UNIX sockets.
155155
///
156156
/// When monitoring a directory, the event may occur *only* for
157157
/// the files within, not the directory itself.
158-
pub static IN_DELETE : uint32_t = 0x00000200;
158+
pub const IN_DELETE : uint32_t = 0x00000200;
159159

160160
/// Event: Watched file or directory was deleted.
161161
///
@@ -166,34 +166,34 @@ pub static IN_DELETE : uint32_t = 0x00000200;
166166
/// An IN_IGNORED event will subsequently be generated.
167167
///
168168
/// [mv(1)]: http://man7.org/linux/man-pages/man1/mv.1.html
169-
pub static IN_DELETE_SELF : uint32_t = 0x00000400;
169+
pub const IN_DELETE_SELF : uint32_t = 0x00000400;
170170

171171
/// Event: Watched file or directory was moved.
172-
pub static IN_MOVE_SELF : uint32_t = 0x00000800;
172+
pub const IN_MOVE_SELF : uint32_t = 0x00000800;
173173

174174
/// Event: File or directory was moved away or in.
175175
///
176176
/// When monitoring a directory, the event may occur *only* for
177177
/// the files within, not the directory itself.
178-
pub static IN_MOVE : uint32_t = (IN_MOVED_FROM | IN_MOVED_TO);
178+
pub const IN_MOVE : uint32_t = (IN_MOVED_FROM | IN_MOVED_TO);
179179

180180
/// Event: File opened was closed.
181181
///
182182
/// When monitoring a directory, the event may occur both for the
183183
/// directory itself and the files within.
184-
pub static IN_CLOSE: uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
184+
pub const IN_CLOSE: uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);
185185

186186
/// Event: Any event occured.
187-
pub static IN_ALL_EVENTS: uint32_t = (
187+
pub const IN_ALL_EVENTS: uint32_t = (
188188
IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_CLOSE_NOWRITE
189189
| IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_CREATE | IN_DELETE
190190
| IN_DELETE_SELF | IN_MOVE_SELF);
191191

192192
/// Option: Don't watch children (if self is a directory).
193-
pub static IN_ONLYDIR : uint32_t = 0x01000000;
193+
pub const IN_ONLYDIR : uint32_t = 0x01000000;
194194

195195
/// Option: Don't dereference (if self is a symlink).
196-
pub static IN_DONT_FOLLOW: uint32_t = 0x02000000;
196+
pub const IN_DONT_FOLLOW: uint32_t = 0x02000000;
197197

198198
/// Option: Don't watch unlinked children.
199199
///
@@ -208,28 +208,28 @@ pub static IN_DONT_FOLLOW: uint32_t = 0x02000000;
208208
/// > IN_EXCL_UNLINK changes this behavior, so that events are
209209
/// > not generated for children after they have been unlinked
210210
/// > from the watched directory.
211-
pub static IN_EXCL_UNLINK: uint32_t = 0x04000000;
211+
pub const IN_EXCL_UNLINK: uint32_t = 0x04000000;
212212

213213
/// Option: Add events to an existing watch instead of replacing it.
214214
///
215215
/// > If a watch instance already exists for the filesystem
216216
/// > object corresponding to self, add (|) the events to the
217217
/// > watch mask instead of replacing it.
218-
pub static IN_MASK_ADD : uint32_t = 0x20000000;
218+
pub const IN_MASK_ADD : uint32_t = 0x20000000;
219219

220220
/// Option: Listen for one event, then remove the watch.
221-
pub static IN_ONESHOT : uint32_t = 0x80000000;
221+
pub const IN_ONESHOT : uint32_t = 0x80000000;
222222

223223
/// Info: Subject of this event is a directory.
224-
pub static IN_ISDIR : uint32_t = 0x40000000;
224+
pub const IN_ISDIR : uint32_t = 0x40000000;
225225

226226
/// Info: Filesystem containing self was unmounted.
227227
///
228228
/// An IN_IGNORED event will subsequently be generated.
229-
pub static IN_UNMOUNT : uint32_t = 0x00002000;
229+
pub const IN_UNMOUNT : uint32_t = 0x00002000;
230230

231231
/// Info: Event queue overflowed.
232-
pub static IN_Q_OVERFLOW: uint32_t = 0x00004000;
232+
pub const IN_Q_OVERFLOW: uint32_t = 0x00004000;
233233

234234
/// Info: Watch was removed.
235235
///
@@ -240,7 +240,7 @@ pub static IN_Q_OVERFLOW: uint32_t = 0x00004000;
240240
/// See the BUGS section of [inotify(7)] for more details.
241241
///
242242
/// [inotify(7)]: http://man7.org/linux/man-pages/man7/inotify.7.html
243-
pub static IN_IGNORED : uint32_t = 0x00008000;
243+
pub const IN_IGNORED : uint32_t = 0x00008000;
244244

245245

246246
/// Describes an event.

src/wrapper.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use ffi::inotify_event;
2222

2323
pub type Watch = c_int;
2424

25-
25+
#[deriving(Clone)]
2626
pub struct INotify {
2727
pub fd: c_int,
2828
events: Vec<Event>,
@@ -139,7 +139,7 @@ impl INotify {
139139
}
140140
}
141141

142-
142+
#[deriving(Clone)]
143143
pub struct Event {
144144
pub wd : i32,
145145
pub mask : u32,
@@ -157,75 +157,75 @@ impl Event {
157157
}
158158
}
159159

160-
pub fn access(&self) -> bool {
160+
pub fn is_access(&self) -> bool {
161161
return self.mask & ffi::IN_ACCESS > 0;
162162
}
163163

164-
pub fn modify(&self) -> bool {
164+
pub fn is_modify(&self) -> bool {
165165
return self.mask & ffi::IN_MODIFY > 0;
166166
}
167167

168-
pub fn attrib(&self) -> bool {
168+
pub fn is_attrib(&self) -> bool {
169169
return self.mask & ffi::IN_ATTRIB > 0;
170170
}
171171

172-
pub fn close_write(&self) -> bool {
172+
pub fn is_close_write(&self) -> bool {
173173
return self.mask & ffi::IN_CLOSE_WRITE > 0;
174174
}
175175

176-
pub fn close_nowrite(&self) -> bool {
176+
pub fn is_close_nowrite(&self) -> bool {
177177
return self.mask & ffi::IN_CLOSE_NOWRITE > 0;
178178
}
179179

180-
pub fn open(&self) -> bool {
180+
pub fn is_open(&self) -> bool {
181181
return self.mask & ffi::IN_OPEN > 0;
182182
}
183183

184-
pub fn moved_from(&self) -> bool {
184+
pub fn is_moved_from(&self) -> bool {
185185
return self.mask & ffi::IN_MOVED_FROM > 0;
186186
}
187187

188-
pub fn moved_to(&self) -> bool {
188+
pub fn is_moved_to(&self) -> bool {
189189
return self.mask & ffi::IN_MOVED_TO > 0;
190190
}
191191

192-
pub fn create(&self) -> bool {
192+
pub fn is_create(&self) -> bool {
193193
return self.mask & ffi::IN_CREATE > 0;
194194
}
195195

196-
pub fn delete(&self) -> bool {
196+
pub fn is_delete(&self) -> bool {
197197
return self.mask & ffi::IN_DELETE > 0;
198198
}
199199

200-
pub fn delete_self(&self) -> bool {
200+
pub fn is_delete_self(&self) -> bool {
201201
return self.mask & ffi::IN_DELETE_SELF > 0;
202202
}
203203

204-
pub fn move_self(&self) -> bool {
204+
pub fn is_move_self(&self) -> bool {
205205
return self.mask & ffi::IN_MOVE_SELF > 0;
206206
}
207207

208-
pub fn move(&self) -> bool {
208+
pub fn is_move(&self) -> bool {
209209
return self.mask & ffi::IN_MOVE > 0;
210210
}
211211

212-
pub fn close(&self) -> bool {
212+
pub fn is_close(&self) -> bool {
213213
return self.mask & ffi::IN_CLOSE > 0;
214214
}
215215

216216
pub fn is_dir(&self) -> bool {
217217
return self.mask & ffi::IN_ISDIR > 0;
218218
}
219219

220-
pub fn unmount(&self) -> bool {
220+
pub fn is_unmount(&self) -> bool {
221221
return self.mask & ffi::IN_UNMOUNT > 0;
222222
}
223223

224-
pub fn queue_overflow(&self) -> bool {
224+
pub fn is_queue_overflow(&self) -> bool {
225225
return self.mask & ffi::IN_Q_OVERFLOW > 0;
226226
}
227227

228-
pub fn ignored(&self) -> bool {
228+
pub fn is_ignored(&self) -> bool {
229229
return self.mask & ffi::IN_IGNORED > 0;
230230
}
231231
}

0 commit comments

Comments
 (0)