|
<%
'#################################################################################
'## Copyright (C) 2003 Rick Eastes
'##
'## This program is free software; you can redistribute it and/or
'## modify it under the terms of the GNU General Public License
'## as published by the Free Software Foundation; either version 2
'## of the License, or any later version.
'##
'## All copyright notices regarding EzyEdit
'## must remain intact in the scripts and in the outputted HTML
'## The "powered by" text/logo with a link back to
'## http://www.ezyedit.com in the footer of the pages MUST
'## remain visible when the pages are viewed on the internet or intranet.
'##
'## This program is distributed in the hope that it will be useful,
'## but WITHOUT ANY WARRANTY; without even the implied warranty of
'## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
'## GNU General Public License for more details.
'##
'## You should have received a copy of the GNU General Public License
'## along with this program; if not, write to the Free Software
'## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'##
'## Support can be obtained from support forums at:
'## http://www.ezyedit.com/forum
'##
'## Correspondence and Marketing Questions can be sent to:
'## rick@ezyedit.com
'## 191 Dorville Rd Carseldine.
'## Brisbane, Australia. 4034
'##
'#################################################################################
Function DeleteCache
Session("FSO").DeleteFolder server.MapPath(site & "content/cache/"),true
Session("FSO").CreateFolder server.MapPath(site & "content/cache/")
End Function
Function DeleteIfExists (FilePath)
Dim blnDeleted
deleted = false
if Session("FSO").FileExists (Filepath) then
Session("FSO").DeleteFile (Filepath)
blnDeleted = true
End if
DeleteIfExists = blnDeleted
End Function
Function FileExists(FilePath)
if Session("FSO").FileExists (Filepath) then
FileExists = true
else
FileExists = false
End if
End Function
' FillSelectFromDir
' e.g usage.
' strImages = "../graphics/product"
' <select name="selPicture">
' <%=FillSelectFromDir(Server.MapPath(strImages), "", "none", "")% >
' </select>
Function DirListing(DirPath)
'Returns an array of directory names in the DirPath
set DirListing = (Session("FSO").getFolder(DirPath)).SubFolders
End Function
Function FileListing(DirPath)
'Returns an array of file names in the DirPath
' Dim FSO
set FileListing = (Session("FSO").getFolder(DirPath)).files
End Function
Function GetFilename (strFile)
GetFilename = Mid(strFile, InstrRev(strFile, "\")+1)
End Function
Function AbsPath(RelativePath)
'Converts a relative path to an absolute path
AbsPath = Server.MapPath(RelativePath)
End Function
function GetFileHandle(txtfile)
'returns a file object
dim objFile
set objFile = Session("FSO").GetFile(txtfile)
set GetFileHandle = objFile
end function
function CreateFile(strFileName,data)
dim objFile
set objFile = Session("FSO").CreateTextFile(server.MapPath(strFileName),true,false)
result = objFile.Write(data) 'write new contents to the file
objFile.Close 'save and close file
CreateFile = result
end function
function SetExtension(strFileName,extension)
'Check existing file extension (if one exists) and give it specified file extension.
strCurrExtension = right(strFileName,len(extension))
if(strCurrExtension = extension)then
SetExtension = strFileName
else
SetExtension = strFileName & "." & extension
end if
end function
function GetFileContents(txtfile)
dim objFile, strContents
set objFile = GetFileHandle(server.MapPath(txtfile))
Dim TextStream
Set TextStream = objFile.OpenAsTextStream(1, -2)
' Read the file line by line
Do While Not TextStream.AtEndOfStream
strContents = strContents & TextStream.readline & vbCRLF
Loop
'FSO.Close
GetFileContents = strContents
end function
%>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
From Brisbane, Australia.
Likes building stuff.