File tree 1 file changed +6
-7
lines changed
1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,8 @@ use libc::{
16
16
size_t,
17
17
ssize_t
18
18
} ;
19
- use std:: c_str :: {
19
+ use std:: ffi :: {
20
20
CString ,
21
- ToCStr ,
22
21
} ;
23
22
use std:: mem;
24
23
use std:: io:: {
@@ -27,6 +26,7 @@ use std::io::{
27
26
IoResult
28
27
} ;
29
28
use std:: os:: errno;
29
+ use std:: path:: BytesContainer ;
30
30
31
31
use ffi;
32
32
use ffi:: inotify_event;
@@ -61,9 +61,10 @@ impl INotify {
61
61
62
62
pub fn add_watch ( & self , path : & Path , mask : u32 ) -> IoResult < Watch > {
63
63
let wd = unsafe {
64
+ let path_c_str = CString :: from_slice ( path. container_as_bytes ( ) ) ;
64
65
ffi:: inotify_add_watch (
65
66
self . fd ,
66
- path . to_c_str ( ) . into_inner ( ) ,
67
+ path_c_str . as_ptr ( ) ,
67
68
mask)
68
69
} ;
69
70
@@ -146,11 +147,9 @@ impl INotify {
146
147
let event = slice. as_ptr ( ) as * const inotify_event ;
147
148
148
149
let name = if ( * event) . len > 0 {
149
- let c_str = CString :: new (
150
- event. offset ( 1 ) as * const c_char ,
151
- false ) ;
150
+ let c_str = CString :: from_slice ( slice) ;
152
151
153
- match c_str. as_str ( ) {
152
+ match c_str. container_as_str ( ) {
154
153
Some ( string)
155
154
=> string. to_string ( ) ,
156
155
None =>
You can’t perform that action at this time.
0 commit comments