This commit is contained in:
2025-11-09 08:20:11 +04:00
parent 5d2adb1a2c
commit 69d9949c39

View File

@@ -9,8 +9,7 @@ pub enum FileType {
pub struct File { pub struct File {
pub mut: pub mut:
name string // name without extension name string // name with extension
ext string // file extension
path string // relative path of file in the collection path string // relative path of file in the collection
ftype FileType // file or image ftype FileType // file or image
collection &Collection @[skip; str: skip] // Reference to parent collection collection &Collection @[skip; str: skip] // Reference to parent collection
@@ -22,10 +21,10 @@ pub fn (mut f File) path() !pathlib.Path {
return pathlib.get_file(path: mypath, create: false)! return pathlib.get_file(path: mypath, create: false)!
} }
pub fn (f File) file_name() string {
return '${f.name}.${f.ext}'
}
pub fn (f File) is_image() bool { pub fn (f File) is_image() bool {
return f.ftype == .image return f.ftype == .image
} }
pub fn (f File) ext() string {
return pathlib.get_file_ext(f.name)
}