Skip to content

Commit

Permalink
rust updates
Browse files Browse the repository at this point in the history
- no need to declare feature io/path anymore
- change range(start,end) to (start..end)
- deprecated warnings remain for FileType & PosixPath, used by rust-fuse
  • Loading branch information
cuviper committed Mar 19, 2015
1 parent 8693d41 commit f6dcaae
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/inode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use libc;
use libc::consts::os::posix88;
use std::collections::hash_map;
use std::old_io::FileType;
use std::old_path::PosixPath;

use blob;
use tree;
Expand All @@ -33,7 +34,7 @@ pub enum Id {
/// A generic interface for different Git object types to implement.
pub trait Inode: Send {
/// Find a directory entry in this Inode by name.
fn lookup(&mut self, _repo: &git2::Repository, _name: &Path
fn lookup(&mut self, _repo: &git2::Repository, _name: &PosixPath
) -> Result<Id, libc::c_int> {
Err(posix88::ENOTDIR)
}
Expand Down Expand Up @@ -62,7 +63,7 @@ pub trait Inode: Send {

/// Read directory entries from this Inode.
fn readdir<'a>(&'a mut self, _repo: &git2::Repository, _offset: u64,
_add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
_add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
) -> Result<(), libc::c_int> {
Err(posix88::ENOTDIR)
}
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
#![feature(asm)]
#![feature(core)]
#![feature(io)]
#![feature(libc)]
#![feature(old_io)]
#![feature(old_path)]
#![feature(path)]
#![feature(std_misc)]

#![deny(missing_docs)]
Expand Down
1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
//!
//! - MOUNTPOINT: The target to mount the filesystem. Defaults to GIT_DIR/fs.
#![feature(path)]
#![feature(std_misc)]

extern crate gitfs;
Expand Down
7 changes: 4 additions & 3 deletions src/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ use libc::consts::os::posix88;
use std::collections::hash_map;
use std::default::Default;
use std::old_io::{FileType, USER_DIR};
use std::old_path::PosixPath;

use inode;


/// Represents a virtual directory in reference paths
/// (e.g. `refs/heads/master` needs intermediate `refs/` and `refs/heads/`)
pub struct RefDir {
entries: hash_map::HashMap<Path, inode::Id>,
entries: hash_map::HashMap<PosixPath, inode::Id>,
}

impl RefDir {
Expand All @@ -31,7 +32,7 @@ impl RefDir {
}

impl inode::Inode for RefDir {
fn lookup(&mut self, _repo: &git2::Repository, name: &Path
fn lookup(&mut self, _repo: &git2::Repository, name: &PosixPath
) -> Result<inode::Id, libc::c_int> {
self.entries.get(name).cloned().ok_or(posix88::ENOENT)
}
Expand All @@ -49,7 +50,7 @@ impl inode::Inode for RefDir {
}

fn readdir<'a>(&mut self, _repo: &git2::Repository, offset: u64,
mut add: Box<FnMut(inode::Id, FileType, &Path) -> bool + 'a>
mut add: Box<FnMut(inode::Id, FileType, &PosixPath) -> bool + 'a>
) -> Result<(), libc::c_int> {
if offset < self.entries.len() as u64 {
for (path, &id) in self.entries.iter().skip(offset as usize) {
Expand Down
9 changes: 5 additions & 4 deletions src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use git2;
use libc;
use libc::consts::os::posix88;
use std::old_io::{FileType, USER_DIR};
use std::old_path::PosixPath;

use inode;
use inode::{FileAttr, Id, Inode};
Expand All @@ -30,7 +31,7 @@ impl Root {
}

impl Inode for Root {
fn lookup(&mut self, repo: &git2::Repository, name: &Path
fn lookup(&mut self, repo: &git2::Repository, name: &PosixPath
) -> Result<Id, libc::c_int> {
if name.as_vec() == b"HEAD" {
repo.head().ok()
Expand All @@ -56,13 +57,13 @@ impl Inode for Root {
}

fn readdir<'a>(&mut self, _repo: &git2::Repository, offset: u64,
mut add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
mut add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
) -> Result<(), libc::c_int> {
if offset == 0 {
add(self.head, FileType::Unknown, &Path::new("HEAD"));
add(self.head, FileType::Unknown, &PosixPath::new("HEAD"));
}
if offset <= 1 {
add(self.refs, FileType::Unknown, &Path::new("refs"));
add(self.refs, FileType::Unknown, &PosixPath::new("refs"));
}
Ok(())
}
Expand Down
9 changes: 5 additions & 4 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use git2;
use libc;
use libc::consts::os::posix88;
use std::old_io::{FileType, USER_DIR};
use std::old_path::PosixPath;
use std::path::AsPath;

use inode;
Expand All @@ -36,7 +37,7 @@ impl Tree {
}

impl Inode for Tree {
fn lookup(&mut self, repo: &git2::Repository, name: &Path
fn lookup(&mut self, repo: &git2::Repository, name: &PosixPath
) -> Result<Id, libc::c_int> {
self.tree(repo).and_then(|tree| {
match tree.get_path(name.as_path()) {
Expand All @@ -58,11 +59,11 @@ impl Inode for Tree {
}

fn readdir<'a>(&'a mut self, repo: &git2::Repository, offset: u64,
mut add: Box<FnMut(Id, FileType, &Path) -> bool + 'a>
mut add: Box<FnMut(Id, FileType, &PosixPath) -> bool + 'a>
) -> Result<(), libc::c_int> {
let len = self.size;
self.tree(repo).map(|tree| {
for i in range(offset, len) {
for i in (offset..len) {
let e = match tree.get(i as usize) {
Some(e) => e,
None => continue,
Expand All @@ -72,7 +73,7 @@ impl Inode for Tree {
Some(git2::ObjectType::Blob) => FileType::RegularFile,
_ => FileType::Unknown,
};
let path = Path::new(e.name_bytes());
let path = PosixPath::new(e.name_bytes());
if add(Id::Oid(e.id()), kind, &path) {
break;
}
Expand Down
1 change: 0 additions & 1 deletion tests/self.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Test that this very testfile is accessible in our own mount.
#![feature(path)]
#![feature(path_ext)]

extern crate gitfs;
Expand Down

0 comments on commit f6dcaae

Please sign in to comment.