Module: NTFS
- Extended by:
- DL::Importable
- Defined in:
- sample/stream.rb
Constant Summary collapse
- OPEN_EXISTING =
3
- GENERIC_READ =
0x80000000
- BACKUP_DATA =
0x00000001
- BACKUP_ALTERNATE_DATA =
0x00000004
- FILE_SHARE_READ =
0x00000001
- FILE_FLAG_BACKUP_SEMANTICS =
0x02000000
Constants included from DL::Importable
Class Method Summary collapse
Methods included from DL::Importable::Internal
#[], #_args_, #_retval_, #callback, #define_struct, #define_union, #dlload, #encode_argument_types, #extern, #import, #init_sym, #init_types, #parse_cproto, #symbol, #typealias
Class Method Details
.streams(filename) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'sample/stream.rb', line 29 def streams(filename) status = [] h = createFile(filename,GENERIC_READ,FILE_SHARE_READ,nil, OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,0) if( h != 0 ) begin # allocate the memory for backup data used in backupRead(). data = DL.malloc(DL.sizeof("L5")) data.struct!("LLLLL", :id, :attrs, :size_low, :size_high, :name_size) # allocate memories for references to long values used in backupRead(). context = DL.malloc(DL.sizeof("L")) lval = DL.malloc(DL.sizeof("L")) while( backupRead(h, data, data.size, lval, false, false, context) ) size = data[:size_low] + (data[:size_high] << (DL.sizeof("I") * 8)) case data[:id] when BACKUP_ALTERNATE_DATA stream_name = DL.malloc(data[:name_size]) backupRead(h, stream_name, stream_name.size, lval, false, false, context) name = stream_name[0, stream_name.size] name.tr!("\000","") if( name =~ /^:(.*?):.*$/ ) status.push([$1,size]) end when BACKUP_DATA status.push([nil,size]) else raise(RuntimeError, "unknown data type #{data[:id]}.") end l1 = DL.malloc(DL.sizeof("L")) l2 = DL.malloc(DL.sizeof("L")) if( !backupSeek(h, data[:size_low], data[:size_high], l1, l2, context) ) break end end ensure backupRead(h, nil, 0, lval, true, false, context) closeHandle(h) end return status else raise(RuntimeError, "can't open #{filename}.\n") end end |