Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fast file find with wildcards, optional date range, match # bytes, binary compare?
#4

.zip   qb64dir.zip (Size: 6.92 KB / Downloads: 107)
The 2 bas programs in the zip contain most of this
mdDir.bas is a bit like _Files$() but also does recursion and contains all attributes/timestamps/etc.
mdDiff.bas is high performance file compare (meant for text files, but you can use same logic for binary)

For big files (>1GB) you might want to use this function to speed things up:
Code: (Select All)
Function readBigFile~&& (file$) '1.5GB/sec
Const BLOCKSIZE = 4194304 '=64*65536 = 4 MB
If Not _FileExists(file$) Then Exit Function
Dim As _Unsigned _Integer64 fsize, blocks
fsize = fileSize(file$)
Dim mem As _MEM: mem = _MemNew(fsize + BLOCKSIZE)
Dim block As String * BLOCKSIZE '=64*65536
filenum% = FreeFile
Open file$ For Random Access Read As filenum% Len = BLOCKSIZE
blocks = fsize \ BLOCKSIZE: blocks = blocks - ((fsize Mod blocks) > 0)

$Checking:Off
For blck~& = 1 To blocks
Get filenum%, , block
_MemPut mem, mem.OFFSET + mpos~&&, block
mpos~&& = mpos~&& + BLOCKSIZE
Next blck~&
Close filenum%
'For c~&& = 0 To fsize - 1
' ch% = _MemGet(mem, mem.OFFSET + c~&&, _Unsigned _Byte)
' char~&&(ch%) = char~&&(ch%) + 1
'Next c~&&
$Checking:On
_MemFree mem
readBigFile~&& = fsize
End Function
45y and 2M lines of MBASIC>BASICA>QBASIC>QBX>QB64 experience
Reply


Messages In This Thread
RE: fast file find with wildcards, optional date range, match # bytes, binary compare? - by mdijkens - 12-19-2024, 12:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  find color of a pixel PhilOfPerth 8 764 10-09-2025, 05:20 PM
Last Post: SMcNeill
  BINARY FILE write pmackay 6 706 09-29-2025, 01:06 PM
Last Post: dakra137
  Command$(count%) - I can't get a value when using the optional argument "(count%)" Unatic 3 529 08-22-2025, 11:58 AM
Last Post: Unatic
  Out of range errors! Unseen Machine 4 560 08-17-2025, 04:11 AM
Last Post: Unseen Machine
  how to get a file's modified date/time and size in bytes? madscijr 36 7,787 05-10-2025, 05:17 AM
Last Post: eoredson

Forum Jump:


Users browsing this thread: 1 Guest(s)