6个版本
使用旧的Rust 2015
0.3.0 | 2022年12月23日 |
---|---|
0.2.1 | 2018年12月30日 |
0.1.2 | 2018年12月29日 |
#65 in macOS和iOS API
27KB
445 行
一个Rusty .DS_Store
解析器
获取库!
将以下内容添加到您的 Cargo.toml
文件中
[dependencies]
ds_store = "0.3"
用法
extern crate ds_store;
use std::collections::HashMap;
use std::{io::Read, fs::File};
use ds_store::{DsStore, RecordValue};
fn main() {
let args: Vec<String> = std::env::args().collect();
if args.len() != 2 {
println!("Incorrect usage! `./binary_path /path/to/.DS_Store");
return;
}
let mut file = File::open(&args[1]).expect("Could not open file.");
let mut buf: Vec<u8> = vec![];
file.read_to_end(&mut buf).expect("Could not read file to end.");
let store: DsStore = match DsStore::new(&buf) {
Ok(s) => s,
Err(e) => {
println!("Could not construct the DS_Store: {:?}", e);
return;
}
};
let records: &HashMap<String, HashMap<&str, RecordValue>> = store.contents();
records.iter().for_each(|r| println!("{:?}", r));
println!("printed {:?} records", records.len());
}
此示例在 examples/basic.rs
中复制。用以下命令调用: $ cargo run --example basic examples/basic.DS_Store
Rust版本
应该与2015版兼容!
许可
此代码在 MIT许可证 下分发。有关信息,请参阅LICENSE.md文件。
什么是.DS_Store
文件?
“桌面服务存储”通常会被毫不犹豫地删除。然而,这样的文件可能会有所帮助!它们究竟有什么作用?
简单来说,.DS_Store
文件用于在MacOS计算机上描述它们所在目录的内容。.DS_Store
由Finder应用程序创建、维护和读取,以正确渲染目录。此文件描述的内容包括在目录选项中设置的属性、文件图标、目录背景颜色或图像等。
文件有3个重要部分。首先是序言部分,它提供了有关文件主信息块位置的信息。第二是信息块,包含数据部分的账簿信息。最后是数据部分,包含目录的实际元数据。
待办事项
查看此列表,我可能不应该这么早发布库!但我太兴奋了!哦,好吧,我想我最好开始改进它了!
- 解决代码中的各种待办事项。
- 记录一切!
- 严格的测试?可能吧!
- 确保使用背景图像和各种其他内容进行测试。
- 更好的API?你打算用DS_Store文件做什么?告诉我!创建一个问题!
- 创建/操作
.DS_Store
文件???? - 使其与no_std兼容?可能不会发生。std类型太好了。
- 添加日志记录,以记录被证明是错误的假设(例如'icgo'记录不是
0x0000000000000004
)
依赖关系
~1.5MB
~20K SLoC