@@ -16,7 +16,7 @@ use windows_service::{
1616 service_manager:: { ServiceManager , ServiceManagerAccess } ,
1717} ;
1818
19- use crate :: { logger, Context , Result , Server , Settings } ;
19+ use crate :: { helpers , logger, Context , Result , Server , Settings } ;
2020
2121const SERVICE_NAME : & str = "static-web-server" ;
2222const SERVICE_TYPE : ServiceType = ServiceType :: OWN_PROCESS ;
@@ -167,17 +167,6 @@ pub fn run_server_as_service() -> Result {
167167 Ok ( ( ) )
168168}
169169
170- fn adjust_canonicalization ( p : PathBuf ) -> String {
171- const VERBATIM_PREFIX : & str = r#"\\?\"# ;
172- let p = p. to_str ( ) . unwrap_or_default ( ) ;
173- let p = if p. starts_with ( VERBATIM_PREFIX ) {
174- p. strip_prefix ( VERBATIM_PREFIX ) . unwrap_or_default ( )
175- } else {
176- p
177- } ;
178- p. to_owned ( )
179- }
180-
181170/// Install a Windows Service for SWS.
182171pub fn install_service ( config_file : Option < PathBuf > ) -> Result {
183172 let manager_access = ServiceManagerAccess :: CONNECT | ServiceManagerAccess :: CREATE_SERVICE ;
@@ -191,7 +180,7 @@ pub fn install_service(config_file: Option<PathBuf>) -> Result {
191180
192181 // Append a `--config-file` path to the binary arguments if present
193182 if let Some ( f) = config_file {
194- let f = adjust_canonicalization ( f) ;
183+ let f = helpers :: adjust_canonicalization ( f) ;
195184 if !f. is_empty ( ) {
196185 service_binary_arguments. push ( OsString :: from ( [ "--config-file=" , & f] . concat ( ) ) ) ;
197186 }
0 commit comments