lavender.software webring #2

Merged
char merged 5 commits from patch/webring into main 2022-03-05 15:00:48 +00:00
3 changed files with 15 additions and 33 deletions
Showing only changes of commit 3a8078c32e - Show all commits

View file

@ -1,21 +1,5 @@
use std::{fs, path::Path};
use crate::*;
fn copy_dir_recursive(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_recursive(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}
pub fn copy_assets(ctx: &BuildContext) -> Result<()> {
log_info("Copying assets…");
copy_dir_recursive(ctx.source_dir.join("assets"), ctx.output_dir.join("assets"))?;

View file

@ -1,5 +1,5 @@
use siru::prelude::*;
use std::{convert::TryInto, path::PathBuf, sync::Arc, time::Duration};
use std::{convert::TryInto, fs, path::Path, path::PathBuf, sync::Arc, time::Duration};
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
@ -27,6 +27,20 @@ impl SiruFS for BuildContext {
}
}
pub fn copy_dir_recursive(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_recursive(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}
fn build() {
let ctx = BuildContext {
source_dir: "src".try_into().unwrap(),

View file

@ -1,21 +1,5 @@
use std::{fs, path::Path};
use crate::*;
fn copy_dir_recursive(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
fs::create_dir_all(&dst)?;
for entry in fs::read_dir(src)? {
let entry = entry?;
let ty = entry.file_type()?;
if ty.is_dir() {
copy_dir_recursive(entry.path(), dst.as_ref().join(entry.file_name()))?;
} else {
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
}
}
Ok(())
}
pub fn copy_webring(ctx: &BuildContext) -> Result<()> {
log_info("Copying webring…");
copy_dir_recursive(