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
use ;
/// Appends an additional extension to the existing extension of a file path.
///
/// This function preserves the existing extension and appends the new extension
/// to it, instead of replacing it. If the path does not have an existing
/// extension, the new extension is simply added.
///
/// # Arguments
///
/// * `path` - A reference to a `PathBuf` representing the file path.
/// * `ext` - The additional extension to append.
///
/// # Returns
///
/// A new `PathBuf` with the appended extension.
///
/// # Examples
///
/// ```
/// use std::path::{Path, PathBuf};
/// use simd_r_drive::utils::append_extension;
///
/// let path = Path::new("example.txt");
/// let modified = append_extension(path, "bk");
/// assert_eq!(modified, PathBuf::from("example.txt.bk"));
///
/// let path_no_ext = Path::new("example");
/// let modified_no_ext = append_extension(path_no_ext, "bk");
/// assert_eq!(modified_no_ext, PathBuf::from("example.bk"));
///
/// let path_multi_ext = Path::new("archive.tar.gz");
/// let modified_multi_ext = append_extension(path_multi_ext, "bk");
/// assert_eq!(modified_multi_ext, PathBuf::from("archive.tar.gz.bk"));
/// ```