1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//! # `SoftPath`
//!
//! A human-friendly file and directory path manipulation library for Rust.
//!
//! This crate provides an ergonomic interface for common file system operations,
//! with a focus on safety, cross-platform compatibility, and ease of use.
//!
//! ## Features
//!
//! - Intuitive path manipulation methods
//! - Automatic directory creation when needed
//! - Home directory expansion (`~` support)
//! - Cross-platform path handling
//! - Strong error handling
//! - Thread-safe operations
//!
//! ## Configuration
//!
//! `SoftPath` provides configurable security limits that can be adjusted globally:
//!
//! ```rust
//! use softpath::{Config, PathExt};
//! use std::path::PathBuf;
//!
//! # fn main() -> Result<(), softpath::SoftPathError> {
//! // Create custom configuration
//! let config = Config::new()
//! .with_max_path_depth(100) // Limit path depth to 100 components
//! .with_max_symlink_depth(10); // Limit symlink following to 10 levels
//!
//! // Set the global configuration
//! softpath::set_config(config);
//!
//! // Now all operations will use these limits
//! let path = PathBuf::from("some/path");
//! match path.create_file() {
//! Ok(()) => println!("File created successfully"),
//! Err(e) if e.to_string().contains("already exists") => {
//! println!("File already exists, continuing...");
//! }
//! Err(e) => return Err(e),
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Basic Examples
//!
//! ```rust
//! use softpath::prelude::*;
//! use std::path::PathBuf;
//!
//! # fn main() -> Result<(), softpath::SoftPathError> {
//! # let temp_dir = std::env::temp_dir();
//! # let config_path = temp_dir.join("softpath_example/config");
//! # let backup_path = temp_dir.join("softpath_example/backup");
//! # std::fs::create_dir_all(&config_path)?;
//! # std::fs::create_dir_all(&backup_path)?;
//!
//! // Create and write to a file
//! let config_file = config_path.join("app.json").into_path()?;
//! config_file.write_string("{\"version\": 1}")?;
//!
//! // Copy to backup location
//! let backup = backup_path.join("app.json").into_path()?;
//! config_file.copy_to(&backup)?;
//! # Ok(())
//! # }
//! ```
pub use Config;
pub use SoftPathError;
pub use PathExt;
pub use set_config;
// Re-export commonly used types
/// Commonly used imports for convenient access to `SoftPath` functionality.
///
/// The `prelude` module re-exports traits and types that are most frequently used,
/// allowing for easier imports in user code.