Commit Graph

195 Commits

Author SHA1 Message Date
Rafał Harabień
881cf7709d Deprecate set_created. set_accessed, set_modified methods on File 2018-06-28 18:58:29 +02:00
Rafał Harabień
ecef2627a7 Move time related code to 'time' module 2018-06-28 18:53:51 +02:00
Rafał Harabień
1f8f8365d6 Add TimeProvider trait and time_provider option
This functionality is very useful for embedded usage where chrono feature
cannot be enabled.
2018-06-28 18:43:02 +02:00
Rafał Harabień
30f3f96537 Improve code style using rustfmt 2018-06-28 18:13:07 +02:00
Rafał Harabień
98c0fa528c Fix no_std build 2018-06-25 23:56:46 +02:00
Rafał Harabień
4528aedc6e Add oem_cp_converter option allowing to provide custom short name decoder
Encoder is not yet used but will be in future.
This is implemented as static reference for now to avoid adding additional
type parameters to all main types. It should be enough for most of cases
where encoder/decoder does not have any state and can be implemented as
static variable.
2018-06-25 23:51:09 +02:00
Rafał Harabień
cd7e77e1b4 Rename directory entry flags and add some internal docs 2018-06-25 00:22:34 +02:00
Rafał Harabień
f9ca0f95ce Fix decoding 0xE5 character in first byte of short name 2018-06-25 00:16:14 +02:00
Rafał Harabień
be96ba8122 Properly handle short names with spaces in the middle 2018-06-25 00:07:11 +02:00
Rafał Harabień
a672add4e7 Remove unnecessary clone() calls 2018-06-23 14:49:16 +02:00
Rafał Harabień
099434c45d Improve file creation time resolution to 1/100s 2018-06-23 14:17:58 +02:00
Rafał Harabień
fda4b5ca5b Add docs for FatType variants 2018-06-20 19:56:16 +02:00
Rafał Harabień
fe90d952bf Fix doc-tests 2018-06-20 19:52:18 +02:00
Rafał Harabień
60d517a951 Add millis field to Time struct (BREAKING CHANGE) 2018-06-20 19:19:41 +02:00
Rafał Harabień
04887faaea Improve docs 2018-06-20 19:08:50 +02:00
Rafał Harabień
8be8c68eab Remove update_fs_info option
FSInfo sector should always be saved if it has changed.
2018-06-20 18:03:12 +02:00
Rafał Harabień
c4a1bc70ec Rename methods: bytes -> as_bytes 2018-06-20 17:38:04 +02:00
Rafał Harabień
69b7675940 Fix no_std build 2018-06-20 17:28:46 +02:00
Rafał Harabień
7a53215a57 No longer return &str for short names in no_std mode
Instead methods returning &[u8] were added.
It is API preparation for proper OEM codepage decoding.
Previous behavior would require to store duplicated short names
(one lossy and one real).
2018-06-20 17:17:01 +02:00
Rafał Harabień
f68996925f Make sure short name generation never fails 2018-06-17 23:21:33 +02:00
Rafał Harabień
a6b66f9434 Make errors more consistent with std::fs 2018-06-17 23:11:53 +02:00
Rafał Harabień
8995a43bc4 Allow renaming to the same name 2018-06-17 22:26:07 +02:00
Rafał Harabień
8c1dae9f0c Do not remove source file in Dir::rename if destination already exists
Previous code removed source file before returning an error.
It also caused a clusters leak. Now it returns error before doing any
modifications on the partition.
2018-06-17 22:25:22 +02:00
Rafał Harabień
4afd38a150 Fix possible overflow when calculating short name checksum
Affects debug build only. Overflow was not handled when calculating
checksum used for short name generation when avoiding a conflict.
LFN checksum was working properly but got refactored in this commit to
use num::Wrapping as well.
2018-06-17 21:58:39 +02:00
Rafał Harabień
674d1f8182 Fix failing in Dir::create_file/dir if existing destination entry has wrong type 2018-06-17 21:46:54 +02:00
Rafał Harabień
4f08acf4ab Do not mount volume if fs_version field in BPB is not zero 2018-06-17 16:34:08 +02:00
Rafał Harabień
8a5491a919 Doc improvements 2018-06-17 16:27:59 +02:00
Rafał Harabień
11a39fdaae Improve/fix API docs 2018-06-16 18:35:56 +02:00
Rafał Harabień
892c3974d3 Move BufStream to fscommon crate (BREAKING CHANGE)
BufStream is universal and can be used with any filesystem so its place is
in different crate. Also moved Partition struct from examples to
fscommon::StreamSlice struct (please note constructor arguments has changed).
2018-06-16 17:57:29 +02:00
Rafał Harabień
5f7fb04084 Add more allocation table tests 2018-06-14 00:59:06 +02:00
Rafał Harabień
217b6046f1 Make disk object type generic (breaking change)
This change allows for moving an object ownership to FileSystem object
instead of borrowing it. It makes usage of library easier in some cases.
Unfortunately it is a breaking change.
2018-06-13 23:24:08 +02:00
Rafał Harabień
b1894a435e Add FAT reading tests 2018-06-12 01:16:35 +02:00
Rafał Harabień
2304b13ec4 Take immutable self reference in Dir methods
Dir methods do not change Dir object itself. They usually clone inner
stream so no change really happens self struct. Underlying partition is
modified but it does not have to affect API. For example see
std::fs::File::set_len. This change greatly simplifies rename API usage.
2018-06-12 00:07:30 +02:00
Rafał Harabień
4f6ed94cb3 Limit file size to 4GB when writting 2018-06-09 19:32:15 +02:00
Rafał Harabień
18b9d8c285 Do not panic if unexpected file type is found during path traversal
For example if in the middle of the path a file is found.
Return error in such case instead of panicking.
2018-06-07 23:26:11 +02:00
Rafał Harabień
632a371b0d Improve code structure 2018-06-07 23:07:52 +02:00
Rafał Harabień
ccb205c906 Ignore free_cluster_count in FSInfo sector if volume has dirty flag 2018-06-07 22:54:35 +02:00
Rafał Harabień
1656540eac Simplify code by using Self in return type 2018-06-06 17:16:32 +02:00
Rafał Harabień
75a6c32360 Add derived traits for FsStatusFlags and add Eq for some structs 2018-06-06 14:29:38 +02:00
Rafał Harabień
85c48d6aec Make FsStatusFlags struct fields non-public and add getters
This way new fields can be added later without losing backward compatibility.
2018-06-06 14:17:05 +02:00
Rafał Harabień
0b5b04aca6 Make FileSystemStats struct fields non-public and add getters
This way new fields can be added later without losing backward compatibility.
2018-06-06 14:01:19 +02:00
Rafał Harabień
66c976bc3b Add method for renaming/moving a file 2018-06-06 13:56:59 +02:00
Rafał Harabień
21b51af6d5 Fix nostd build 2018-06-04 22:41:38 +02:00
Rafał Harabień
242e650626 Reduce number of pub(crate) attributes 2018-06-03 16:44:12 +02:00
Rafał Harabień
be0d969f7b Remove ReadSeek and ReadWriteSeek traits duplicated definition 2018-06-03 16:29:44 +02:00
Rafał Harabień
a83115dd45 Update FSInfo sector by default (if it is dirty) 2018-05-31 21:39:17 +02:00
Rafał Harabień
9f5f070955 Allow opening files/dirs using short name 2018-05-31 00:23:32 +02:00
Rafał Harabień
7355ac462c Make short name generation more compatible to WinNT 2018-05-31 00:17:01 +02:00
Rafał Harabień
b53882a2ad Fix detection of short name collisions for very short names 2018-05-31 00:11:18 +02:00
Rafał Harabień
0b22cfa0b3 Avoid building short name when traversing path 2018-05-30 17:54:03 +02:00
Rafał Harabień
282c40fad2 Implement proper short-name generation 2018-05-30 17:43:18 +02:00
Rafał Harabień
7c5541c2a9 Add test for lowercase SFN (short LFN encoded in SFN) 2018-05-30 01:39:34 +02:00
Rafał Harabień
d455540707 Add more unit tests 2018-05-30 01:33:01 +02:00
Rafał Harabień
0e96b05054 Add support for LFN encoding in SFN entries on WinNT
New Windows does not create LFN entries if name fits in 8.3 format and
letters in both basename and ext parts are all uppercase or all lowercase.
This commit fixes handling of lowercase letters.
2018-05-30 01:17:24 +02:00
Rafał Harabień
b4be13823c Cache free clusters count 2018-05-28 00:03:42 +02:00
Rafał Harabień
945612f042 Do not write FSInfo sector if nothing changed. 2018-05-27 23:56:38 +02:00
Rafał Harabień
147b31fdcd Update FSInfo sector on unmount/drop 2018-05-27 23:48:38 +02:00
Rafał Harabień
908ab61ee5 Update number of free clusters when allocating and freeing 2018-05-27 23:31:40 +02:00
Rafał Harabień
380add131d Simplify code by using while and if let constructions 2018-05-27 18:37:33 +02:00
Rafał Harabień
a760b4b6d0 Fix cluster leak when truncating files 2018-05-27 18:04:45 +02:00
Rafał Harabień
7709f5e6f6 Add FileSystem::stats method
It allows to get number of total and free clusters on FAT volume.
2018-05-26 17:09:13 +02:00
Rafał Harabień
6230fe91f9 Do not ignore 2 last clusters when allocating 2018-05-26 17:02:36 +02:00
Rafał Harabień
9129816893 Speed up allocation by tracking last allocated cluster 2018-05-26 14:36:38 +02:00
Rafał Harabień
d094fd5d1d Support checking entire FAT table when hint points in the middle of it 2018-05-12 23:38:56 +02:00
Rafał Harabień
4793d20977 Read FSInfo sector on mount and use it during cluster allocation 2018-05-12 23:17:45 +02:00
Rafał Harabień
3dc332d8c8 Fix std build 2018-05-10 15:14:09 +02:00
Rafał Harabień
35d03daae9 Support no_std without alloc 2018-05-10 15:00:59 +02:00
Rafał Harabień
11b2a3b956 Basic no_std support 2018-05-10 01:00:24 +02:00
Rafał Harabień
73c6e9a461 Fix compilation without chromo 2018-05-09 22:58:05 +02:00
Rafał Harabień
429864a69f Clarify that seeked filesystem is not handled by library 2018-05-09 15:34:41 +02:00
Rafał Harabień
e9dec65318 Fix warnings in Rust 1.25 2018-05-09 15:34:00 +02:00
Rafał Harabień
8bb24994e0 Add read_status_flags API for getting dirty and IO error volume flags. 2017-12-01 17:24:02 +01:00
Rafał Harabień
cecc35033a Add write example. 2017-11-08 20:40:36 +01:00
Rafał Harabień
d5c37f2af5 Introduce FsOptions struct for providing options for library.
Old read_only flag in FileSystem::new was misleading.
2017-11-08 20:26:50 +01:00
Rafał Harabień
8a8ee3c51a Ignore volume ID and label if signature is not valid. 2017-11-08 20:03:21 +01:00
Rafał Harabień
5c0ad0ce18 More code refactoring. 2017-11-08 19:59:03 +01:00
Rafał Harabień
681ee56cb3 Keep only BPB in FileSystem struct instead of entire BootRecord. 2017-11-08 19:41:05 +01:00
Rafał Harabień
4366b1836d Add more comments in code. 2017-11-08 16:47:12 +01:00
Rafał Harabień
3f581835db Code refactoring - no functional changes. 2017-11-08 16:03:08 +01:00
Rafał Harabień
3dc524759f WIP dir_entry module? 2017-11-08 14:09:20 +01:00
Rafał Harabień
c4e6d59492 Add set_created and set_accessed public functions in File.
Small code refactoring included.
2017-11-08 01:23:00 +01:00
Rafał Harabień
b38ea78f3e Add automatic update of timestamps (created, accessed, modified).
Works only if chrono feature is enabled (default).
2017-11-08 00:18:31 +01:00
Rafał Harabień
cdde3ca468 When generating short name replace invalid characters with '?'. 2017-11-08 00:07:06 +01:00
Rafał Harabień
1576c4d697 Add file name validation. 2017-11-07 23:17:52 +01:00
Rafał Harabień
288da370b3 Ignore high 16 bits of cluster number in FAT12/16 dir entry. 2017-11-07 22:52:56 +01:00
Rafał Harabień
de9977e571 Don't panic in Drop.
The same behavior exists (without logging) in BufWriter from std crate.
It's not recommended to depend on flush during drop.
Instead user should flush explicitly and check for error.
2017-11-07 01:13:02 +01:00
Rafał Harabień
4613196733 Catch only NotFound error in create_file and create_dir. 2017-11-07 01:06:52 +01:00
Rafał Harabień
21bd2a0e8d Zero new directory clusters after allocation. 2017-10-27 15:03:54 +02:00
Rafał
9ec23f1234 Add create_dir function. (#5) 2017-10-27 14:12:53 +02:00
Rafał
529d717e30 Add .editorconfig file and fix whitespaces in existing files. (#4) 2017-10-25 17:20:27 +02:00
Rafał Harabień
9d3780f859 Update README and add more doc comments. 2017-10-21 16:25:04 +02:00
Rafał Harabień
2a61b0d175 Small code improvements. 2017-10-21 15:51:19 +02:00
Rafał
df98ca8779 Create file functionality (#3)
* Support removing files and directories.

* Add create_file functionality.
2017-10-21 15:35:26 +02:00
Rafał Harabień
ba5329edad Support removing files and directories. 2017-10-20 16:18:17 +02:00
Rafał Harabień
b2c3eb1823 Don't recalculate cluster in seek if not needed. 2017-10-15 16:17:41 +02:00
Rafał Harabień
e2374c08cc Fix seek for directory backed file. 2017-10-15 15:56:01 +02:00
Rafał Harabień
da76625759 Replace commented out logging by log crate usage. 2017-10-15 00:55:19 +02:00
Rafał Harabień
ef96f90b0d Add checking for LFN sequence corruption. 2017-10-14 15:24:03 +02:00
Rafał Harabień
98ec30589a Add some sanity checks and fix possible issues with partial read when not using read_exact. 2017-10-10 23:19:44 +02:00
Rafał Harabień
d52b0918ca Support FAT mirroring. 2017-10-10 23:18:32 +02:00