code wiki / (root) / nx_torrent_extract.nx

nx_torrent_extract.nx

buildroot/runtime/nx_torrent_extract.nx

11732 B201 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic torrent
docsdependenciesstructsconstsfunctions

about

nx_torrent_extract.nx -- split a completed/partial download.part into the REAL files the torrent contains, per the metadata "files" list (multi-file) or "name" (single-file). This is what turns the opaque "download.part" the operator sees into a playable REBDB-1026...mkv. Reuses nx_bencode. STREAMING copy (1 MiB chunks -- never mmaps the multi-GB payload). For a PARTIAL download the missing pieces are zero-gaps in download.part, so the extracted media still plays ("most of a film" = the exceed axis). argv[1] = the torrent folder (must contain download.meta + download.part). license_tier: ORIGINAL module: nishi-core.torrent.extract depends: nishi-core.torrent.bencode capability: TORRENT_FILE_EXTRACT

dependencies 1 imports · 0 importers

nx_bencode.nx nx_torrent_extract.nx

imports: nx_bencode.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main ex_cat ex_slen ex_w sys_read nx_bc_dict_get sys_mmap nx_bc_str _bc_is_digit _bc_bytes_eq nx_bc_skip _bc_is_digit ↻ nx_bc_int _bc_is_digit ↻ nx_bc_str ↻ ex_mkdirs sys_mkdir ex_wn ex_copy_range sys_openat_wr sys_read ↻ nx_bc_skip ↻ ex_poster_walk ex_slen ↻ sys_getdents64 dirent_reclen dirent_type dirent_name ex_poster_walk ↻ ex_is_img ex_ends ex_slen ↻ ex_ends ↻ ex_fsize ex_lcname_has ex_slen ↻ ex_is_vid ex_ends ↻ ex_cat ↻ ex_copy_file

structs

none

consts

12const EX_MAGIC_1048576: i64 = 1048576
13const EX_MAGIC_65536: i64 = 65536
14const EX_MAGIC_2048: i64 = 2048
47const EX_NAME_BONUS: i64 = 1099511627776

functions

16func ex_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main
17func ex_wn(v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(1,"-" as *u8,1)} var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8; m=m/10; k=k+1} let b: *u8=sys_mmap(28); var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main
18func ex_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
19func ex_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+ex_slen(s) }
called by 2: ex_poster_walkmain calls 1: ex_slen
23func ex_mkdirs(path: *u8) -> i64
called by 1: main calls 1: sys_mkdir
33func ex_copy_range(srcfd: i64, start: i64, len: i64, dstpath: *u8) -> i64
called by 1: main calls 2: sys_openat_wrsys_read
48func ex_lcname_has(name: *u8, sub: *u8) -> i64
called by 1: ex_poster_walk calls 1: ex_slen
59func ex_ends(name: *u8, suf: *u8) -> i64
66func ex_is_vid(name: *u8) -> i64 { if ex_ends(name,".mp4" as *u8)==1 {return 1} if ex_ends(name,".mkv" as *u8)==1 {return 1} if ex_ends(name,".ts" as *u8)==1 {return 1} if ex_ends(name,".flv" as *u8)==1 {return 1} return 0 }
called by 1: ex_poster_walk calls 1: ex_ends
67func ex_is_img(name: *u8) -> i64 { if ex_ends(name,".jpg" as *u8)==1 {return 1} if ex_ends(name,".jpeg" as *u8)==1 {return 1} if ex_ends(name,".png" as *u8)==1 {return 1} return 0 }
called by 1: ex_poster_walk calls 1: ex_ends
68func ex_fsize(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0 {return 0-1} let s: i64=sys_lseek(fd,0,2); sys_close(fd); return s }
called by 1: ex_poster_walk
69func ex_copy_file(src: *u8, dst: *u8) -> i64
77func ex_poster_walk(dir: *u8, depth: i64, mode: i64, best: *u8, bestscore: *i64, madep: *i64) -> i64
136func main(argc: i64, argv: *i64) -> i64