@@ -54,12 +54,11 @@ pub fn wallpaper_current_time(
5454 program : Arc < Option < String > > ,
5555 times : & [ Time ] ,
5656) -> Result < ( ) , Box < dyn Error > > {
57+ // we should be able to unwrap the result from canonicalize since we already found
58+ // out that the directory is valid
5759 let mut dir_iter = sorted_dir_iter ( dir) ;
5860
59- dir_iter
60- . next ( )
61- . unwrap ( )
62- . map_err ( |_| Errors :: DirNonExistantError ( dir. to_string ( ) ) ) ?;
61+ dir_iter. next ( ) ;
6362
6463 let mut prog_handle: Command = Command :: new ( "" ) ;
6564 let mut times_iter = times. iter ( ) ;
@@ -127,17 +126,6 @@ pub fn wallpaper_current_time(
127126 Ok ( ( ) )
128127}
129128
130- fn prog_handle_loader ( filepath_set : & str , program : Arc < Option < String > > , prog_handle : & mut Command ) {
131- if let Some ( prog_str) = program. as_deref ( ) {
132- let mut prog_split = prog_str. split_whitespace ( ) ;
133- * prog_handle = Command :: new ( prog_split. next ( ) . unwrap ( ) ) ;
134- for word in prog_split {
135- prog_handle. arg ( word) ;
136- }
137- prog_handle. arg ( filepath_set) ;
138- }
139- }
140-
141129pub fn wallpaper_listener (
142130 dir : String ,
143131 dir_count : usize ,
@@ -186,6 +174,17 @@ pub fn wallpaper_listener(
186174 }
187175}
188176
177+ fn prog_handle_loader ( filepath_set : & str , program : Arc < Option < String > > , prog_handle : & mut Command ) {
178+ if let Some ( prog_str) = program. as_deref ( ) {
179+ let mut prog_split = prog_str. split_whitespace ( ) ;
180+ * prog_handle = Command :: new ( prog_split. next ( ) . unwrap ( ) ) ;
181+ for word in prog_split {
182+ prog_handle. arg ( word) ;
183+ }
184+ prog_handle. arg ( filepath_set) ;
185+ }
186+ }
187+
189188pub fn listener_setup ( dir : & str ) -> ( usize , Result < Time , Errors > , Time , Vec < Time > ) {
190189 let dir_count = WalkDir :: new ( dir) . into_iter ( ) . count ( ) - 1 ;
191190 let step_time = if dir_count == 0 {
@@ -209,10 +208,9 @@ pub fn print_schedule(dir: &str, dir_count: usize) -> Result<(), Box<dyn Error>>
209208 return Err ( Errors :: CountCompatError ( dir_count) . into ( ) ) ;
210209 }
211210
212- dir_iter
213- . next ( )
214- . unwrap ( )
215- . map_err ( |_| Errors :: DirNonExistantError ( dir. to_string ( ) ) ) ?;
211+ dir_iter. next ( ) ;
212+
213+ let mut dir_iter = sorted_dir_iter ( dir) ;
216214
217215 while i < 24 * 60 {
218216 println ! (
@@ -227,7 +225,7 @@ pub fn print_schedule(dir: &str, dir_count: usize) -> Result<(), Box<dyn Error>>
227225 Ok ( ( ) )
228226}
229227
230- fn sorted_dir_iter ( dir : & str ) -> IntoIter {
228+ pub fn sorted_dir_iter ( dir : & str ) -> IntoIter {
231229 WalkDir :: new ( dir)
232230 . sort_by ( |a, b| {
233231 alphanumeric_sort:: compare_str (
@@ -276,12 +274,12 @@ fn error_checking(
276274 None => Err ( Errors :: ConfigFileError ( ConfigFileErrors :: Empty ) ) ,
277275 Some ( time) => Ok ( time) ,
278276 } ?;
279-
280277 if 1440 % dir_count != 0 || dir_count == 0 {
281278 return Err ( Errors :: CountCompatError ( dir_count) . into ( ) ) ;
282- } ;
279+ }
283280 Ok ( * loop_time)
284281}
282+
285283#[ cfg( windows) ]
286284fn de_command_spawn ( filepath_set : & str ) -> Result < ( ) , Box < dyn Error > > {
287285 unsafe {
0 commit comments