Crates.io | ds_store |
lib.rs | ds_store |
version | 0.3.0 |
source | src |
created_at | 2018-12-29 02:37:58.3231 |
updated_at | 2022-12-23 15:45:33.607298 |
description | A .DS_Store parser for Rust. |
homepage | https://github.com/sinistersnare/ds_store |
repository | https://github.com/sinistersnare/ds_store |
max_upload_size | |
id | 104325 |
size | 36,999 |
.DS_Store
Parseradd something like this to your Cargo.toml
file:
[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());
}
This example is replicated in examples/basic.rs
. Call it with $ cargo run --example basic examples/basic.DS_Store
Should be 2015 edition compatible!
This code is distributed under the MIT license. Please see the LICENSE.md file for information.
.DS_Store
file?The Desktop Services Store is mostly just deleted without a second thought. However, such files can be helpful! What are they really for?
Put simply, .DS_Store
files are used on MacOS Computers to describe the contents of the directory they are in.
.DS_Store
's are created, maintained, and read by the Finder application to properly render directories.
The things that this file describes includes properties set in the directory options, file icons, directory background color or image, and many more things.
The file has 3 important sections. First, the prelude, which gives information about where to find the main information block of the file. Second, the information block, containing bookkeeping information for the data-section. Finally, the data section, holding the actual metadata of the directory.
Looking at this list, I probably should not have released the library so early! I was so excited though! Oh well, I guess I better get to improving it!
.DS_Store
files?????0x0000000000000004
)