aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFenrir <[email protected]>2017-01-28 21:07:11 -0700
committerFenrir <[email protected]>2017-01-28 21:18:04 -0700
commit47e4c16118a474662f52e4c990972dead727f209 (patch)
tree9677e765df77c7a9d11bcaf21c40cb33a4c6bd08
parentctr-std: Fix panic message formatting (diff)
downloadarchived-ctru-rs-47e4c16118a474662f52e4c990972dead727f209.tar.xz
archived-ctru-rs-47e4c16118a474662f52e4c990972dead727f209.zip
ctru-rs: impl Seek for File
-rw-r--r--ctru-rs/src/services/fs.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/ctru-rs/src/services/fs.rs b/ctru-rs/src/services/fs.rs
index 566ca07..2a567e2 100644
--- a/ctru-rs/src/services/fs.rs
+++ b/ctru-rs/src/services/fs.rs
@@ -3,7 +3,7 @@
//! This module contains basic methods to manipulate the contents of the 3DS's filesystem.
//! Only the SD card is currently supported.
-use std::io::{Read, Write};
+use std::io::{Read, Write, Seek, SeekFrom};
use std::io::Error as IoError;
use std::io::Result as IoResult;
use std::io::ErrorKind as IoErrorKind;
@@ -923,6 +923,27 @@ impl Write for File {
}
}
+impl Seek for File {
+ fn seek(&mut self, pos: SeekFrom) -> IoResult<u64> {
+ match pos {
+ SeekFrom::Start(off) => {
+ self.offset = off;
+ },
+ SeekFrom::End(off) => {
+ let mut temp = self.metadata()?.len() as i64;
+ temp += off;
+ self.offset = temp as u64;
+ },
+ SeekFrom::Current(off) => {
+ let mut temp = self.offset as i64;
+ temp += off;
+ self.offset = temp as u64;
+ },
+ }
+ Ok(self.offset)
+ }
+}
+
impl Drop for Fs {
fn drop(&mut self) {
unsafe {
@@ -983,7 +1004,7 @@ impl From<ArchiveID> for FS_ArchiveID {
SdmcWriteOnly => ARCHIVE_SDMC_WRITE_ONLY,
BossExtdata => ARCHIVE_BOSS_EXTDATA,
CardSpiFS => ARCHIVE_CARD_SPIFS,
- ExtDataAndBossExtdata => ARCHIVE_EXTDATA_AND_BOSS_EXTDATA,
+ ExtDataAndBossExtdata => ARCHIVE_EXTDATA_AND_BOSS_EXTDATA,
SystemSaveData2 => ARCHIVE_SYSTEM_SAVEDATA2,
NandRW => ARCHIVE_NAND_RW,
NandRO => ARCHIVE_NAND_RO,