From 69b7675940a2a91d7f736b77b248d3d70a99ec2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Wed, 20 Jun 2018 17:28:46 +0200 Subject: [PATCH] Fix no_std build --- src/dir.rs | 4 ++-- src/fs.rs | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/dir.rs b/src/dir.rs index 13a3b3b..7722a31 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -240,9 +240,9 @@ impl <'a, T: ReadWriteSeek + 'a> Dir<'a, T> { // check if directory contains no files for r in self.iter() { let e = r?; - let name = e.file_name(); + let name = e.short_file_name_bytes(); // ignore special entries "." and ".." - if name != "." && name != ".." { + if name != ".".as_bytes() && name != "..".as_bytes() { return Ok(false); } } diff --git a/src/fs.rs b/src/fs.rs index af6f01d..64c82d3 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -1,6 +1,7 @@ use core::cell::RefCell; use core::cmp; use core::char; +use core::iter::FromIterator; use io::prelude::*; use io::{Error, ErrorKind, SeekFrom}; use io; @@ -13,10 +14,7 @@ use dir_entry::DIR_ENTRY_SIZE; use table::{ClusterIterator, alloc_cluster, read_fat_flags, count_free_clusters}; #[cfg(all(not(feature = "std"), feature = "alloc"))] -use alloc::{String, string::ToString}; -#[cfg(all(not(feature = "std"), not(feature = "alloc")))] -use core::str; -use core::iter::FromIterator; +use alloc::String; // FAT implementation based on: // http://wiki.osdev.org/FAT @@ -688,5 +686,5 @@ impl <'a, T: ReadWriteSeek> Seek for DiskSlice<'a, T> { } pub(crate) fn decode_oem_char_lossy(oem_char: u8) -> char { - if oem_char < 0x80 { oem_char as char } else { char::REPLACEMENT_CHARACTER } + if oem_char < 0x80 { oem_char as char } else { '\u{FFFD}' } }