'========================================================================
' Fileops is a set functions to manipulate file names and paths.
' QUOTE - Returns a quoted string
' GetPATH - Returns file path (without file name)
' GetFILENAME - Returns file name (without path)
' GetFILEEXT - Returns file extension (like ".exe", ".html" etc.)
' GetFILENAMENOEXT - Returns file name without extension
' GetFULLPATHNOEXT - Returns full path without file extension
' SetPATH - Set file path (with the same file name)
' SetFILENAME - Set file name (with the same file path)
' SetFILEEXT - Set file extension (with the same file path and name)
'========================================================================
' QUOTE : Returns a quoted string
function Quote (StringToQuote as string) as string
StringToQuote = chr$(34) + StringToQuote + chr$(34)
result = replacesubstr$(stringtoquote, chr$(34) + chr$(34), chr$(34))
end function
'===============================================================================
' GetPATH : Returns file path (without file name)
Function GetPath (fullname as string) as string
result = left$(fullname, rinstr(fullname, "\"))
end function
'===============================================================================
' GetFILENAME : Returns file name (without path)
Function GetFileName (fullname as string) as string
result = right$(fullname, len(fullname) - rinstr(fullname, "\"))
end function
'===============================================================================
' GetFILEEXT : Returns file extension (like ".exe", ".html" etc.)
Function GetFileExt (fullname as string) as string
result = right$(fullname, len(fullname) - rinstr(fullname, ".") + 1)
end function
'===============================================================================
' GetFILENAMENOEXT : Returns file name without extension
function GetFileNameNoExt(fullname as string) as string
fullname = right$(fullname, len(fullname) - rinstr(fullname, "\"))
result = left$(fullname, rinstr(fullname, ".") - 1)
end function
'===============================================================================
' GetFULLPATHNOEXT : Returns full path without file extension
function GetFullPathNoExt(fullname as string) as string
result = left$(fullname, rinstr(fullname, ".") - 1)
end function
'===============================================================================
'# SetPATH : Set file path (without file name)
Function SetPath (fullname as string, newPath as
string) as long
if right$(newPath,1)<>"\" then newPath=newPath+"\"
fullname=newPath+getfilename(fullname)
end function
'===============================================================================
'# SetFILENAME : Set file name with old path
Function SetFileName (fullname as string, Newname as string) as integer
fullname=GetPath (fullname)+Newname
end function
'===============================================================================
'# SetFILEEXT : Set file extension
Function SetFileExt (fullname as string, Newext as string) as integer
fullname=GetFullPathNoExt(fullname)+Newext
end function
'=============================================================================== sub SubDirCopy (DirSrc$, DirDst$, mask$) 'Copy DirSrc$ directory with full subdir structure and files (by mask$) to DirDst$
'=============================================================================== sub DirCopy (DirSrc$, DirDst$, mask$) 'Copy files (by mask$) from DirSrc$ to DirDst$ '=============================================================================== sub KillFiles (FileName$) 'Kill files in FileName$ 'for example FileName$="C:\BAS\RAPIDQ\tmp\*.tmp" FName$ = DIR$(FileName$, 0) '-- Get first file while FName$ <>"" kill FName$ if fileexists (FName$)>0 then print "Can't kill file "+FName$ FName$ = DIR$ '-- Get next file wend end sub