equivalent to SetEndOfFile_()?
Posted: Tue Nov 26, 2019 5:49 pm
Hello:
is there any equivalent to the win api SetEndOfFile_()?
thanks
is there any equivalent to the win api SetEndOfFile_()?
thanks
- a basic to master the web -
https://forums.spiderbasic.com/
The following function truncates the file at the current file pointer location (FileSeek()).morosh wrote:is there any equivalent to the win api SetEndOfFile_()?
Code: Select all
Procedure TruncateFile(file)
!var f;
!if (f = spider.file.objects.Get(v_file)) f.size = spider_Loc(v_file);
EndProcedure
file = CreateFile(#PB_Any,"",0)
If file
WriteString(file,"0123456789",#PB_Unicode)
Debug "Length of file: " + Lof(file)
Debug "Current file pointer: " + Loc(file)
FileSeek(file,8)
TruncateFile(file)
;WriteString(file,"Hello!",#PB_Unicode)
;WriteWord(file,0)
Debug "Length of file: " + Lof(file)
Debug "Current file pointer: " + Loc(file)
export = ExportFileMemory(file)
If export
Debug "-----"
Debug "Length of memory: " + MemorySize(export)
Debug PeekS(export,0,MemorySize(export),#PB_Unicode)
EndIf
CloseFile(file)
EndIf
Code: Select all
;
; SpiderBasic 2.30 - Delete a file that was created using '#PB_LocalStorage' flag.
;
; ref: https://localforage.github.io/localForage/
;
Procedure DeleteFile(filename.s, flag.i = #PB_LocalStorage)
If flag = #PB_LocalStorage
!LocalForage.removeItem("sbfs_" + v_filename);
EndIf
EndProcedure