buesingniklas icon

Untitled

buesingniklas | PRO | 01/10/22 05:41:28 AM UTC | 0 ⭐ | 10180 👁️ | Never ⏰ | []
Rust |

1.07 KB

|

None

|

0 👍

/

0 👎

fn extract_sciter() -> anyhow::Result<String> {
    for file in std::fs::read_dir(std::env::temp_dir())? {
        if let Ok(entry) = file {
            let path = entry.path();
            if path.is_dir()
                && path
                    .file_name()
                    .unwrap_or_default()
                    .to_os_string()
                    .into_string()
                    .unwrap_or_default()
                    .starts_with("sciter")
            {
                std::fs::remove_dir_all(path).ok();
            }
        }
    }
 
    let sciter = include_bytes!("../resources/sciter.dll.zs");
 
    let tmp_dir = tempfile::Builder::new().prefix("sciter").tempdir()?;
    let tmp_file = tmp_dir.path().join("sciter.dll");
 
    zstd::stream::copy_decode(&sciter[..], File::create(&tmp_file)?)?;
 
    let path = &tmp_file
        .into_os_string()
        .into_string()
        .or(Err(anyhow::anyhow!(
            "Couldn't convert temp file into appropriate path"
        )))?;
 
    tmp_dir.into_path();
 
    Ok(path.to_owned())
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎