mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
all: change optional to result of io (#16075)
This commit is contained in:
parent
6e46933c55
commit
f6844e9766
187 changed files with 1885 additions and 1874 deletions
|
@ -150,10 +150,10 @@ fn (item_list Item_list) get_file_path() string {
|
|||
* Scan functions
|
||||
*
|
||||
******************************************************************************/
|
||||
fn (mut item_list Item_list) scan_folder(path string, in_index int) ? {
|
||||
fn (mut item_list Item_list) scan_folder(path string, in_index int) ! {
|
||||
println('Scanning [$path]')
|
||||
mut folder_list := []string{}
|
||||
lst := os.ls(path)?
|
||||
lst := os.ls(path)!
|
||||
|
||||
// manage the single files
|
||||
for c, x in lst {
|
||||
|
@ -171,7 +171,7 @@ fn (mut item_list Item_list) scan_folder(path string, in_index int) ? {
|
|||
if ext == .zip {
|
||||
item.i_type = .zip
|
||||
item_list.lst << item
|
||||
item_list.scan_zip(pt, item_list.lst.len - 1)?
|
||||
item_list.scan_zip(pt, item_list.lst.len - 1)!
|
||||
continue
|
||||
}
|
||||
if is_image(ext) == true {
|
||||
|
@ -194,7 +194,7 @@ fn (mut item_list Item_list) scan_folder(path string, in_index int) ? {
|
|||
i_type: .folder
|
||||
}
|
||||
item_list.lst << item
|
||||
item_list.scan_folder(pt, item_list.lst.len - 1)?
|
||||
item_list.scan_folder(pt, item_list.lst.len - 1)!
|
||||
}
|
||||
// println(item_list.lst.len)
|
||||
// println("==================================")
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
import sokol.gfx
|
||||
import szip
|
||||
|
||||
fn (mut il Item_list) scan_zip(path string, in_index int) ? {
|
||||
fn (mut il Item_list) scan_zip(path string, in_index int) ! {
|
||||
println('Scanning ZIP [$path]')
|
||||
mut zp := szip.open(path, szip.CompressionLevel.no_compression, szip.OpenMode.read_only)?
|
||||
n_entries := zp.total()?
|
||||
mut zp := szip.open(path, szip.CompressionLevel.no_compression, szip.OpenMode.read_only)!
|
||||
n_entries := zp.total()!
|
||||
// println(n_entries)
|
||||
for index in 0 .. n_entries {
|
||||
zp.open_entry_by_index(index)?
|
||||
is_dir := zp.is_dir()?
|
||||
zp.open_entry_by_index(index)!
|
||||
is_dir := zp.is_dir()!
|
||||
name := zp.name()
|
||||
size := zp.size()
|
||||
// println("$index ${name} ${size:10} $is_dir")
|
||||
|
@ -47,7 +47,7 @@ fn (mut il Item_list) scan_zip(path string, in_index int) ? {
|
|||
zp.close()
|
||||
}
|
||||
|
||||
fn (mut app App) load_texture_from_zip() ?(gfx.Image, int, int) {
|
||||
fn (mut app App) load_texture_from_zip() !(gfx.Image, int, int) {
|
||||
item := app.item_list.lst[app.item_list.item_index]
|
||||
// println("Load from zip [${item.path}]")
|
||||
|
||||
|
@ -58,15 +58,15 @@ fn (mut app App) load_texture_from_zip() ?(gfx.Image, int, int) {
|
|||
}
|
||||
app.zip_index = item.container_index
|
||||
// println("Opening the zip [${item.path}]")
|
||||
app.zip = szip.open(item.path, szip.CompressionLevel.no_compression, szip.OpenMode.read_only)?
|
||||
app.zip = szip.open(item.path, szip.CompressionLevel.no_compression, szip.OpenMode.read_only)!
|
||||
}
|
||||
// println("Now get the image")
|
||||
app.zip.open_entry_by_index(item.container_item_index)?
|
||||
app.zip.open_entry_by_index(item.container_item_index)!
|
||||
zip_entry_size := int(item.size)
|
||||
|
||||
app.resize_buf_if_needed(zip_entry_size)
|
||||
|
||||
app.zip.read_entry_buf(app.mem_buf, app.mem_buf_size)?
|
||||
app.zip.read_entry_buf(app.mem_buf, app.mem_buf_size)!
|
||||
app.zip.close_entry()
|
||||
return app.load_texture_from_buffer(app.mem_buf, zip_entry_size)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue