pub fn check_diary_path_exists(
full_diary_path: &PathBuf,
) -> Result<(), Box<dyn Error>>Expand description
Verifies whether a diary file exists at the specified path.
This function checks if the file at the given path exists on the filesystem. It’s used to determine whether to create a new diary file with a template or append to an existing one.
§Arguments
full_diary_path- Path to the diary file to check
§Returns
Ok(())- File exists at the specified pathErr(Box<dyn Error>)- File does not exist at the specified path
§Errors
Returns an error if:
- The file does not exist on the filesystem
- The path cannot be accessed due to permission issues
- The path represents a directory instead of a file
§Examples
ⓘ
use rusty_commit_saver::vim_commit::check_diary_path_exists;
use std::path::PathBuf;
use std::fs::File;
// Create a temporary test file
let test_file = PathBuf::from("/tmp/test_diary.md");
File::create(&test_file).unwrap();
// File exists - returns Ok
assert!(check_diary_path_exists(&test_file).is_ok());
// File doesn't exist - returns Err
let missing_file = PathBuf::from("/tmp/nonexistent.md");
assert!(check_diary_path_exists(&missing_file).is_err());