$ PBExportHeader $ nvo_directory.sru $ PBExportComments $ directory manipulation classes forwardglobal type nvo_directory from nonvisualobjectend typetype stc_filetime from structure within nvo_directoryend typetype stc_fileopstruct from structure within nvo_directoryend typetype stc_browseinfo from structure within nvo_directoryend typetype stc_find_data from structure within nvo_directoryend typetype large_integer from structure within nvo_directoryend typetype stc_ofstruct from Structure with nvo_directorynd Typety SHFILEOPSTRUCT from Structure Withnin NVO_DIRECTORYEND TYPEEND FORWARD
TYPE STC_FILETIME FROM STRUCTURE UNSIGNEDLONG L_TIME UNSIGNEDLONG H_TIMEEND TYPE
TYPE STC_FILEOPSTRUCT FROM STRUCTURE UNSIGNEDLONG HWND UNSIGNEDLONG WFUNG HWND PFROM STRING PTO Long Fflags Long Fanyopertonsaborted long hnamemappings string lpszprogresstitlend Type
TYPE STC_BROWSEINFO from Structure Long Hwndowner Long Pidlroot String PszdisplayName String Lpsztitle Unsignedlong Ulflags Unsignedlong LPFN UNSIGNEDLONG LPARM Long iimagend Type
type stc_find_data from structure unsignedlong att stc_filetime c_time stc_filetime a_time stc_filetime w_time unsignedlong h_size unsignedlong l_size unsignedlong dwreserved0 unsignedlong dwreserved1 character cfilename [260] character calternatefilename [16] end type
Type Large_integer from Structure Unsignedlong LowPart Unsignedlong Highpart Teype
Type STC_OFSTRUCT from Structure Character Cbytes Character FFixedDisk Long Nerrcode Long Reserved1 Long Reserved2 Character Szpathname [128] End Type
type shfileopstruct from structure long hwnd unsignedlong wfunc long pfrom string pto unsignedlong fflags boolean fanyoperationsaborted long hnamemappings string lpszprogresstitleend typeglobal type nvo_directory from nonvisualobject autoinstantiateend type
type prototypesFUNCTION ulong GetCurrentDirectoryA (ulong BufferLen, ref string currentdir) LIBRARY "kernel32.dll" FUNCTION ulong SetCurrentDirectory (ref string lpPathName) LIBRARY "kernel32.dll" ALIAS FOR "SetCurrentDirectoryA" Function uLong GetModuleFileNameA (long hinstModule, Ref String lpszPath, uLong cchPath ) Library "kernel32.dll" FUNCTION ulong GetTempPath (ulong nBufferLength, ref string lpBuffer) LIBRARY "kernel32.dll" ALIAS FOR "GetTempPathA" Function boolean CreateDirectoryA (string lpPathName, string lpSecurityAttributes) Library "kernel32.dll" Function boolean RemoveDirectoryA (string lpPathName) Library "kernel32.dll" Function ulong GetTempPathA (ulong nBufferLength, ref string lpBuffer) Library "kernel32.dll" Function uint GetWindowsDirectoryA (ref string lpBuffer, uint uSize) Library "kernel32.dll" Function uint GetSystemDirectoryA (ref string lpBuffer, UINT USIZE "kernel32.dll" Function uint getDriveTypea (string lprootpathname) library "kernel32.dll" function ulong findclose (Ulong H) FindFile) LIBRARY "kernel32.dll" FUNCTION ulong FindFirstFile (ref string lpFileName, ref stc_FIND_DATA lpFindFileData) LIBRARY "kernel32.dll" ALIAS FOR "FindFirstFileA" FUNCTION ulong FindNextFile (ulong hFindFile, ref stc_FIND_DATA lpFindFileData) LIBRARY "kernel32.dll" ALIAS FOR "FindNextFileA" FUNCTION ulong SetFileAttributes (ref string lpFileName, ulong dwFileAttributes) LIBRARY "kernel32.dll" ALIAS FOR "SetFileAttributesA" FUNCTION boolean DeleteFileA (ref string filename) LIBRARY "kernel32.DLL"
Function boolean GetDiskFreeSpaceA (string lpRootPathName, ref ulong lpSectorsPerCluster, ref ulong lpBytesPerSector, ref ulong lpNumberOfFreeClusters, ref ulong lpTtoalNumberOfClusters) LIBRARY "kernel32.dll" Function boolean GetVolumeInformationA (string lpRootPathName, ref string lpVolumeNameBuffer, ulong nVolumeNameSize, ref ulong lpVolumeSerialNumber, ref ulong lpMaximumComponentLength , ref ulong lpFileSystemFlags, ref string lpFileSystemNameBuffer, ulong nFileSystemNameSize) LIBRARY "kernel32.dll" Function long SHFileOperation (stc_fileopstruct lpFileOp) Library "Shell32.dll" Alias for "SHFileOperationA" Function long SHBrowseForFolder (ref stc_BROWSEINFO lpBi) Library "shell32.dll" Function boolean SHGetPathFromIDList (long pIDL, ref String pszPath) Library "shell32.dll" Alias For "SHGetPathFromIDListA" FUNCTION ulong WNetAddConnection (ref string lpszNetPath, ref string lpszPassword, ref string lpszLocalName) LIBRARY "mpr.dll" ALIAS FOR "WNetAddConnectionA" FUNCTION Ulong WnetCancelConnection ref string lpszName, boolean bForce) LIBRARY "mpr.dll" ALIAS FOR "WNetCancelConnectionA" Function long SHFormatDrive (ulong hWnd, ulong iDrive, ulong iCapacity, ulong iType) Library "shell32.dll" function long MyZip_AddDirectory (ref string SrcPath, ref string ZipFile) library "myzip.dll" function long MyZip_ExtractFileAll (ref string zipfile, ref string pathname) library "myzip.dll" function boolean EncryptFile (ref string lpFileName) Library "ADVAPI32.dll" Alias for "EncryptFileA" function boolean DecryptFile (ref String lpfilename, long dwreserved) library "advapi32.dll" alias for "decryptfilea"
Function boolean MoveFileA (ref string lpExistingFileName, ref string lpNewFileName) LIBRARY "kernel32.dll" Function long GetDiskFreeSpaceExA (ref string lpRootPathName, ref large_integer lpFreeBytesAvailableToCaller, ref large_integer lpTotalNumberOfBytes, ref large_integer lpTotalNumberOfFreeBytes) Library "kernel32.dll" Function long GetFileAttributes (string lpFileName ) Library "kernel32.dll" Alias for "GetFileAttributesA" FUNCTION ulong FileTimeToDosDateTime (ref Stc_FILETIME lpFileTime, ref long lpFatDate, ref long lpFatTime) LIBRARY "kernel32.dll" FUNCTION ulong DosDateTimeToFileTime (ulong wFatDate, ulong wFatTime, ref Stc_FILETIME lpFileTime) LIBRARY " kernel32.dll "Function long GetLogicalDriveStrings (long nBufferLength, ref blob lpBuffer) Library" kernel32.dll "Alias for" GetLogicalDriveStringsA "Function long SHFileOperation (ref SHFILEOPSTRUCT lpFileOp) Library" shell32.dll "Alias for" SHFileOperationA "Function long RtlMoveMemory (rEF Char Destination [], long Source, long size) LIB rary "kernel32" Function long RtlMoveMemory (long Destination, REF Char Source [], long Size) library "kernel32" Function long LocalAlloc (long Flags, long Bytes) library "kernel32" Function long LocalFree (long MemHandle) library "kernel32" end prototypestype variablesprivate: string is_subdirs [], is_subfiles [] long il_subdirs_number, il_subfiles_number, il_directory_space = 0constant ulong FO_MOVE = 1constant ulong FO_COPY = 2constant ulong FO_DELETE = 3constant ulong FOF_ALLOWUNDO = 64constant ulong FOF_FILESONLY = 128 end variables
forward prototypespublic function string of_get_directory_current () public function long of_set_directory_current () public function long of_set_directory_current (string as_dir_name) public function string of_get_directory_app () public function string of_get_directory_temp () public function string of_get_directory_system () public function string of_get_directory_windows () public function string of_get_drive_type ( string as_rootpathname) public function string of_get_drive_cdrom () public function string of_directory_create_all (string as_directory) public function boolean of_directory_delete (string as_directory) public function long of_directory_no_recursion (string as_first_directory, string as_second_directory, ref stc_find_data as_file []) public function long of_directory_no_recursion (string as_directory, REF STC_FIND_DATA AS_FILE []) PUBLIC FUNCTION long of_directory_dir (string as_directory, boolean no_first_dir, ref stc_find_data as_file []) private function boolean of_set_file_attrib (s tring as_filename, boolean ab_readonly, boolean ab_hidden, boolean ab_system) private function boolean of_set_file_attrib (string as_filename, unsignedlong aul_attrib) private function boolean of_file_delete (string as_filename) public function boolean of_drive_isavailable (string as_drive) public function string of_get_drive_serialnumber (string as_drive) public function string of_get_drive_volumename (string as_drive) private function unsignedlong of_bitwiseor (unsignedlong aul_value1, unsignedlong aul_value2) private function string of_shbrowseforfolder (long alhparent, string asprompt, long alflags) public function string of_directory_browseforfolder (long alhparent,
string asprompt) public function string of_directory_browseforcomputer (long alhparent, string asprompt) public function string of_directory_browseforprinter (long alhparent, string asprompt) public function unsignedlong of_directory_netcancelconnection (ref string as_driver) public function boolean of_drive_format (character as_drive) private subroutine of_get_directory_subdirs (window aw_acton, string as_directory) public function long of_get_directory_subdirs (window aw_acton, string as_directory, ref string as_subdirs []) private subroutine of_get_directory_subfiles (window aw_acton, string as_directory) public function long of_get_directory_subfiles (window aw_acton, string as_directory, ref string as_subfiles []) public function long of_get_directory_capacity (window aw_window, string as_directory) protected function long of_get_directory_usedcapacity (string as_directory) private function unsignedlong of_bitwiseand (unsignedlong aul_value1, unsignedlong aul_value2) private function integer of _get_last_pos (string as_string1, string as_string2, integer ai_bz) public function long of_directory_uncompress (ref string as_documentname, ref string as_directory) public function long of_directory_compress (ref string as_directory, ref string as_newdocument) public function boolean of_directory_decrypt (ref string as_directory) public function boolean of_directory_encrypt (ref string as_directory) public function boolean of_directory_rename (ref string as_directory, ref string as_newname) public function boolean of_directory_create (string as_directory) public function boolean of_directory_isavailable (string as_directory) public function unsignedlong of_directory_netaddconnection (ref string as_directory, ref string as_pass,
ref string as_driver) public function double of_get_drive_totalspace (string as_drive) public function double of_get_drive_freespace (string as_drive) public function double of_get_drive_usedspace (string as_drive) public function string of_get_drive_filesystemname (string as_drive) public function string of_get_directory_attributes (string as_directory) public function datetime of_get_directory_createtime (string as_directory) public function datetime of_get_directory_writetime (string as_directory) public function datetime of_get_directory_accesstime (string as_directory) private function long of_makechar (readonly string asstrings [], ref character acchar []) public function string of_get_drive_list () private function boolean of_shfileoperation (ref shfileopstruct lpfileop) public function boolean of_directory_copy_all (readonly string asfrom [], readonly string asto) public function boolean of_directory_move_all (readonly string asfrom [], readonly string asto) public function boolean of_directory_ delete_all (readonly string asfrom []) public function boolean of_directory_move (ref string as_directory1, ref string as_directory2) end prototypespublic function string of_get_directory_current (); / * Function effect: Get the current folder name Return value: string * / string ls_curdirulong l_bufl_buf = 256ls_curdir = space (l_buf) getCurrentDirectorya (l_buf, ls_curdir) Return Ls_Curdirend Function
public function long of_set_directory_current (); string ls_dir_namels_dir_name = this.of_get_directory_app () return this.of_set_directory_current (mid (ls_dir_name, 1, lastpos (ls_dir_name, "/") - 1))
END FUNCTION
Public Function Long Of_set_directory_current (string as_dir_name); RETURN SETCURRENTDIRECTORY (AS_DIR_NAME) End Function
public function string of_get_directory_app (); / * function action: get the application files in the current run of the name of the return value: string * / long ll_RCString ls_AppPathlong ll_apphandlerll_apphandler = handle (GetApplication ()) ls_AppPath = Space (256) ll_RC = GetModuleFileNameA (ll_apphandler, ls_AppPath , 256) IF (ll_rc = 0) THEN LS_APPPPATH = "" RETURN LS_APPPPPPPPPPPPPPPPPATION FUNCTION
public function string of_get_directory_temp (); / * Function effect: acquiring system temporary folder name Return value: string * / ulong nBufferLength = 255string lpBufferlpbuffer = fill ( '', 255) GetTempPath (nBufferLength, lpBuffer) return lpbuffer
END FUNCTION
PUBLIC FUNCTION STRING OF_GET_DIRECTORY_SYSTEM (); / * Function Role: Get System Folder Name Return Value: String * / String Ls_bufferulong Ll_RequiredBuffersize
Ls_buffer = space (255) LL_RequiredBuffersize = GetSystemDirectorya (ls_buffer, 255)
IF ll_requiredbuffersize = 0 or ll_requiredbuffersize> 255 Then setnull (ls_buffer)
Return ls_buffer
END FUNCTION
Public function string of_get_directory_windows (); / * Function: Get a Windows folder name return value: string * / string ls_bufferulong ll_requiredbuffersize
Ls_buffer = space (255) LL_RequiredBuffersize = getWindowsDirectorya (ls_buffer, 255)
IF ll_requiredbuffersize = 0 or ll_requiredbuffersize> 255 Then setnull (ls_buffer)
Return Ls_Bufferend Function
public function string of_get_drive_type (string as_rootpathname); / * Function effect: Get the specified type of drive parameters: as_drive string drive Return Value: string * / string ls_DriveTypeas_RootPathName = Left (as_RootPathName, 1) ":" CHOOSE CASE GetDriveTypeA (as_RootPathName ) CASE 2 ls_DriveType = "REMOVABLE" CASE 3 ls_DriveType = "FIXED" CASE 4 ls_DriveType = "REMOTE" CASE 5 ls_DriveType = "CDROM" CASE 6 ls_DriveType = "RAMDISK" CASE ELSE SetNull (ls_DriveType) END CHOOSERETURN ls_DriveTypeend functionpublic function string of_get_drive_cdrom ( ); / * Function: Get the drive name return value of the optical drive: string * / integer li_i, li_start, li_endstring ls_cdroms = "" li_start = ASC ("A") for Li_Ind = ASC ("z") for Li_i = li_start to li_end IF of_GET_DRIVE_TYPE (Char (li_i)) = "CDROM" THEN LS_CDROMS = LS_CDROMS CHAR (Li_i) NextRetReturn LS_CDROMSEND FUNCTION
public function string of_directory_create_all (string as_directory); / * function operates: to create a new directory (containing the parent folder) Parameters: as_directory string Folder Name Return value: boolean * / String ls_ret, ls_path [] Int li_i, li_j, li_pos = 1ls_ret = "OK" Do While li_pos> 0 IF DirectoryExists (as_directory) THEN Exit li_i ; ls_path [li_i] = as_directory li_pos = of_get_last_pos (as_directory, "/", 1) as_directory = Left (as_directory, li_pos) LoopFor li_j = li_i To 1 Step -1 // Established directory IF 1 <> createDirectory (ls_path [li_j]) THEN LS_RET = "fa"; EXIT END IFNEXTRETURN LS_RET
END FUNCTION
public function boolean of_directory_delete (string as_directory); / * function action: delete a directory, you can not have a child file and folder parameters: as_directory string folder name Return value: boolean * / return RemoveDirectoryA (as_directory) end function
public function long of_directory_no_recursion (string as_first_directory, string as_second_directory, ref stc_find_data as_file []); long i, j, kstc_find_data lss_tempstring ls_swapk = upperbound (as_file) 1if mid (as_first_directory, len (as_first_directory)) <> "/" then as_first_directory = as_first_directory "/" end ifif mid (as_second_directory, len (as_second_directory)) <> "/" and len (as_second_directory)> 0 then as_second_directory = as_second_directory "/" end if
LS_SWAP = as_first_directory as_second_directory "*"
I = FindFirstFile (LS_SWAP, LSS_TEMP) if i = - 1 Then Return -1END IFJ = IDO While J <> 0 if Lss_Temp.cfileName = '.' or LSS_TEMP.CFILENAME = '..' or LEN (TRIM (LSS_TEMP.CFILENAME )) = 0 then else as_file [k] = lss_temp as_file [k] .cfilename = as_second_directory as_file [k] .cfilename k end if j = findnextfile (i, lss_temp) loopfindclose (i) return k - 1end function
Public Function Long of_Directory_no_recursion (string as_directory, ref stc_find_data as_file []); long i, j, kstc_find_data lss_tempstring ls_swapk = Upperbound (as_file) 1
if mid (as_directory, len (as_directory)) <> "/" then as_directory = as_directory "/" end ifls_swap = as_directory "*" i = findfirstfile (ls_swap, lss_temp) if i = - 1 then return -1end ifj = ido while J <> 0 if lss_temp.cfilename = '.' or lss_temp.cfilename = ".." or LEN (Trim (LSS_TEMP.CFileName) = 0 THEN ELSE AS_FILE [K] = LSS_TEMP AS_FILE [K] .cfilename = as_directory AS_FILE [K] .cfilename K end if j = findnextfile (i, lss_temp) loopfindclose (i) Return K - 1
END FUNCTION
public function long of_directory_dir (string as_directory, boolean no_first_dir, ref stc_find_data as_file []); long i, jif no_first_dir then if this.of_directory_no_recursion (as_directory, '', as_file)> 0 then j = upperbound (as_file) for i = 1 to J IF (AS_FILE [I] .att, 32) - MOD (as_file [i] .att, 16)> 0 THEN THIS.OF_DIRECTORY_NO_RECURSION (as_directory, as_file [i] .cfilename, as_file) j = Upperbound (as_file ) End if next end ifelse if this.of_directory_no_recursion (as_directory, as_file)> 0 THEN J = UpperBound (as_file) for i = 1 to jiff (mod (as_file [i] .att, 32) - MOD (as_file [i] .att, 16))> 0 THEN THIS.OF_DIRECTORY_NO_RECURSION (as_file [i] .cfilename, as_file) j = Upperbound (as_file) end if next end ifend if // f_shu_debug (String (j)) Return Jend Function
Private function boolean of_set_file_attrib (string as_filename, boolean ab_readonly, boolean ab_hidden, boolean ab_system); ulong lul_attrib = 0
If ab_readonly kiln atat = lul_attrib 1END IFIF AB_HIDDEN THEN LUL_ATTRIB = LUL_ATTRIB 21END IFIF AB_SYSTEM THEN LUL_ATTRIB = LUL_ATTRIB 4END IF
Return NOT setFileAttributes (as_filename, lul_attrib) = 0
END FUNCTION
Private function boolean of_set_file_attrib (string as_filename, unsignedlong aul_attrib); return not setfileAttributes (as_filename, aul_attrib) = 0nd function
Private function bolean of_file_delete; / * Function: Delete the specified file parameter: String as_filename Remove the file name return value: boolean * / return deletefilea (as_filename)
END FUNCTION
public function boolean of_drive_isavailable (string as_drive); / * Function effect: Analyzing the drive name is legitimate parameters: string as_drive drive name Return value: boolean * / RETURN not IsNull (of_Get_drive_Type (as_drive)) end function
public function string of_get_drive_serialnumber (string as_drive); / * Function effect: Get the specified sequence number drive parameters: as_drive string drive Return Value: string * / string ls_VolumeNameBufferulong ll_VolumeSerialNumberulong ll_MaximumComponentLengthulong ll_FileSystemFlagsstring ls_FileSystemNameBufferas_drive = Left (as_drive, 1) ":" ls_VolumeNameBuffer = Space (20) ls_FileSystemNameBuffer = Space (20) IF not GetVolumeInformationA (as_drive, ls_VolumeNameBuffer, 20, ll_VolumeSerialNumber, ll_MaximumComponentLength, ll_FileSystemFlags, ls_FileSystemNameBuffer, 20) THEN SetNull (ll_VolumeSerialNumber) END IFRETURN String (ll_VolumeSerialNumber) end functionpublic function string of_get_drive_volumename (string as_drive); / * function effect: Get the specified drive label name parameters: as_drive string drive return value: string * / string ls_VolumeNameBufferulong ll_VolumeSerialNumberulong ll_MaximumComponentLengthulong ll_FileSystemFlagsstring ls_FileSystemNameBufferas_drive = Left (as_drive, 1) ":" ls_VolumeNameBuffer = Space (20 LS_FILESYSTEMNAMEBUFFER = Space (20) if not getVolumeInformationa (as_drive , Ls_VolumeNameBuffer, 20, ll_VolumeSerialNumber, ll_MaximumComponentLength, ll_FileSystemFlags, ls_FileSystemNameBuffer, 20) THEN SetNull (ls_VolumeNameBuffer) END IFRETURN ls_VolumeNameBufferend function
private function unsignedlong of_bitwiseor (unsignedlong aul_value1, unsignedlong aul_value2); / * Function effect: two long type data bits or operational parameters: aul_value1 unsignedlong aul_value2 unsignedlong Return Value: unsignedlong * / UnsignedLong lul_Result = 0Unsignedlong lul_multiple = 1Unsignedlong lul_bitIf IsNull (aul_Value1 ) Or IsNull (aul_Value2) Then SetNull (lul_Result) Return lul_ResultEnd IfDo lul_bit = (mod (aul_value1, 2) mod (aul_value2, 2) 1) / 2 lul_Result = lul_bit * lul_multiple aul_value1 = aul_value1 / 2 aul_value2 = aul_value2 / 2 LUL_MULTIPLE * = 2 loop until aul_value1 = 0 and aul_value2 = 0RETURN LUL_RESULTEND FUNCTION
private function string of_shbrowseforfolder (long alhparent, string asprompt, long alflags); constant long max_path = 260long llIDListstc_BROWSEINFO lBIstring lsPathlBI.hWndOwner = alhParent lBI.pidlRoot = 0 lBI.pszDisplayName = Space (MAX_PATH) lBI.lpszTitle = asPrompt lBI.ulFlags = alFlags lBI.lpfn = 0 lBI.lParam = 0 lBI.iImage = 0 llIDList = SHBrowseForFolder (lBI) IF (llIDList> 0) THEN lsPath = Space (MAX_PATH) IF NOT SHGetPathFromIDList (llIDList, lsPath) THEN lsPath = "" END IFELSE lsPath = "" Endiff Return Trim (LSPATH)
END FUNCTION
public function string of_directory_browseforfolder (long alhparent, string asprompt); / * Function effect: on access Folder dialog parameters: alparent long parent object handle on the box label content as_prompt string Return value: string * / constant long BIF_RETURNONLYFSDIRS = 1RETURN This.of_shbrowseforfolder (alhparent, asprompt, bif_returnonlyfsdirs) End Function
public function string of_directory_browseforcomputer (long alhparent, string asprompt); / * function role: to get Folder dialog box (with My Network Places) parameters: alparent long parent object handle on the box label content as_prompt string Return value: string * / constant ulong BIF_BROWSEFORCOMPUTER = 4096RETURN This.of_SHBrowseForFolder (alhParent, asPrompt, BIF_BROWSEFORCOMPUTER) end functionpublic function string of_directory_browseforprinter (long alhparent, string asprompt); / * function effect: on access box folders (including printers) parameters: alparent long parent objects Object handle AS_PROMPT STRING dialog String content return value: string * / constant ulong bif_browseforprinter = 8192 Return this.of_shbrowseForfolder (alhparent, asprompt, bif_browseforprinter) end function
public function unsignedlong of_directory_netcancelconnection (ref string as_driver); / * Function effect: disconnect a local mapped drive parameters: as_driver string locally mapped drive name Return Value: unsignedlong * / return WNetCancelConnection (as_driver, false) end function
Public Function Boolean of_Drive_format (character as_drive); / * Function: Format parameters for specified drive: String as_drive needs to format the drive name Return Value: boolean * / return (SHFormatDrive (0, ASC (Upper (as_drive) - 65, 0, 0) <> 0)
END FUNCTION
private subroutine of_get_directory_subdirs (window aw_acton, string as_directory); long ll, li, il_subdirsDragObject il_lsbstring is_listitemif right (as_directory, 1) <> "/" then as_directory = as_directory "/" aw_acton.openuserobject (il_lsb, "listbox", 0,0 ) il_lsb.dynamic dirlist (as_directory "*. 2345", 16) il_subdirs = il_lsb.dynamic totalitems () for ll = 1 to il_subdirs is_listitem = il_lsb.dynamic text (ll) if is_listitem = "[..]" then CONTINUE li = upperbound (is_subdirs) is_subdirs [li 1] = as_directory mid (is_listitem, 2, len (is_listitem) - 2) of_get_directory_subdirs (aw_acton, is_subdirs [li 1]) nextaw_acton.closeuserobject (il_lsb) destroy il_lsbend subroutine
public function long of_get_directory_subdirs (window aw_acton, string as_directory, ref string as_subdirs []); / * function action: Get subfolders specified folder list of parameters: aw_window window parent window name as_directory string folder name, to be the absolute path as_subdirs [] String Storage subfolder list String array return value: long * / long ll_returnof_get_directory_subdirs (aw_acton, as_directory) as_subdirs = is_subdirsreturn il_subdirs_numbend function
private subroutine of_get_directory_subfiles (window aw_acton, string as_directory); long ll, li, il_subfilesDragObject il_lsbstring is_listitemif right (as_directory, 1) <> "/" then as_directory = as_directory "/" aw_acton.openuserobject (il_lsb, "listbox", 0,0 ) il_lsb.dynamic dirlist (as_directory "*. *", 32823) il_subfiles = il_lsb.dynamic totalitems () for ll = 1 to il_subfiles is_listitem = il_lsb.dynamic text (ll) if mid (is_listitem, 1,1) <> " [ "then li = upperbound (is_subfiles) is_subfiles [li 1] = as_directory is_listitem elseif is_listitem <>" [..] "then of_get_directory_subfiles (aw_acton, as_directory mid (is_listitem, 2, len (is_listitem) - 2)) end ifnextil_subfiles_number = upperbound (is_subfiles) aw_acton.closeuserobject (il_lsb) destroy il_lsbend subroutinepublic function long of_get_directory_subfiles (window aw_acton, string as_directory, ref string as_subfiles []); / * function effect: obtaining sub-files in the specified folder list of parameters: aw_window Window Parent Window Name AS_DIRECTORY STRING folder name, absolute path AS_SUBFILES [] String Storage subfold list String array return value: long * / Long LL_RETURNOF_GET_DIRECTORY_SUBFILES (aw_acton, as_directory) as_subfiles = is_subfilesreturn il_subfiles_numbend function
public function long of_get_directory_capacity (window aw_window, string as_directory); / * Function action: to obtain the actual size parameters specified folder: aw_window window parent window name as_directory string folder name, for an absolute path Return value: long * / long ll_directory_length = 0, llstring ls_subfiles [] of_get_directory_subfiles (aw_window, as_directory, ls_subfiles) for ll = 1 to upperbound (ls_subfiles) ll_directory_length = ll_directory_length filelength (ls_subfiles [ll]) next return ll_directory_length
END FUNCTION
protected function long of_get_directory_usedcapacity (string as_directory); / * Function effect: acquiring space size specified folder name of the folder as_directory string, the return value for an absolute path: long * / Constant long MAX_PATH = 260Constant long INVALID_HANDLE_value = -1Constant long FILE_ATTRIBUTE_DIRECTORY = 16stc_find_data flong hfile, hsizeIf Right (as_directory, 1) <> "/" Then as_directory = as_directory "/" as_directory = as_directoryhFile = FindFirstFile (as_directory, f) If hFile = INVALID_HANDLE_value Then return 0If of_bitwiseand (f.Att, FILE_ATTRIBUTE_DIRECTORY) = 0 THEN IL_DIRECTORY_SPACE = IL_DIRECTORY_SPACE F.L_SIZEEND IFINDCLOSE (HFILE) RETURN IL_DIRECTORY_SPACEEND FUNCTION
private function unsignedlong of_bitwiseand (unsignedlong aul_value1, unsignedlong aul_value2); / * Function effect: two long type of data bits and operating parameters: aul_value1 unsignedlong aul_value2 unsignedlong Return Value: unsignedlong * / UnsignedLong lul_Result = 0Unsignedlong lul_multiple = 1Unsignedlong lul_bitIf IsNull (aul_Value1 ) Or IsNull (aul_Value2) Then SetNull (lul_Result) Return lul_ResultEnd IfDo lul_bit = mod (aul_value1, 2) * mod (aul_value2, 2) lul_Result = lul_bit * lul_multiple aul_value1 = aul_value1 / 2 aul_value2 = aul_value2 / 2 lul_multiple * = 2 Loop Until aul_value1 = 0 or aul_value2 = 0RETURN LUL_RESULT
END FUNCTION
private function integer of_get_last_pos (string as_string1, string as_string2, integer ai_bz); Integer li_len, li_iString ls_reverseli_len = Len (as_string1) IF ai_bz = 0 THEN as_string1 = Upper (as_string1); as_string2 = Upper (as_string2) END IFls_reverse = reverse (as_string1) Li_i = li_len - POS (as_string1, as_string2, 1) return li_i
END FUNCTION
public function long of_directory_uncompress (ref string as_documentname, ref string as_directory); / * function role: the compressed folder to decompress parameters: string as_documentname need to decompress the file name, absolute path string as_directory destination folder, absolute path of the return value: Long * / return myzip_extractfileAll (as_documentname, as_directory) End Function
public function long of_directory_compress (ref string as_directory, ref string as_newdocument); / * Function effect: folder compression parameters: string as_directory folder absolute path string file name of as_newdocument compressed absolute path Return value: long * / if right (as_directory, 1) = "/" THEN As_Directory = MID (as_directory, 1, len (as_directory - 1) end if return myzip_adddirectory (as_directory, as_newdocument) End Function
Public Function Boolean of_directory_Decrypt (Ref string as_directory); / * Function: File is solved, only with Win2000 or more OS parameters: boolean * / if right (as_directory, 1) = "/" THEN As_Directory = MID (as_directory, 1, len (as_directory) - 1) end ifreturn decryptfile (as_directory, 0) End function
Public Function Boolean Off (Ref String As_Directory); / * Function Role: Folder Encryption THEN As_Directory = MID (as_directory, 1, len (as_directory - 1) end ifreturn encryptfile (as_directory) end function
public function boolean of_directory_rename (ref string as_directory, ref string as_newname); / * Function effect: Rename Folder parameters: as_directory string original folder name, for an absolute path name the new folder as_newname string, tape path without a return value: boolean * / string ls_directorynameif right (as_directory, 1) = "/" then as_directory = mid (as_directory, len (as_directory) - 1) end ifls_directoryname = mid (as_directory, 1, lastpos (as_directory, "/")) as_newnamereturn MoveFileA ( as_directory, ls_directoryname) end functionpublic function boolean of_directory_create (string as_directory); / * function action: Create a new directory parameters: as_directory1 string folder name return value: boolean * / string ls_SecurityAttributesSetNull (ls_SecurityAttributes) rETURN CreateDirectoryA (as_directory, ls_SecurityAttributes)
END FUNCTION
public function boolean of_directory_isavailable (string as_directory); / * Function action: determining whether there is a folder parameters: as_directory string Folder Name Return value: boolean * / String ls_Attributesnvo_file invo_filels_Attributes = invo_file.of_Get_file_Attributes (as_directory) IF IsNull (ls_Attributes) THEN RETURN FALSERETURN POS (LS_ATTRIBUTES, "D")> 0nd function
public function unsignedlong of_directory_netaddconnection (ref string as_directory, ref string as_pass, ref string as_driver); / * Function effect: mapping a network folder local drive parameters: as_directory string folder name as_pass string access password as_driver local drive Name Return Value: unsignedlong * / RETURN WNETDCONNECTION (as_directory, as_pass, as_driver)
END FUNCTION
public function double of_get_drive_totalspace (string as_drive); / * Function effect: Get the specified drive space parameters: as_drive string drive Return Value: real * / Double ld_capacityany ia_passif right (as_drive, 1) <> ":" then as_drive = as_drive ":" end ifLARGE_INTEGER lngFreeCaller, lngTotal, lngTotalFreeGetDiskFreeSpaceExA (as_drive, lngFreeCaller, lngTotal, lngTotalFree) IF lngTotal.Highpart> 0 THEN ld_capacity = (lngTotal.Highpart * 1.0 * 4294967295) lngTotal.LowPartELSE ld_capacity = lngTotal.LowPartEND IFreturn ld_capacityend function
public function double of_get_drive_freespace (string as_drive); / * Function effect: acquiring specified drive space available parameters: as_drive string drive Return Value: real * / Double ld_capacityany ia_passif right (as_drive, 1) <> ":" then as_drive = as_drive ":" end ifLARGE_INTEGER lngFreeCaller, lngTotal, lngTotalFreeGetDiskFreeSpaceExA (as_drive, lngFreeCaller, lngTotal, lngTotalFree) IF lngTotalFree.Highpart> 0 THEN ld_capacity = (lngTotalFree.Highpart * 1.0 * 4294967295) lngTotalFree.LowPartELSE ld_capacity = lngTotalFree.LowPartEND IFreturn ld_capacity
END FUNCTION
public function double of_get_drive_usedspace (string as_drive); / * Function effect: acquiring specified drive used space size parameters: as_drive string drive Return Value: double * / Double ld_capacity1, ld_capacity2any ia_passif right (as_drive, 1) <> ": "then as_drive = as_drive ": "end ifLARGE_INTEGER lngFreeCaller, lngTotal, lngTotalFreeGetDiskFreeSpaceExA (as_drive, lngFreeCaller, lngTotal, lngTotalFree) IF lngTotal.Highpart> 0 THEN ld_capacity1 = (lngTotal.Highpart * 1.0 * 4294967295) lngTotal.LowPartELSE ld_capacity1 = lngTotal. LowPartEND IFIF lngTotalFree.Highpart> 0 THEN ld_capacity2 = (lngTotalFree.Highpart * 1.0 * 4294967295) lngTotalFree.LowPartELSE ld_capacity2 = lngTotalFree.LowPartEND IFreturn ld_capacity1 - ld_capacity2end function
public function string of_get_drive_filesystemname (string as_drive); / * Function effect: Get the specified drive file system name Parameters: as_drive string drive Return Value: string * / string ls_VolumeNameBufferulong ll_VolumeSerialNumberulong ll_MaximumComponentLengthulong ll_FileSystemFlagsstring ls_FileSystemNameBufferif right (as_drive, 1) <> "/ "then as_drive = as_drive " / "end ifls_VolumeNameBuffer = Space (20) ls_FileSystemNameBuffer = Space (20) GetVolumeInformationA (as_drive, ls_VolumeNameBuffer, 20, ll_VolumeSerialNumber, ll_MaximumComponentLength, ll_FileSystemFlags, ls_FileSystemNameBuffer, 20) RETURN ls_FileSystemNameBufferend function
public function string of_get_directory_attributes (string as_directory); long ll_fileattributesstring ls_fileattributesll_fileattributes = GetFileAttributes (as_directory) IF ll_FileAttributes = 4294967295 THEN SetNull (ls_FileAttributes) ELSE IF Mod (ll_FileAttributes, 2)> 0 THEN ls_FileAttributes = "R" IF Mod (ll_FileAttributes, 4) > 1 THEN ls_FileAttributes = "H" IF Mod (ll_FileAttributes, 8)> 3 THEN ls_FileAttributes = "S" IF Mod (ll_FileAttributes, 32)> 15 THEN ls_FileAttributes = "D" IF Mod (ll_FileAttributes, 64)> 31 THEN LS_FILEATTRIBUTES = "a" end ifreturn LS_FileAttributesend function
public function datetime of_get_directory_createtime (string as_directory); / * function action: get creation time parameter folder: as_filename string filename, you need absolute file path Return value: datetime * / long ll_codedatetime ldt_filedatetimelong lul_date, lul_timeint lui_year, lui_month, lui_day, lui_hour , lui_minute, lui_secondstc_find_data ls_filell_code = findfirstfile (as_directory, ls_file) findclose (ll_code) ldt_filedatetime = datetime (ls_file.c_time) if ll_code = -1 then setnull (ldt_filedatetime) else filetimetodosdatetime (ls_file.c_time, lul_date, lul_time) lui_day = mod (lul_date , 32) lui_month = mod (lul_date, 512) / 32 if lui_month = 0 then lui_month = 1 end if lui_year = lul_date / 512 1980 lui_second = mod (lul_time, 32) * 2 lui_minute = mod (lul_time, 2048) / 32 lui_hour = (lul_time) / 2048 8 if lui_hour> = 24 then lui_hour = lui_hour - 24 ldt_filedatetime = datetime (relativedate (date (lui_year, lui_month, lui_day), 1), time (lui_hour, lui_minute, lui_second)) else ldt_filedatetime = DateTime (Date (Lui_Year, Lui_Month, Lui_day), Time (Lui_Hour, Lui_Minute, Lui_Second) End IFEND ifreturn LDT_FiledateTimeEnd Function
public function datetime of_get_directory_writetime (string as_directory); / * Function action: retrieve the last write time parameter folder: as_filename string file name, for an absolute file path Return value: datetime * / long ll_codedatetime ldt_filedatetimelong lul_date, lul_timeint lui_year, lui_month, lui_day , lui_hour, lui_minute, lui_secondstc_find_data ls_filell_code = findfirstfile (as_directory, ls_file) findclose (ll_code) ldt_filedatetime = datetime (ls_file.a_time) if ll_code = -1 then setnull (ldt_filedatetime) else filetimetodosdatetime (ls_file.a_time, lul_date, lul_time) lui_day = mod (lul_date, 32) lui_month = mod (lul_date, 512) / 32 if lui_month = 0 then lui_month = 1 end if lui_year = lul_date / 512 1980 lui_second = mod (lul_time, 32) * 2 lui_minute = mod (lul_time, 2048) / 32 lui_hour = (lul_time) / 2048 8 if lui_hour> = 24 then lui_hour = lui_hour - 24 ldt_filedatetime = datetime (relativedate (date (lui_year, lui_month, lui_day), 1), time (lui_hour, lui_minute, lui_second)) else LDT_FILEDATETIME = DATETIME (Date (Lui_Year, Lui_Month, Lui_day), Time (Lui_Hour, Lui_Minute, Lui_Second) End Ifen D iFreturn LDT_FILEDATETIMEEND FUNCTION
public function datetime of_get_directory_accesstime (string as_directory); / * function role: Gets the last access time parameter folder: as_filename string filename, you need absolute file path Return value: datetime * / long ll_codedatetime ldt_filedatetimelong lul_date, lul_timeint lui_year, lui_month, lui_day, lui_hour, lui_minute, lui_secondstc_find_data ls_filell_code = findfirstfile (as_directory, ls_file) findclose (ll_code) ldt_filedatetime = datetime (ls_file.a_time) if ll_code = -1 then setnull (ldt_filedatetime) else filetimetodosdatetime (ls_file.a_time, lul_date, lul_time) lui_day = mod ( lul_date, 32) lui_month = mod (lul_date, 512) / 32 if lui_month = 0 then lui_month = 1 end if lui_year = lul_date / 512 1980 lui_second = mod (lul_time, 32) * 2 lui_minute = mod (lul_time, 2048) / 32 lui_hour = (lul_time) / 2048 8 if lui_hour> = 24 then lui_hour = lui_hour - 24 ldt_filedatetime = datetime (relativedate (date (lui_year, lui_month, lui_day), 1), time (lui_hour, lui_minute, lui_second)) else ldt_filedatetime = DATETIME (Date (Lui_Year, Lui_Month, Lui_Day), Time (Lui_Hour, Lui_Minute, Lui_Second) End Ife nd ifreturn ldt_filedatetimeend functionprivate function long of_makechar (readonly string asstrings [], ref character acchar []); char lcChar [], lcString [] long llStringCount, llStringIndexlong llCharCount, llCharIndex
// count number of strings in arrayllstringcount = upperbound (asstrings [])
IF (llstringcount> 0) THEN / / Add Each of the strings to the char Array for llstringIndex = 1 to llstringcount
// Get Length of current string llcharcount = len (asstrings [llstringindex])
IF llcharcount> 0 THEN
// Convert String Into char Array LCString = Asstrings [llstringIndex]
// Concatenate string to existing char array FOR llCharIndex = 1 TO llCharCount lcChar [UpperBound (lcChar) 1] = lcString [llCharIndex] NEXT // Terminate each string with a null character lcChar [UpperBound (lcChar) 1] = Char ( 0) end if next // The last element equipment must be double-null Terminated LCCHAR [UPPERBOUND (LCCHAR) 1] = char (0) End IF
// set reference argumentAcchar = lcchar
// Return Length of char ArrayReturn UpperBound (LCCHAR)
END FUNCTION
Public function string of_get_drive_list (); / * Function: Get the drive list parameters: None Return Value: string * / long c, i, pos, l = 255string ls_driveblob {255} BC = getLogicalDriveStrings (L, REF B) IF C> 0 THEN for i = 1 TO C IF ASC (BLOBMID (B, I, 1))) <> 0 THEN LS_DRIVE = LS_DRIVE CHAR (Blobmid (B, I, 1)) ELSE LS_DRIVE = LS_Drive ";" END IF Nextend ifreturn ls_drive
END FUNCTION
Private function boolean of_shfileopstruct lpfileop; return (shfileOperation) = 0)
END FUNCTION
Public Function Boolean of_directory_copy_all (readonly string asfrom [], readonly string asto; shfileopstruct lpfileopchar lcfrom [] long lpstringboolean lbopy = false
// Convert Array of strings Into a single null-seperated char Arrayif this.of_makechar (asfrom [], lcfrom)> 0 THEN
// Allocate Memory for char Array (pstring) LPSTRING = Localalloc (0, Upperbound (LCFROM))
// Copy Char Array Into Newly Allocated Memory RTLMOVEMEMORY (LPSTRING, LCFROM, UPPERBOUND (LCFROM))
// Populate FileOperation structure lpFileOp.hWnd = 0 // No parent dialog lpFileOp.wFunc = FO_COPY // Perform a COPY operation lpFileOp.pFrom = lpString // Source files lpFileOp.pTo = asTo // Destination directory lpFileOp.fFlags = FOF_ALLOWUNDO FOF_FILESONLY // Save UNDO info lpFileOp.fAnyOperationsAborted = FALSE // This is an OUTPUT var to indicate user aborted lpFileOp.hNameMappings = 0 // Do not want old / new pathnames lpFileOp.lpszProgressTitle = "" // Display default message (ie. File currently being copy) .// perform copy lbcopy = this.of_shfileOperation (lpfileop)
// free allocated memory localfree (lpstring) endiff
// Return Results of CopyReturn LBCOPY
End functionpublic function boolean of_directory_move_all (readonly string asfrom [], readonly string asto; shfileopstruct lpfileopchar lcfrom [] long lpstringBoolean lbmove = false
// Convert Array of strings Into a single null-seperated char Arrayif this.of_makechar (asfrom [], lcfrom)> 0 THEN
// Allocate Memory for char Array (pstring) LPSTRING = Localalloc (0, Upperbound (LCFROM))
// Copy Char Array Into Newly Allocated Memory RTLMOVEMEMORY (LPSTRING, LCFROM, UPPERBOUND (LCFROM))
// Populate FileOperation structure lpFileOp.hWnd = 0 // No parent dialog lpFileOp.wFunc = FO_MOVE // Perform a MOVE operation lpFileOp.pFrom = lpString // Source files lpFileOp.pTo = asTo // Destination directory lpFileOp.fFlags = FOF_ALLOWUNDO FOF_FILESONLY // Save UNDO info lpFileOp.fAnyOperationsAborted = FALSE // This is an OUTPUT var to indicate user aborted lpFileOp.hNameMappings = 0 // Do not want old / new pathnames lpFileOp.lpszProgressTitle = "" // Display default message (ie. File currently being copy) .// perform move lbmove = this.of_shfileopert:
// free allocated memory localfree (lpstring) endiff
// Return Results of Movereturn LBMOVE
END FUNCTION
Public Function Boolean of_directory_delete_all (readonly string asfrom []); shfileopstruct lpfileopchar lcfrom [] long lpstringBoolean lbdelete = false
// Convert Array of strings Into a single null-seperated char Arrayif this.of_makechar (asfrom [], lcfrom)> 0 THEN
// Allocate Memory for char Array (pstring) LPSTRING = Localalloc (0, Upperbound (LCFROM))
// Copy Char Array Into Newly Allocated Memory RTLMOVEMEMORY (LPSTRING, LCFROM, UPPERBOUND (LCFROM))
// Populate FileOperation structure lpFileOp.hWnd = 0 // No parent dialog lpFileOp.wFunc = FO_DELETE // Perform a DELETE operation lpFileOp.pFrom = lpString // Source files lpFileOp.pTo = "" // Not used for DELETE lpFileOp.fFlags = FOF_ALLOWUNDO FOF_FILESONLY // Save UNDO info lpFileOp.fAnyOperationsAborted = FALSE // This is an OUTPUT var to indicate user aborted lpFileOp.hNameMappings = 0 // Do not want old / new pathnames lpFileOp.lpszProgressTitle = "" // Display default message (IE. File Currently Being Copied) .// Perform Delete LbDelete = this.of_shfileOperation (lpfileop)
// free allocated memory localfree (lpstring) endiff
// Return Results of Deletereturn LBDELETE
END FUNCTION
public function boolean of_directory_move (ref string as_directory1, ref string as_directory2); / * Function action: moving folders parameters: as_directory1 string is moved folder name destination folder as_directory2 string Return value: boolean * / if right (as_directory1,1) = "/" then as_directory1 = mid (as_directory1, len (as_directory1) - 1) end ifif right (as_directory2,1) = "/" then as_directory2 = mid (as_directory2, len (as_directory2) - 1) end ifreturn MoveFileA (as_directory1, as_directory2 ) End function
ON NVO_DIRECTORY.CREATECALL Super :: Createtriggerevent (this, "constructor") End on
ON NVO_DIRECTORY.DESTROYTROYTRIGEREVENT (this, "destructor") CALL Super :: destroynd ON