graham Posted June 24, 2004 Posted June 24, 2004 (edited) Sometimes you want a temp scratch file & want to be sure that it does not exist... ;=============================================================================== ; ; Description: Generates a Fully qualified path of a temporary file, guaranteed not to exist ; Syntax: _GetTempFileName ($prefix, $drive, $directory, $extension) ; Parameter(s): IN - $drive, $directory, $extension - if specified, will be ; used in the generated full path, if blank, will be filled ; in from @TempDir. The file name part is always generated ; and consists numbers preceded by the $prefix parameter, ; if any. ; Requirement(s): None ; Return Value(s): Fully qualified path of a temporary file, guaranteed not to ; ; Author(s): Graham Keellings software@Keellings.com ; Note(s): None ; ;=============================================================================== Func _GetTempFileName ($prefix, $drive, $directory, $extension) Local $szDrive, $szDir, $szFName, $szExt, $fullPath _SplitPath(@TempDir & "\dummy.tmp", $szDrive, $szDir, $szFName, $szExt) if $drive <> "" then $szDrive = $drive endif if $directory <> "" then $szDir = $directory endif if $extension <> "" then $szExt = $extension endif do $fullPath = _MakePath($fullPath, $szDrive, $szDir, _ $prefix & Int(Random(1000000, 9999999)), $szExt) until FileExists($fullPath) = 0 return $fullPath EndFunc Edited June 24, 2004 by graham
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now