s
This commit is contained in:
1 parent
7e3a27cf6d
commit
e9c5ed9a4c
42 files changed
+2055
-4654
No files matched your search
Generated
+5165
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "native_media_viewer"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.104"
|
||||
eframe = "0.37.0"
|
||||
egui_extras = "0.37.0"
|
||||
image = "0.25.10"
|
||||
rfd = "0.18.0"
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use serde::Serialize;
|
||||
use anyhow::Result;
|
||||
|
||||
#[derive(Serialize, Clone, Debug)]
|
||||
pub struct FileInfo {
|
||||
pub name: String,
|
||||
pub path: String,
|
||||
pub is_dir: bool,
|
||||
pub extension: Option<String>,
|
||||
}
|
||||
|
||||
pub fn list_files(dir_path: &str) -> Result<Vec<FileInfo>> {
|
||||
let path = Path::new(dir_path);
|
||||
let mut files = Vec::new();
|
||||
|
||||
if path.is_dir() {
|
||||
for entry in fs::read_dir(path)? {
|
||||
let entry = entry?;
|
||||
let metadata = entry.metadata()?;
|
||||
let file_name = entry.file_name().to_string_lossy().into_owned();
|
||||
let file_path = entry.path().to_string_lossy().into_owned();
|
||||
|
||||
files.push(FileInfo {
|
||||
name: file_name,
|
||||
path: file_path,
|
||||
is_dir: metadata.is_dir(),
|
||||
extension: entry.path().extension().map(|s| s.to_string_lossy().into_owned()),
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(files)
|
||||
}
|
||||
Reference in new issue
Block a user