Comments at http://www.powerbasic.com/support/pb...d.php?p=313824
Code:
#COMPILE EXE #DIM ALL #INCLUDE "WIN32API.INC" FUNCTION FileSize(BYVAL sFileName AS STRING) AS QUAD 'Bytes = FileSize(sFileName) returns file size or -1 if any error LOCAL FindData AS WIN32_FIND_DATA LOCAL hDir AS LONG hDir = FindFirstFile(BYVAL STRPTR(sFileName), FindData) IF hDir = -1 THEN 'if not found return -1 FUNCTION = -1 ELSE 'return number of bytes FindClose hDir 'Thank you, Pierre Bellisle FUNCTION = MAK(QUAD, FindData.nFileSizeLow , FindData.nFileSizeHigh) END IF END FUNCTION FUNCTION PBMAIN AS LONG 'Creating a file and kill after test LOCAL sTempFile AS STRING LOCAL Bytes AS QUAD LOCAL hFile AS LONG sTempFile = "\junk.tmp" 'modify this, file name (killed after test) Bytes = 5000000000 'modify this - bytes in sTempFile hFile = FREEFILE OPEN sTempFile FOR BINARY AS #hFile IF ERR THEN ? "Open error: " + $DQ+ sTempFile + $DQ + " error" + STR$(ERRCLEAR) ELSE SEEK #hFile, Bytes +1 'seek 1 byte larger to create correct size IF ERR THEN ? "SEEK error:" + STR$(ERRCLEAR) CLOSE #hFile ELSE SETEOF #hFile 'write new end of file IF ERR THEN ? "SETEOF error:" + STR$(ERRCLEAR) CLOSE #hFile END IF END IF ? "FileSize: " + FORMAT$(FileSize(sTempFile),"#,") 'test KILL sTempFile IF ERR THEN ? "Kill error:" + STR$(ERRCLEAR) + " " + $DQ + sTempFile + $DQ ELSE ? "Killed: " + $DQ + sTempFile + $DQ END IF SLEEP 1000 'for PB/CC users END FUNCTION