1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: more ? -> ! fixes

This commit is contained in:
Delyan Angelov 2022-10-16 22:48:40 +03:00
parent 7302d8c4a8
commit 7ff7e540b9
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 18 additions and 18 deletions

View File

@ -10,14 +10,14 @@ fn main() {
files := os.args#[1..] files := os.args#[1..]
if files.len > 0 && files[0].starts_with('@') { if files.len > 0 && files[0].starts_with('@') {
lst_path := files[0].all_after('@') lst_path := files[0].all_after('@')
listed_files := os.read_file(lst_path)?.split('\n') listed_files := os.read_file(lst_path)!.split('\n')
process_files(listed_files)? process_files(listed_files)!
return return
} }
process_files(files)? process_files(files)!
} }
fn process_files(files []string) ? { fn process_files(files []string) ! {
mut table := ast.new_table() mut table := ast.new_table()
mut pref := pref.new_preferences() mut pref := pref.new_preferences()
pref.is_fmt = true pref.is_fmt = true

View File

@ -12,13 +12,13 @@ mut:
fn main() { fn main() {
if os.args.len < 2 { if os.args.len < 2 {
eprintln('Usage: play_wav file1.wav file2.wav ...') eprintln('Usage: play_wav file1.wav file2.wav ...')
play_sounds([os.resource_abs_path('uhoh.wav')])? play_sounds([os.resource_abs_path('uhoh.wav')])!
exit(1) exit(1)
} }
play_sounds(os.args[1..])? play_sounds(os.args[1..])!
} }
fn play_sounds(files []string) ? { fn play_sounds(files []string) ! {
mut player := Player{} mut player := Player{}
player.init() player.init()
for f in files { for f in files {
@ -31,7 +31,7 @@ fn play_sounds(files []string) ? {
eprintln('skipping "$f" (not a .wav file)') eprintln('skipping "$f" (not a .wav file)')
continue continue
} }
player.play_wav_file(f)? player.play_wav_file(f)!
} }
player.stop() player.stop()
} }
@ -65,9 +65,9 @@ fn (mut p Player) stop() {
p.free() p.free()
} }
fn (mut p Player) play_wav_file(fpath string) ? { fn (mut p Player) play_wav_file(fpath string) ! {
println('> play_wav_file: $fpath') println('> play_wav_file: $fpath')
samples := read_wav_file_samples(fpath)? samples := read_wav_file_samples(fpath)!
p.finished = true p.finished = true
p.samples << samples p.samples << samples
p.finished = false p.finished = false
@ -116,10 +116,10 @@ struct RIFFFormat {
sub_format [16]u8 // GUID sub_format [16]u8 // GUID
} }
fn read_wav_file_samples(fpath string) ?[]f32 { fn read_wav_file_samples(fpath string) ![]f32 {
mut res := []f32{} mut res := []f32{}
// eprintln('> read_wav_file_samples: $fpath -------------------------------------------------') // eprintln('> read_wav_file_samples: $fpath -------------------------------------------------')
mut bytes := os.read_bytes(fpath)? mut bytes := os.read_bytes(fpath)!
mut pbytes := &u8(bytes.data) mut pbytes := &u8(bytes.data)
mut offset := u32(0) mut offset := u32(0)
rh := unsafe { &RIFFHeader(pbytes) } rh := unsafe { &RIFFHeader(pbytes) }

View File

@ -13,24 +13,24 @@ for _ in 0 .. 3 {
} }
println('\nMaking dir "v_script_dir".') println('\nMaking dir "v_script_dir".')
mkdir('v_script_dir')? mkdir('v_script_dir')!
println("\nEntering into v_script_dir and listing it's files.") println("\nEntering into v_script_dir and listing it's files.")
chdir('v_script_dir')? chdir('v_script_dir')!
files := ls('.') or { panic(err) } files := ls('.') or { panic(err) }
println(files) println(files)
println('\nCreating foo.txt') println('\nCreating foo.txt')
create('foo.txt')? create('foo.txt')!
println('\nFiles:') println('\nFiles:')
again_ls := ls('.') or { panic(err) } again_ls := ls('.') or { panic(err) }
println(again_ls) println(again_ls)
println('\nRemoving foo.txt and v_script_dir') println('\nRemoving foo.txt and v_script_dir')
rm('foo.txt')? rm('foo.txt')!
chdir('../')? chdir('../')!
rmdir('v_script_dir')? rmdir('v_script_dir')!
print('\nDoes v_script_dir still exist? ') print('\nDoes v_script_dir still exist? ')
println(exists('v_script_dir')) println(exists('v_script_dir'))