forked from M-Labs/zynq-rs
core_io -> core2::io
This commit is contained in:
parent
313662b196
commit
26bde04a19
|
@ -6,9 +6,8 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
libboard_zynq = { path = "../libboard_zynq" }
|
||||
<<<<<<< HEAD
|
||||
core_io = { version = "0.1", features = ["collections"] }
|
||||
fatfs = { version = "0.3", features = ["core_io"], default-features = false }
|
||||
core2 = { version = "=0.3.2", features = ["alloc", "nightly"], default-features = false }
|
||||
fatfs = { git = "https://github.com/SimonRenblad/rust-fatfs", branch = "stable-0.3", features = ["core2", "alloc"], default-features = false }
|
||||
log = "=0.4.14"
|
||||
|
||||
[features]
|
||||
|
@ -17,4 +16,3 @@ target_coraz7 = []
|
|||
target_redpitaya = []
|
||||
target_kasli_soc = []
|
||||
ipv6 = []
|
||||
fat_lfn = [ "fatfs/alloc" ]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use alloc::vec::Vec;
|
||||
use core_io::{Error, Read, Seek, SeekFrom};
|
||||
use core2::io::{Error, Read, Seek, SeekFrom};
|
||||
use libboard_zynq::devc;
|
||||
use log::debug;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ extern crate alloc;
|
|||
|
||||
use core::fmt;
|
||||
use alloc::{string::FromUtf8Error, string::String, vec::Vec, rc::Rc};
|
||||
use core_io::{self as io, BufRead, BufReader, Read, Write, Seek, SeekFrom};
|
||||
use core2::io::{self as io, Read, Write, Seek, SeekFrom};
|
||||
use libboard_zynq::sdio;
|
||||
|
||||
pub mod sd_reader;
|
||||
|
@ -54,11 +54,13 @@ impl<'a> From<FromUtf8Error> for Error<'a> {
|
|||
fn parse_config<'a>(
|
||||
key: &'a str,
|
||||
buffer: &mut Vec<u8>,
|
||||
file: fatfs::File<sd_reader::SdReader>,
|
||||
file: &mut fatfs::File<sd_reader::SdReader>,
|
||||
) -> Result<'a, ()> {
|
||||
let prefix = [key, "="].concat().to_ascii_lowercase();
|
||||
for line in BufReader::new(file).lines() {
|
||||
let line = line?.to_ascii_lowercase();
|
||||
let mut read_buf = Vec::new();
|
||||
file.read_to_end(&mut read_buf)?;
|
||||
for line in String::from_utf8(read_buf)?.lines() {
|
||||
let line = line.to_ascii_lowercase();
|
||||
if line.starts_with(&prefix) {
|
||||
buffer.extend(line[prefix.len()..].as_bytes());
|
||||
return Ok(());
|
||||
|
@ -101,7 +103,7 @@ impl Config {
|
|||
match root_dir.open_file(&["/CONFIG/", key, ".BIN"].concat()) {
|
||||
Ok(mut f) => f.read_to_end(&mut buffer).map(|_| ())?,
|
||||
Err(_) => match root_dir.open_file("/CONFIG.TXT") {
|
||||
Ok(f) => parse_config(key, &mut buffer, f)?,
|
||||
Ok(mut f) => parse_config(key, &mut buffer, &mut f)?,
|
||||
Err(_) => return Err(Error::KeyNotFoundError(key)),
|
||||
},
|
||||
};
|
||||
|
@ -124,11 +126,11 @@ impl Config {
|
|||
let prefix = [key, "="].concat().to_ascii_lowercase();
|
||||
match root_dir.create_file("/CONFIG.TXT") {
|
||||
Ok(mut f) => {
|
||||
let mut buffer = String::new();
|
||||
f.read_to_string(&mut buffer)?;
|
||||
let mut buffer = Vec::new();
|
||||
f.read_to_end(&mut buffer)?;
|
||||
f.seek(SeekFrom::Start(0))?;
|
||||
f.truncate()?;
|
||||
for line in buffer.lines() {
|
||||
for line in String::from_utf8(buffer)?.lines() {
|
||||
if line.len() > 0 && !line.to_ascii_lowercase().starts_with(&prefix) {
|
||||
f.write(line.as_bytes())?;
|
||||
f.write(NEWLINE)?;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use core_io::{BufRead, Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write};
|
||||
use core2::io::{BufRead, Error, ErrorKind, Read, Result as IoResult, Seek, SeekFrom, Write};
|
||||
use fatfs;
|
||||
use libboard_zynq::sdio::{sd_card::SdCard, CmdTransferError};
|
||||
use log::debug;
|
||||
|
|
|
@ -13,9 +13,9 @@ target_kasli_soc = ["libboard_zynq/target_kasli_soc", "libsupport_zynq/target_ka
|
|||
default = ["target_zc706"]
|
||||
|
||||
[dependencies]
|
||||
log = "0.4"
|
||||
byteorder = { version = "1.3", default-features = false }
|
||||
core_io = { version = "0.1", features = ["collections"] }
|
||||
log = "=0.4.14"
|
||||
byteorder = { version = "=1.3", default-features = false }
|
||||
core2 = { version = "=0.3.2", default-features = false, features = ["alloc", "nightly"] }
|
||||
|
||||
libboard_zynq = { path = "../libboard_zynq" }
|
||||
libsupport_zynq = { path = "../libsupport_zynq" }
|
||||
|
|
|
@ -8,7 +8,7 @@ mod netboot;
|
|||
|
||||
use alloc::rc::Rc;
|
||||
use core::mem;
|
||||
use core_io::{Read, Seek};
|
||||
use core2::io::{Read, Seek};
|
||||
use libboard_zynq::{
|
||||
self as zynq,
|
||||
clocks::source::{ArmPll, ClockSource, IoPll},
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
use byteorder::{ByteOrder, NetworkEndian};
|
||||
use core_io::{Read, Seek};
|
||||
use core2::io::{Read, Seek};
|
||||
use libboard_zynq::{
|
||||
devc,
|
||||
eth::Eth,
|
||||
|
|
Loading…
Reference in New Issue