Browse Source

Update bitflags

pull/10/head
Fenrir 8 years ago
parent
commit
4e629ea378
  1. 2
      ctru-rs/Cargo.toml
  2. 35
      ctru-rs/src/services/fs.rs

2
ctru-rs/Cargo.toml

@ -15,7 +15,7 @@ path = "../ctru-sys" @@ -15,7 +15,7 @@ path = "../ctru-sys"
version = "0.4"
[dependencies.bitflags]
version = "0.7.0"
version = "0.9.0"
[dependencies.widestring]
version = "0.2.2"

35
ctru-rs/src/services/fs.rs

@ -18,26 +18,29 @@ use std::sync::Arc; @@ -18,26 +18,29 @@ use std::sync::Arc;
use widestring::{WideCString, WideCStr};
bitflags! {
flags FsOpen: u32 {
const FS_OPEN_READ = 1,
const FS_OPEN_WRITE = 2,
const FS_OPEN_CREATE = 4,
#[derive(Default)]
struct FsOpen: u32 {
const FS_OPEN_READ = 1;
const FS_OPEN_WRITE = 2;
const FS_OPEN_CREATE = 4;
}
}
bitflags! {
flags FsWrite: u32 {
const FS_WRITE_FLUSH = 1,
const FS_WRITE_UPDATE_TIME = 256,
#[derive(Default)]
struct FsWrite: u32 {
const FS_WRITE_FLUSH = 1;
const FS_WRITE_UPDATE_TIME = 256;
}
}
bitflags! {
flags FsAttribute: u32 {
const FS_ATTRIBUTE_DIRECTORY = 1,
const FS_ATTRIBUTE_HIDDEN = 256,
const FS_ATTRIBUTE_ARCHIVE = 65536,
const FS_ATTRIBUTE_READ_ONLY = 16777216,
#[derive(Default)]
struct FsAttribute: u32 {
const FS_ATTRIBUTE_DIRECTORY = 1;
const FS_ATTRIBUTE_HIDDEN = 256;
const FS_ATTRIBUTE_ARCHIVE = 65536;
const FS_ATTRIBUTE_READ_ONLY = 16777216;
}
}
@ -467,7 +470,7 @@ impl File { @@ -467,7 +470,7 @@ impl File {
impl Metadata {
/// Returns whether this metadata is for a directory.
pub fn is_dir(&self) -> bool {
self.attributes == self.attributes | FS_ATTRIBUTE_DIRECTORY.bits
self.attributes == self.attributes | FS_ATTRIBUTE_DIRECTORY.bits()
}
/// Returns whether this metadata is for a regular file.
@ -586,7 +589,7 @@ impl OpenOptions { @@ -586,7 +589,7 @@ impl OpenOptions {
let path = to_utf16(path);
let fs_path = ::libctru::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _);
let r = ::libctru::FSUSER_OpenFile(&mut file_handle, self.arch_handle,
fs_path, flags.bits, 0);
fs_path, flags.bits(), 0);
if r < 0 {
return Err(IoError::new(IoErrorKind::Other, ::Error::from(r)));
}
@ -685,7 +688,7 @@ pub fn create_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> { @@ -685,7 +688,7 @@ pub fn create_dir<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<()> {
let path = to_utf16(path.as_ref());
let fs_path = ::libctru::fsMakePath(PathType::UTF16.into(), path.as_ptr() as _);
let r = ::libctru::FSUSER_CreateDirectory(arch.handle, fs_path,
FS_ATTRIBUTE_DIRECTORY.bits);
FS_ATTRIBUTE_DIRECTORY.bits());
if r < 0 {
Err(IoError::new(IoErrorKind::Other, ::Error::from(r)))
} else {
@ -722,7 +725,7 @@ pub fn metadata<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<Metadata> { @@ -722,7 +725,7 @@ pub fn metadata<P: AsRef<Path>>(arch: &Archive, path: P) -> IoResult<Metadata> {
let maybe_dir = read_dir(&arch, path.as_ref());
match (maybe_file, maybe_dir) {
(Ok(file), _) => file.metadata(),
(_, Ok(_dir)) => Ok(Metadata { attributes: FS_ATTRIBUTE_DIRECTORY.bits, size: 0 }),
(_, Ok(_dir)) => Ok(Metadata { attributes: FS_ATTRIBUTE_DIRECTORY.bits(), size: 0 }),
(Err(e), _) => Err(e),
}
}

Loading…
Cancel
Save