| Crates.io | samevol |
| lib.rs | samevol |
| version | 0.1.1 |
| created_at | 2025-03-14 22:15:09.081536+00 |
| updated_at | 2025-03-15 01:36:27.666126+00 |
| description | A lightweight Windows utility for determining if two paths reside on the same storage volume. 轻量级 Windows 工具库,用于检测两个路径是否位于同一存储卷。 |
| homepage | |
| repository | https://github.com/Lurito/samevol |
| max_upload_size | |
| id | 1592809 |
| size | 33,946 |
使用中文的开发者可以跳转至下方的中文文档。
A lightweight Windows utility for determining if two paths reside on the same storage volume.
Add to your Cargo.toml:
cargo add samevol
Basic example:
use samevol::is_same_vol;
fn main() {
let path1 = r"C:\Windows\System32";
let path2 = r"D:\Data\test.txt";
println!("Same volume? {}", is_same_vol(path1, path2)); // false
}
Resolves the device path of volume for a given path:
use samevol::resolve_device_path;
fn main() {
let path = r"C:\Windows\System32\drivers\etc\hosts";
let device_path = resolve_device_path(path).expect("Failed to resolve volume");
println!("Device path: {}", device_path);
}
Force refresh volume mappings:
use samevol::reinitialize_volume_map;
fn main() {
// After system storage configuration changes
let count = reinitialize_volume_map().expect("Failed to refresh mappings");
println!("Reloaded {} volume mappings", count);
}
Issues and PRs are welcome!
Note: Due to the limitations of the maintainer's English proficiency, the existing code comments are primarily in Chinese, the maintainer's language.
Apache 2.0 © 2025 爱佐 (Ayrzo)
This repository is licensed under the Apache 2.0 License. See the LICENSE file for details.
AI usage notice: Portions of the codebase, comments, and documentation were written with assistance from DeepSeek AI.
轻量级 Windows 工具库,用于检测两个路径是否位于同一存储卷。
添加到 Cargo.toml:
cargo add samevol
基础用法:
use samevol::is_same_vol;
fn main() {
let path1 = r"C:\Windows\System32";
let path2 = r"D:\Data\test.txt";
println!("是否同一卷? {}", is_same_vol(path1, path2)); // false
}
解析某路径对应卷的设备路径:
use samevol::resolve_device_path;
fn main() {
let path = r"C:\Windows\System32\drivers\etc\hosts";
let device_path = resolve_device_path(path).expect("Failed to resolve volume");
println!("设备路径: {}", device_path);
}
强制刷新卷映射:
use samevol::reinitialize_volume_map;
fn main() {
// 系统存储配置变更后调用
let count = reinitialize_volume_map().expect("映射刷新失败");
println!("已重新加载 {} 个卷映射", count);
}
欢迎提交 issue 和 PR!
Apache 2.0 © 2025 爱佐
本存储库根据 Apache 2.0 许可证授权。有关详细信息,请参阅 LICENSE 文件。
人工智能使用说明:部分代码、注释和文档是在 深度求索 DeepSeek AI 的辅助下编写的。