Secure temporary file: Difference between revisions
Content added Content deleted
Line 141: | Line 141: | ||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
<lang PureBasic>Procedure.s TempFile() |
<lang PureBasic>Procedure.s TempFile() |
||
Protected a,Result$ |
Protected a, Result$ |
||
For a=0 To 9999 |
For a = 0 To 9999 |
||
Result$=GetTemporaryDirectory()+StringField(GetFilePart(ProgramFilename()),1,".") |
Result$ = GetTemporaryDirectory() + StringField(GetFilePart(ProgramFilename()),1,".") |
||
Result$+"_"+Str(ElapsedMilliseconds())+"_("+RSet(Str(a),4,"0")+").tmp" |
Result$ + "_" + Str(ElapsedMilliseconds()) + "_(" + RSet(Str(a),4,"0") + ").tmp" |
||
If FileSize(Result$)=-1 |
If FileSize(Result$) = -1 ; -1 = File not found |
||
ProcedureReturn Result$ |
ProcedureReturn Result$ |
||
EndIf |
EndIf |
||
Next |
Next |
||
ProcedureReturn "" |
|||
EndProcedure |
EndProcedure |
||
Define File, File$ |
Define File, File$ |
||
File$=TempFile() |
File$ = TempFile() |
||
⚫ | |||
File=CreateFile(#PB_Any,File$) |
File = CreateFile(#PB_Any, File$) |
||
⚫ | |||
If File <> 0 |
|||
WriteString(File,"Some temporary data here...") |
WriteString(File, "Some temporary data here...") |
||
CloseFile(File) |
|||
CloseFile(File) |
|||
EndIf |
|||
EndIf</lang> |
EndIf</lang> |
||