add walkdir source
parent
b9b9fc393c
commit
98565b175c
|
|
@ -2,6 +2,12 @@ local fs = require("filesystem")
|
||||||
|
|
||||||
local root = fs.directory(".")
|
local root = fs.directory(".")
|
||||||
|
|
||||||
|
string.starts_with = function(self, str)
|
||||||
|
return self:find('^' .. str) ~= nil
|
||||||
|
end
|
||||||
|
|
||||||
for entry in root do
|
for entry in root do
|
||||||
print(entry)
|
if not entry.rel_path:starts_with("%.") then
|
||||||
|
print(entry.rel_path)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::driver_filesystem::filesystem_resource::FilesystemResourceLocation;
|
use crate::driver_filesystem::filesystem_resource::FilesystemResourceLocation;
|
||||||
use crate::resource::{DynResource, DynResourceLocation, Resource, ResourceLocation};
|
use crate::resource::{DynResource, DynResourceLocation, Resource, ResourceLocation};
|
||||||
use crate::source::ResourceSource;
|
use crate::source::ResourceSource;
|
||||||
|
use std::fs::rename;
|
||||||
use std::io::Sink;
|
use std::io::Sink;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
@ -31,7 +32,7 @@ impl Iterator for DirectorySource {
|
||||||
self.iter
|
self.iter
|
||||||
.next()
|
.next()
|
||||||
.map(|entry| entry.unwrap())
|
.map(|entry| entry.unwrap())
|
||||||
.map(|entry| entry.path().to_path_buf())
|
.map(|entry| entry.path().strip_prefix("./").unwrap().to_path_buf())
|
||||||
.map(|entry| {
|
.map(|entry| {
|
||||||
let loc = FilesystemResourceLocation::from(entry);
|
let loc = FilesystemResourceLocation::from(entry);
|
||||||
Box::new(loc) as Box<dyn ResourceLocation>
|
Box::new(loc) as Box<dyn ResourceLocation>
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,3 @@ use mlua::{MetaMethod, UserData, UserDataFields, UserDataMethods};
|
||||||
|
|
||||||
mod resource_bindings;
|
mod resource_bindings;
|
||||||
mod source_bindings;
|
mod source_bindings;
|
||||||
|
|
||||||
impl UserData for DynResourceLocation {
|
|
||||||
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
|
|
||||||
methods.add_meta_method_mut(MetaMethod::ToString, |lua, this, _: ()| Ok(this.location()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
use crate::resource::DynResourceLocation;
|
||||||
|
use mlua::{MetaMethod, UserData, UserDataFields, UserDataMethods};
|
||||||
|
|
||||||
|
impl UserData for DynResourceLocation {
|
||||||
|
fn add_fields<'lua, F: UserDataFields<'lua, Self>>(fields: &mut F) {
|
||||||
|
fields.add_field_method_get("rel_path", |lua, this| Ok(this.location()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
|
||||||
|
methods.add_meta_method_mut(MetaMethod::ToString, |lua, this, _: ()| Ok(this.location()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue