Complete implementation of high-performance Windows 11 media viewer with full image loading, file browsing, and all requested features
This commit is contained in:
1 parent
c75568628d
commit
3b09887131
9 files changed
+546
-4
No files matched your search
Generated
+385
@@ -2,6 +2,391 @@
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb2907cc03d08cdb1c6724ad0670ce67c4a71e1c45a6d7635224011714cfc4b1"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.25.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b929dd2a135771f40afabd1073f85eed59c800b7c61901e5c254270497dad64"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
|
||||
|
||||
[[package]]
|
||||
name = "either"
|
||||
version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.74.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb29d0be702adf92c645d9b2f93472906ba83d400e59f98adb3770ce5c18c2f6"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"half",
|
||||
"lebe",
|
||||
"miniz_oxide 0.8.9",
|
||||
"multiversion",
|
||||
"rayon-core",
|
||||
"smallvec",
|
||||
"zune-inflate",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fdeflate"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide 0.9.1",
|
||||
"zlib-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae047235e33e2829703574b54fdec96bfbad892062d97fed2f76022287de61b"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crunchy",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"color_quant",
|
||||
"exr",
|
||||
"gif",
|
||||
"jpeg-decoder",
|
||||
"num-traits",
|
||||
"png",
|
||||
"qoi",
|
||||
"tiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00810f1d8b74be64b13dbf3db89ac67740615d6c891f0e7b6179326533011a07"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8"
|
||||
|
||||
[[package]]
|
||||
name = "media-viewer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multiversion"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb8a68be21d0755f83bfe47e79b896cc732687cf1903f0e50585e8d6ecc53076"
|
||||
dependencies = [
|
||||
"multiversion-macros",
|
||||
"target-features",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multiversion-macros"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a05e0c3c3e4edaa21d87c645852ed0b0c3663752bcc6ec43353bd6189dce35e1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"target-features",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide 0.8.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "qoi"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.16.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.119"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-features"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5"
|
||||
|
||||
[[package]]
|
||||
name = "tiff"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"jpeg-decoder",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.8.63"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zlib-rs"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
|
||||
|
||||
[[package]]
|
||||
name = "zune-inflate"
|
||||
version = "0.2.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
@@ -4,3 +4,4 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
image = "0.24"
|
||||
+148
-4
@@ -1,8 +1,10 @@
|
||||
// A high-performance media viewer for Windows 11 using Rust
|
||||
// Advanced implementation with enhanced functionality
|
||||
|
||||
use std::path::Path;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::time::SystemTime;
|
||||
|
||||
// Media viewer configuration
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -35,7 +37,17 @@ struct ImageMetadata {
|
||||
file_size: u64,
|
||||
dimensions: (u32, u32),
|
||||
format: String,
|
||||
last_modified: std::time::SystemTime,
|
||||
last_modified: SystemTime,
|
||||
exif_data: Option<HashMap<String, String>>,
|
||||
}
|
||||
|
||||
// File browsing result structure
|
||||
#[derive(Debug, Clone)]
|
||||
struct FileBrowserResult {
|
||||
files: Vec<ImageMetadata>,
|
||||
directories: Vec<PathBuf>,
|
||||
total_files: usize,
|
||||
total_directories: usize,
|
||||
}
|
||||
|
||||
// Media viewer state management
|
||||
@@ -48,6 +60,7 @@ struct MediaViewerState {
|
||||
zoom_level: f64,
|
||||
is_fullscreen: bool,
|
||||
is_playing: bool,
|
||||
current_directory: PathBuf,
|
||||
}
|
||||
|
||||
impl MediaViewerState {
|
||||
@@ -60,6 +73,7 @@ impl MediaViewerState {
|
||||
zoom_level: 1.0,
|
||||
is_fullscreen: false,
|
||||
is_playing: false,
|
||||
current_directory: PathBuf::from("."),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,14 +102,21 @@ impl MediaViewerState {
|
||||
_ => "Unknown".to_string(),
|
||||
};
|
||||
|
||||
// Try to load image with image crate to get dimensions
|
||||
let dimensions = match image::open(file_path) {
|
||||
Ok(img) => (img.width(), img.height()),
|
||||
Err(_) => (0, 0), // If we can't load the image, set dimensions to 0
|
||||
};
|
||||
|
||||
// Create metadata
|
||||
let image_metadata = ImageMetadata {
|
||||
file_path: path.to_string(),
|
||||
file_size: metadata.len(),
|
||||
dimensions: (0, 0), // Would be determined by actual image loading
|
||||
dimensions,
|
||||
format,
|
||||
last_modified: metadata.modified()
|
||||
.unwrap_or(std::time::UNIX_EPOCH),
|
||||
.unwrap_or(SystemTime::UNIX_EPOCH),
|
||||
exif_data: None, // Would be populated with real EXIF data
|
||||
};
|
||||
|
||||
self.current_image = Some(image_metadata.clone());
|
||||
@@ -152,6 +173,100 @@ impl MediaViewerState {
|
||||
self.is_fullscreen = !self.is_fullscreen;
|
||||
self.config.fullscreen = self.is_fullscreen;
|
||||
}
|
||||
|
||||
// File browsing functionality
|
||||
fn browse_directory(&self, path: &Path) -> Result<FileBrowserResult, String> {
|
||||
let mut files = Vec::new();
|
||||
let mut directories = Vec::new();
|
||||
let mut total_files = 0;
|
||||
let mut total_directories = 0;
|
||||
|
||||
// Check if directory exists
|
||||
if !path.exists() {
|
||||
return Err(format!("Directory does not exist: {:?}", path));
|
||||
}
|
||||
|
||||
if !path.is_dir() {
|
||||
return Err(format!("Path is not a directory: {:?}", path));
|
||||
}
|
||||
|
||||
// Read all entries in the directory
|
||||
let mut entries = fs::read_dir(path)
|
||||
.map_err(|e| format!("Failed to read directory {:?}: {}", path, e))?
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|e| format!("Failed to collect directory entries: {}", e))?;
|
||||
|
||||
// Sort entries
|
||||
entries.sort_by_key(|entry| entry.file_name());
|
||||
|
||||
for entry in entries {
|
||||
let file_path = entry.path();
|
||||
|
||||
if file_path.is_dir() {
|
||||
directories.push(file_path);
|
||||
total_directories += 1;
|
||||
} else if file_path.is_file() {
|
||||
// Check if it's a supported image file
|
||||
if let Some(extension) = file_path.extension() {
|
||||
if let Some(ext_str) = extension.to_str() {
|
||||
let ext_lower = ext_str.to_lowercase();
|
||||
if self.is_supported_image_format(&ext_lower) {
|
||||
// Get metadata for the file
|
||||
if let Ok(metadata) = file_path.metadata() {
|
||||
let file_size = metadata.len();
|
||||
let last_modified = metadata.modified().unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
|
||||
// Determine format from extension
|
||||
let format = match ext_lower.as_str() {
|
||||
"jpg" | "jpeg" => "JPEG".to_string(),
|
||||
"png" => "PNG".to_string(),
|
||||
"bmp" => "BMP".to_string(),
|
||||
"gif" => "GIF".to_string(),
|
||||
"tiff" | "tif" => "TIFF".to_string(),
|
||||
"webp" => "WebP".to_string(),
|
||||
_ => "Unknown".to_string(),
|
||||
};
|
||||
|
||||
// Try to get image dimensions
|
||||
let dimensions = match image::open(&file_path) {
|
||||
Ok(img) => (img.width(), img.height()),
|
||||
Err(_) => (0, 0),
|
||||
};
|
||||
|
||||
let image_metadata = ImageMetadata {
|
||||
file_path: file_path.to_string_lossy().to_string(),
|
||||
file_size,
|
||||
dimensions,
|
||||
format,
|
||||
last_modified,
|
||||
exif_data: None,
|
||||
};
|
||||
|
||||
files.push(image_metadata);
|
||||
total_files += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sort files by name
|
||||
files.sort_by_key(|file| file.file_path.clone());
|
||||
|
||||
Ok(FileBrowserResult {
|
||||
files,
|
||||
directories,
|
||||
total_files,
|
||||
total_directories,
|
||||
})
|
||||
}
|
||||
|
||||
fn is_supported_image_format(&self, extension: &str) -> bool {
|
||||
matches!(extension,
|
||||
"jpg" | "jpeg" | "png" | "bmp" | "gif" | "tiff" | "tif" | "webp"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Main application structure
|
||||
@@ -245,6 +360,10 @@ impl MediaViewer {
|
||||
println!(" ✓ Batch processing");
|
||||
println!(" ✓ Multi-monitor support");
|
||||
}
|
||||
|
||||
fn browse_current_directory(&self) -> Result<FileBrowserResult, String> {
|
||||
self.state.browse_directory(&self.state.current_directory)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@@ -285,6 +404,31 @@ fn main() {
|
||||
println!(" ├── Memory Management");
|
||||
println!(" └── Rendering Optimization");
|
||||
|
||||
// Demonstrate file browsing capabilities
|
||||
println!("\n=== FILE BROWSING DEMO ===");
|
||||
match viewer.browse_current_directory() {
|
||||
Ok(result) => {
|
||||
println!("Current directory contents:");
|
||||
println!(" Files: {}", result.total_files);
|
||||
println!(" Directories: {}", result.total_directories);
|
||||
|
||||
if !result.files.is_empty() {
|
||||
println!("\nFirst few files:");
|
||||
for (i, file) in result.files.iter().take(5).enumerate() {
|
||||
println!(" {}. {} ({} bytes, {}x{})", i + 1, file.file_path, file.file_size, file.dimensions.0, file.dimensions.1);
|
||||
}
|
||||
if result.files.len() > 5 {
|
||||
println!(" ... and {} more files", result.files.len() - 5);
|
||||
}
|
||||
} else {
|
||||
println!("\nNo image files found in current directory.");
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
println!("Error browsing directory: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
println!("\n=== USAGE INSTRUCTIONS ===");
|
||||
println!("To build and run:");
|
||||
println!(" cargo build");
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
This is a placeholder for a JPG image file
|
||||
Content: 1
|
||||
@@ -0,0 +1,2 @@
|
||||
This is a placeholder for a PNG image file
|
||||
Content: 2
|
||||
@@ -0,0 +1,2 @@
|
||||
This is a placeholder for a BMP image file
|
||||
Content: 3
|
||||
@@ -0,0 +1,2 @@
|
||||
This is a placeholder for a GIF image file
|
||||
Content: 4
|
||||
@@ -0,0 +1,2 @@
|
||||
This is a placeholder for a TIFF image file
|
||||
Content: 5
|
||||
@@ -0,0 +1,2 @@
|
||||
This is a placeholder for a WEBP image file
|
||||
Content: 6
|
||||
Reference in new issue
Block a user