| 1 | use std::io; | 
| 2 | use std::path::Path; | 
|---|
| 3 |  | 
|---|
| 4 | #[ cfg(unix)] | 
|---|
| 5 | pub fn device_num<P: AsRef<Path>>(path: P) -> io::Result<u64> { | 
|---|
| 6 | use std::os::unix::fs::MetadataExt; | 
|---|
| 7 |  | 
|---|
| 8 | path.as_ref().metadata().map(|md: Metadata| md.dev()) | 
|---|
| 9 | } | 
|---|
| 10 |  | 
|---|
| 11 | #[ cfg(windows)] | 
|---|
| 12 | pub fn device_num<P: AsRef<Path>>(path: P) -> io::Result<u64> { | 
|---|
| 13 | use winapi_util::{file, Handle}; | 
|---|
| 14 |  | 
|---|
| 15 | let h = Handle::from_path_any(path)?; | 
|---|
| 16 | file::information(h).map(|info| info.volume_serial_number()) | 
|---|
| 17 | } | 
|---|
| 18 |  | 
|---|
| 19 | #[ cfg(not(any(unix, windows)))] | 
|---|
| 20 | pub fn device_num<P: AsRef<Path>>(_: P) -> io::Result<u64> { | 
|---|
| 21 | Err(io::Error::new( | 
|---|
| 22 | io::ErrorKind::Other, | 
|---|
| 23 | "walkdir: same_file_system option not supported on this platform", | 
|---|
| 24 | )) | 
|---|
| 25 | } | 
|---|
| 26 |  | 
|---|