|
of_deltree
|
|
Full name
|
pfc_n_cst_filesrv.of_deltree
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_deltree(string)
|
Name
|
Datatype
|
li_RC
|
integer
|
ll_Cnt
|
long
|
ll_Entries
|
long
|
lnv_DirList
|
n_cst_dirattrib[]
|
ls_Directory
|
string
|
ls_Subdirectory
|
string
|
public function integer of_deltree (string as_directoryname);//////////////////////////////////////////////////////////////////////////////
// Public Function: of_DelTree
// Arguments: as_DirectoryName The name of the directory to be deleted; an
// absolute path may be specified or it will
// be relative to the current working directory
// Returns: Integer
// 1 if successful,
// -1 if an error occurrs.
// Description: Delete a directory and all its files and subdirectories. This
// function is recurrsive.
//////////////////////////////////////////////////////////////////////////////
// Rev. History: Version
// 5.0 Initial version
// 7.0 Changed datatype of li_Cnt, li_Entries from int to long
//////////////////////////////////////////////////////////////////////////////
// Copyright © 1996-1999 Sybase, Inc. and its subsidiaries. All rights reserved. Any distribution of the
// PowerBuilder Foundation Classes (PFC) source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//////////////////////////////////////////////////////////////////////////////
integer li_RC
long ll_Entries, ll_Cnt
string ls_Directory, ls_Subdirectory
n_cst_dirattrib lnv_DirList[]
If Not of_DirectoryExists(as_DirectoryName) Then Return 1
If Right(as_DirectoryName, 1) <> is_Separator Then
ls_Directory = as_DirectoryName + is_Separator
Else
ls_Directory = as_DirectoryName
End If
ll_Entries = of_DirList(ls_Directory + is_AllFiles, 55, lnv_DirList)
For ll_Cnt = 1 To ll_Entries
If lnv_DirList[ll_Cnt].ib_SubDirectory Then
// Recursively call this function to erase the subdirectory
// Skip [..]
If lnv_DirList[ll_Cnt].is_FileName <> "[..]" Then
// Remove [] from directory name
ls_SubDirectory = Mid(lnv_DirList[ll_Cnt].is_FileName, 2, &
(Len(lnv_DirList[ll_Cnt].is_FileName) - 2))
li_RC = of_DelTree(ls_Directory + ls_SubDirectory)
If li_RC < 0 Then
Return li_RC
End if
End if
Else
// Delete the file
If Not FileDelete(ls_Directory + lnv_DirList[ll_Cnt].is_FileName) Then
Return -1
End if
End if
Next
Return of_RemoveDirectory(as_DirectoryName)
end function