Fix &'static str -> &str.

master
WangRunji 7 years ago
parent 20d2ac2eca
commit 0e6510c84f

@ -4,7 +4,7 @@ version = "0.0.1"
authors = ["WangRunji <wangrunji0408@163.com>"] authors = ["WangRunji <wangrunji0408@163.com>"]
[lib] [lib]
crate-type = ["staticlib"] #crate-type = ["staticlib"]
[profile.dev] [profile.dev]
panic = 'abort' # prevent `_Unwind_Resume` link error panic = 'abort' # prevent `_Unwind_Resume` link error

@ -32,6 +32,9 @@ pub mod c_interface;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
pub use sfs::*;
pub use vfs::*;
#[cfg(feature = "ucore")] #[cfg(feature = "ucore")]
#[global_allocator] #[global_allocator]
pub static UCORE_ALLOCATOR: c_interface::UcoreAllocator = c_interface::UcoreAllocator{}; pub static UCORE_ALLOCATOR: c_interface::UcoreAllocator = c_interface::UcoreAllocator{};

@ -96,7 +96,7 @@ impl INode {
} }
} }
/// Only for Dir /// Only for Dir
fn get_file_inode_id(&self, name: &'static str) -> Option<INodeId> { fn get_file_inode_id(&self, name: &str) -> Option<INodeId> {
(0..self.disk_inode.blocks) (0..self.disk_inode.blocks)
.map(|i| { .map(|i| {
use vfs::INode; use vfs::INode;
@ -249,7 +249,7 @@ impl vfs::INode for INode {
assert_eq!(self.disk_inode.type_, FileType::File, "resize is only available on file"); assert_eq!(self.disk_inode.type_, FileType::File, "resize is only available on file");
self._resize(len) self._resize(len)
} }
fn create(&mut self, name: &'static str, type_: vfs::FileType) -> vfs::Result<Ptr<vfs::INode>> { fn create(&mut self, name: &str, type_: vfs::FileType) -> vfs::Result<Ptr<vfs::INode>> {
let fs = self.fs.upgrade().unwrap(); let fs = self.fs.upgrade().unwrap();
let info = self.info().unwrap(); let info = self.info().unwrap();
assert_eq!(info.type_, vfs::FileType::Dir); assert_eq!(info.type_, vfs::FileType::Dir);
@ -273,7 +273,7 @@ impl vfs::INode for INode {
Ok(inode) Ok(inode)
} }
fn lookup(&self, path: &'static str) -> vfs::Result<Ptr<vfs::INode>> { fn lookup(&self, path: &str) -> vfs::Result<Ptr<vfs::INode>> {
let fs = self.fs.upgrade().unwrap(); let fs = self.fs.upgrade().unwrap();
let info = self.info().unwrap(); let info = self.info().unwrap();
assert_eq!(info.type_, vfs::FileType::Dir); assert_eq!(info.type_, vfs::FileType::Dir);

@ -82,15 +82,15 @@ impl Debug for Str32 {
write!(f, "{}", self.as_ref()) write!(f, "{}", self.as_ref())
} }
} }
impl From<&'static str> for Str256 { impl<'a> From<&'a str> for Str256 {
fn from(s: &'static str) -> Self { fn from(s: &'a str) -> Self {
let mut ret = [0u8; 256]; let mut ret = [0u8; 256];
ret[0..s.len()].copy_from_slice(s.as_ref()); ret[0..s.len()].copy_from_slice(s.as_ref());
Str256(ret) Str256(ret)
} }
} }
impl From<&'static str> for Str32 { impl<'a> From<&'a str> for Str32 {
fn from(s: &'static str) -> Self { fn from(s: &'a str) -> Self {
let mut ret = [0u8; 32]; let mut ret = [0u8; 32];
ret[0..s.len()].copy_from_slice(s.as_ref()); ret[0..s.len()].copy_from_slice(s.as_ref());
Str32(ret) Str32(ret)

@ -22,8 +22,8 @@ pub trait INode: Debug {
// fn name_file(&mut self) -> Result<()>; // fn name_file(&mut self) -> Result<()>;
// fn reclaim(&mut self) -> Result<()>; // fn reclaim(&mut self) -> Result<()>;
fn resize(&mut self, len: usize) -> Result<()>; fn resize(&mut self, len: usize) -> Result<()>;
fn create(&mut self, name: &'static str, type_: FileType) -> Result<INodePtr>; fn create(&mut self, name: &str, type_: FileType) -> Result<INodePtr>;
fn lookup(&self, path: &'static str) -> Result<INodePtr>; fn lookup(&self, path: &str) -> Result<INodePtr>;
fn list(&self) -> Result<Vec<String>>; fn list(&self) -> Result<Vec<String>>;
// fn io_ctrl(&mut self, op: u32, data: &[u8]) -> Result<()>; // fn io_ctrl(&mut self, op: u32, data: &[u8]) -> Result<()>;
fn fs(&self) -> Weak<FileSystem>; fn fs(&self) -> Weak<FileSystem>;

Loading…
Cancel
Save