1use crate::error::Result;
4use crate::presentation::Presentation as PresentationImpl;
5use std::fs::File;
6use std::io::BufReader;
7use std::path::Path;
8
9pub fn Presentation(pptx: Option<&str>) -> Result<PresentationImpl> {
13 let path = pptx.unwrap_or_else(|| {
14 return "";
18 });
19
20 if path.is_empty() {
21 return PresentationImpl::new();
23 }
24
25 if Path::new(path).exists() {
26 let file = File::open(path)?;
27 let reader = BufReader::new(file);
28 PresentationImpl::open(reader)
29 } else {
30 PresentationImpl::new()
32 }
33}
34
35pub fn new_presentation() -> Result<PresentationImpl> {
37 PresentationImpl::new()
38}
39
40pub fn open_presentation<P: AsRef<Path>>(path: P) -> Result<PresentationImpl> {
42 let file = File::open(path)?;
43 let reader = BufReader::new(file);
44 PresentationImpl::open(reader)
45}
46