Skip to content

Commit a605b28

Browse files
committed
Fix compilation due to c_str redesign
The `c_str` module has been redesigned: rust-lang/rust#20507 This change fixes the code to align with the redesign. Fixes #9
1 parent 4a18a90 commit a605b28

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/wrapper.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ use libc::{
1616
size_t,
1717
ssize_t
1818
};
19-
use std::c_str::{
19+
use std::ffi::{
2020
CString,
21-
ToCStr,
2221
};
2322
use std::mem;
2423
use std::io::{
@@ -27,6 +26,7 @@ use std::io::{
2726
IoResult
2827
};
2928
use std::os::errno;
29+
use std::path::BytesContainer;
3030

3131
use ffi;
3232
use ffi::inotify_event;
@@ -61,9 +61,10 @@ impl INotify {
6161

6262
pub fn add_watch(&self, path: &Path, mask: u32) -> IoResult<Watch> {
6363
let wd = unsafe {
64+
let path_c_str = CString::from_slice(path.container_as_bytes());
6465
ffi::inotify_add_watch(
6566
self.fd,
66-
path.to_c_str().into_inner(),
67+
path_c_str.as_ptr(),
6768
mask)
6869
};
6970

@@ -146,11 +147,9 @@ impl INotify {
146147
let event = slice.as_ptr() as *const inotify_event;
147148

148149
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);
152151

153-
match c_str.as_str() {
152+
match c_str.container_as_str() {
154153
Some(string)
155154
=> string.to_string(),
156155
None =>

0 commit comments

Comments
 (0)