|
of_dirlist
|
|
Full name
|
pfc_n_cst_filesrvsol2.of_dirlist
|
Access
|
public
|
Extend of
|
long
|
Return value
|
long
|
Prototype
|
public function long of_dirlist(string,long,ref n_cst_dirattrib[])
|
Name
|
Datatype
|
lb_Found
|
boolean
|
lc_Drive
|
char
|
ll_Cnt
|
long
|
ll_Entries
|
long
|
lnv_Empty
|
n_cst_dirattrib[]
|
lnv_Numeric
|
n_cst_numerical
|
lstr_FindData
|
os_finddata
|
lt_Time
|
time
|
lul_handle
|
ulong
|
public function long of_dirlist (string as_filespec, long al_filetype, ref n_cst_dirattrib anv_dirlist[]);//////////////////////////////////////////////////////////////////////////////
// Public Function: of_DirList
// Arguments: as_FileSpec The file spec. to list (including wildcards); an
// absolute path may be specified or it will
// be relative to the current working directory
// al_FileType A number representing one or more types of files
// to include in the list, see PowerBuilder Help on
// the DirList listbox function for an explanation.
// anv_DirList[] An array of n_cst_dirattrib structure whichl will contain
// the results, passed by reference.
// Returns: Integer
// The number of elements in anv_DirList if successful, -1 if an error occurrs.
// Description: List the contents of a directory (Name, Date, Time, and Size).
//////////////////////////////////////////////////////////////////////////////
// Rev. History: Version
// 5.0.02 Initial version
// 7.0 Changed return datatype from int to long
// Changed 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.
//////////////////////////////////////////////////////////////////////////////
boolean lb_Found
char lc_Drive
long ll_Cnt, ll_Entries
ulong lul_handle
time lt_Time
os_finddata lstr_FindData
n_cst_dirattrib lnv_Empty[]
n_cst_numerical lnv_Numeric
// Empty the result array
anv_DirList = lnv_Empty
// List the entries in the directory
lul_handle = FindFirstFileA(as_FileSpec, lstr_FindData)
If lul_handle <= 0 Then Return -1
Do
// Determine if this file should be included.
If of_IncludeFile(String(lstr_FindData.ch_filename), al_FileType, lstr_FindData.ul_FileAttributes) Then
// Add it to the array
ll_Entries ++
anv_DirList[ll_Entries].is_FileName = lstr_FindData.ch_filename
anv_DirList[ll_Entries].is_AltFileName = lstr_FindData.ch_alternatefilename
If Trim(anv_DirList[ll_Entries].is_AltFileName) = "" Then
anv_DirList[ll_Entries].is_AltFileName = anv_DirList[ll_Entries].is_FileName
End If
// Set date and time
of_ConvertFileDatetimeToPB(lstr_FindData.str_CreationTime, anv_DirList[ll_Entries].id_CreationDate, &
anv_DirList[ll_Entries].it_CreationTime)
of_ConvertFileDatetimeToPB(lstr_FindData.str_LastAccessTime, anv_DirList[ll_Entries].id_LastAccessDate, lt_Time)
of_ConvertFileDatetimeToPB(lstr_FindData.str_LastWriteTime, anv_DirList[ll_Entries].id_LastWriteDate, &
anv_DirList[ll_Entries].it_LastWriteTime)
// Calculate file size
anv_DirList[ll_Entries].idb_FileSize = (lstr_FindData.ul_FileSizeHigh * (2.0 ^ 32)) + lstr_FindData.ul_FileSizeLow
// Set file attributes
anv_DirList[ll_Entries].ib_ReadOnly = lnv_Numeric.of_getbit(lstr_FindData.ul_FileAttributes, 1)
anv_DirList[ll_Entries].ib_Hidden = lnv_Numeric.of_getbit(lstr_FindData.ul_FileAttributes, 2)
anv_DirList[ll_Entries].ib_System = lnv_Numeric.of_getbit(lstr_FindData.ul_FileAttributes, 3)
anv_DirList[ll_Entries].ib_SubDirectory = lnv_Numeric.of_getbit(lstr_FindData.ul_FileAttributes, 5)
anv_DirList[ll_Entries].ib_Archive = lnv_Numeric.of_getbit(lstr_FindData.ul_FileAttributes, 6)
anv_DirList[ll_Entries].ib_Drive = False
// Put brackets around subdirectories
If anv_DirList[ll_Entries].ib_SubDirectory Then
anv_DirList[ll_Entries].is_FileName = "[" + anv_DirList[ll_Entries].is_FileName + "]"
anv_DirList[ll_Entries].is_AltFileName = "[" + anv_DirList[ll_Entries].is_AltFileName + "]"
End If
End If
lb_Found = FindNextFileA(lul_handle, lstr_FindData)
Loop Until Not lb_Found
FindClose(lul_handle)
// Add the drives if desired.
// If the type is > 32768 this was to prevent read-write files from being included.
If al_FileType >=32768 Then al_FileType = al_FileType - 32768
// If the type is > 16384, then a list of drives should be included
If al_FileType >= 16384 Then
For ll_Cnt = 0 To 25
lc_Drive = Char(ll_Cnt + 97)
If of_GetDriveType(lc_Drive) > 1 Then
ll_Entries ++
anv_DirList[ll_Entries].is_FileName = "[-" + lc_Drive + "-]"
anv_DirList[ll_Entries].is_AltFileName = anv_DirList[ll_Entries].is_FileName
anv_DirList[ll_Entries].ib_ReadOnly = False
anv_DirList[ll_Entries].ib_Hidden = False
anv_DirList[ll_Entries].ib_System = False
anv_DirList[ll_Entries].ib_SubDirectory = False
anv_DirList[ll_Entries].ib_Archive = False
anv_DirList[ll_Entries].ib_Drive = True
End if
Next
End if
Return ll_Entries
end function