lavender.software webring #2
3 changed files with 15 additions and 33 deletions
|
@ -1,21 +1,5 @@
|
||||||
use std::{fs, path::Path};
|
|
||||||
|
|
||||||
use crate::*;
|
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<()> {
|
pub fn copy_assets(ctx: &BuildContext) -> Result<()> {
|
||||||
log_info("Copying assets…");
|
log_info("Copying assets…");
|
||||||
copy_dir_recursive(ctx.source_dir.join("assets"), ctx.output_dir.join("assets"))?;
|
copy_dir_recursive(ctx.source_dir.join("assets"), ctx.output_dir.join("assets"))?;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use siru::prelude::*;
|
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>>;
|
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() {
|
fn build() {
|
||||||
let ctx = BuildContext {
|
let ctx = BuildContext {
|
||||||
source_dir: "src".try_into().unwrap(),
|
source_dir: "src".try_into().unwrap(),
|
||||||
|
|
|
@ -1,21 +1,5 @@
|
||||||
use std::{fs, path::Path};
|
|
||||||
|
|
||||||
use crate::*;
|
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<()> {
|
pub fn copy_webring(ctx: &BuildContext) -> Result<()> {
|
||||||
log_info("Copying webring…");
|
log_info("Copying webring…");
|
||||||
copy_dir_recursive(
|
copy_dir_recursive(
|
||||||
|
|
Loading…
Reference in a new issue