Another Clstemp

Class TempDir

Private vorlagenpath As String

Declare Private Function checkDir( path As String ) As Integer
Declare Private Function CreateDir( Byval path As String ) As Integer

'**************************************************
' Property: T e m p D i r
'**************************************************
Private Property Get TempDir As String

Dim tmp As String

tmp = Environ( "TEMP" )
If tmp = "" Then
tmp = Environ( "TMP" )
If tmp = "" Then
' wenn man schon keinen Temp-Pfad ermitteln kann, dann immer auf C: schreiben
tmp = "C:"
End If
End If

TempDir = tmp

End Property

'**************************************************
' Property: T e m p F i l e n a m e
'**************************************************
Public Property Get TempFilename As String

Dim result As Variant

result = Evaluate( randomstring$ )

TempFilename = result( 0 )

End Property

'**************************************************
' Property: T e m p P a t h
'**************************************************
Public Property Get TempPath As String

Dim tmp As String

tmp = Me.TempDir + Me.vorlagenpath

' �berpr�fen
If Not Me.CheckDir( tmp ) Then
' Pfad nicht vorhanden, dann anlegen
If Not Me.CreateDir( tmp ) Then
Error CErr_NoTmpDirectory%, CErr_txt_NoTmpDirectory$
End If
End If

TempPath = tmp

End Property

'**************************************************
' Function: C h a n g e D i r
'**************************************************
Private Function ChangeDir( tmppath As String ) As Integer

ChangeDir = False

On Error Goto ErrorHandler

Chdir tmppath

ChangeDir = True

ExitFunction:

Exit Function

ErrorHandler:

Resume ExitFunction

End Function

'**************************************************
' Function: C h e c k D i r
'**************************************************
Private Function checkDir( path As String ) As Integer

On Error Resume Next

CheckDir = False

Chdrive Left( path, 1 )
Chdir path

If Curdir = path Then
CheckDir = True
End If

End Function

'**************************************************
' Function: CreateDir
'**************************************************
Private Function CreateDir( Byval path As String ) As Integer

Dim pos As Integer
Dim tmppath As String

On Error Goto ErrorHandler

CreateDir = False

path = path + ""

' Laufwerk ausw�hlen
pos = Instr( 1, path, "" )
Chdrive( Left( path, pos - 1 ) )
pos = pos + 1

While pos <> 0
pos = Instr( pos, path, "" )
If pos > 0 Then
tmpPath = Left( path, pos - 1 )
If Not Me.ChangeDir( tmppath ) Then
Mkdir tmppath
Chdir tmppath
End If
pos = pos + 1
End If
Wend

If Curdir = Left$( path, Len( path ) - 1 ) Then
CreateDir = True
End If

EndFunction:

Exit Function

ErrorHandler:

Resume EndFunction

End Function

'**************************************************
' Function: C l e a r T m p D i r
'**************************************************
Public Sub ClearTmpDir( path As String, filetype As String )

Dim filename As String

On Error Resume Next

' nur leeren, wenn es auch vorhanden ist
If Me.CheckDir( path ) Then

filename = Dir$( path + "*" + filetype )

While Not filename = ""
Kill path + "" + filename
filename = Dir$( )
Wend

End If

End Sub

'**************************************************
' Sub: New
'**************************************************
Sub New( )

 

End Sub

End Class

This was first published in November 2000

Dig deeper on Domino Resources - Part 2

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close