use sf_open_fd

This commit is contained in:
Luna 2019-10-22 18:57:36 -03:00
parent 2d64eaa3ef
commit 6e66850d90
2 changed files with 6 additions and 3 deletions

View file

@ -1,3 +1,3 @@
load :0; load :0;
embed 3 1 ./file.mp3 embed 3 1 file.mp3
quicksave; quicksave;

View file

@ -31,14 +31,17 @@ pub fn sopen(
var cstr_path = try std.cstr.addNullByte(allocator, path); var cstr_path = try std.cstr.addNullByte(allocator, path);
defer allocator.free(cstr_path); defer allocator.free(cstr_path);
var file = c.sf_open(cstr_path.ptr, mode, fmt); var fs_file = try std.fs.File.openRead(path);
var file = c.sf_open_fd(fs_file.handle, mode, fmt, 1);
const st: i32 = c.sf_error(file); const st: i32 = c.sf_error(file);
if (st != 0) { if (st != 0) {
var msg = c.sf_error_number(st);
std.debug.warn( std.debug.warn(
"Failed to open {} ({})\n", "Failed to open {} ({})\n",
path, path,
c.sf_error_number(st), msg[0..std.mem.len(u8, msg)],
); );
return ImageError.OpenFail; return ImageError.OpenFail;