0.3.6 - Accept AsRef<Path> for disk path arguments

This commit is contained in:
Jeremy Soller
2019-07-06 08:21:23 -06:00
parent 39e8b8fa7f
commit 3872f74e9a
4 changed files with 7 additions and 5 deletions
Generated
+1 -1
View File
@@ -97,7 +97,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "redoxfs"
version = "0.3.5"
version = "0.3.6"
dependencies = [
"fuse 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)",
+1 -1
View File
@@ -2,7 +2,7 @@
name = "redoxfs"
description = "The Redox Filesystem"
repository = "https://gitlab.redox-os.org/redox-os/redoxfs"
version = "0.3.5"
version = "0.3.6"
license-file = "LICENSE"
readme = "README.md"
authors = ["Jeremy Soller <jackpot51@gmail.com>"]
+3 -2
View File
@@ -1,5 +1,6 @@
use std::fs::{File, OpenOptions};
use std::io::{Read, Write, Seek, SeekFrom};
use std::path::Path;
use syscall::error::{Error, Result, EIO};
use BLOCK_SIZE;
@@ -20,14 +21,14 @@ pub struct DiskFile {
}
impl DiskFile {
pub fn open(path: &str) -> Result<DiskFile> {
pub fn open<P: AsRef<Path>>(path: P) -> Result<DiskFile> {
let file = try_disk!(OpenOptions::new().read(true).write(true).open(path));
Ok(DiskFile {
file: file
})
}
pub fn create(path: &str, size: u64) -> Result<DiskFile> {
pub fn create<P: AsRef<Path>>(path: P, size: u64) -> Result<DiskFile> {
let file = try_disk!(OpenOptions::new().read(true).write(true).create(true).open(path));
try_disk!(file.set_len(size));
Ok(DiskFile {
+2 -1
View File
@@ -1,5 +1,6 @@
use std::fs::{File, OpenOptions};
use std::io::{Read, Write, Seek, SeekFrom};
use std::path::Path;
use std::u64;
use syscall::error::{Error, Result, EIO};
@@ -21,7 +22,7 @@ pub struct DiskSparse {
}
impl DiskSparse {
pub fn create(path: &str) -> Result<DiskSparse> {
pub fn create<P: AsRef<Path>>(path: P) -> Result<DiskSparse> {
let file = try_disk!(OpenOptions::new().read(true).write(true).create(true).open(path));
Ok(DiskSparse {
file