国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

自己封裝的一個文件目錄操作用戶對象

2024-07-21 02:07:01
字體:
來源:轉載
供稿:網友
,歡迎訪問網頁設計愛好者web開發。
$pbexportheader$nvo_directory.sru
$pbexportcomments$目錄操作類
forward
global type nvo_directory from nonvisualobject
end type
type stc_filetime from structure within nvo_directory
end type
type stc_fileopstruct from structure within nvo_directory
end type
type stc_browseinfo from structure within nvo_directory
end type
type stc_find_data from structure within nvo_directory
end type
type large_integer from structure within nvo_directory
end type
type stc_ofstruct from structure within nvo_directory
end type
type shfileopstruct from structure within nvo_directory
end type
end forward

type stc_filetime from structure
 unsignedlong  l_time
 unsignedlong  h_time
end type

type stc_fileopstruct from structure
 unsignedlong  hwnd
 unsignedlong  wfunc
 string  pfrom
 string  pto
 long  fflags
 long  fanyoperationsaborted
 long  hnamemappings
 string  lpszprogresstitle
end type

type stc_browseinfo from structure
 long  hwndowner
 long  pidlroot
 string  pszdisplayname
 string  lpsztitle
 unsignedlong  ulflags
 unsignedlong  lpfn
 unsignedlong  lparam
 long  iimage
end 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
end type

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  lpszprogresstitle
end type

global type nvo_directory from nonvisualobject autoinstantiate
end type

type prototypes
function 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) library "kernel32.dll"
function uint getdrivetypea(string lprootpathname) library "kernel32.dll"
function ulong findclose(ulong hfindfile) 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) library "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 prototypes

type variables
private:
string is_subdirs[],is_subfiles[]
long il_subdirs_number,il_subfiles_number,il_directory_space=0
constant ulong fo_move  = 1
constant ulong fo_copy  = 2
constant ulong fo_delete  = 3
constant ulong fof_allowundo  = 64
constant ulong fof_filesonly  = 128 
end variables

forward prototypes
public 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 (string 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 prototypes

public function string of_get_directory_current ();/*函數作用:獲取當前的文件夾名稱
  返回值:string    */
string ls_curdir
ulong l_buf
l_buf=256
ls_curdir=space(l_buf)
getcurrentdirectorya(l_buf,ls_curdir)
return ls_curdir
end function

public function long of_set_directory_current ();string ls_dir_name
ls_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 ();/*函數作用:獲取當前運行的應用程序文件名稱
   返回值:string    */
long   ll_rc
string  ls_apppath
long   ll_apphandler
ll_apphandler = handle(getapplication())
ls_apppath = space(256)
ll_rc = getmodulefilenamea(ll_apphandler, ls_apppath, 256)
if (ll_rc = 0) then ls_apppath = ""
return ls_apppath

end function

public function string of_get_directory_temp ();/*函數作用:獲取系統臨時文件夾名
   返回值:string    */       
ulong nbufferlength=255
string lpbuffer
lpbuffer=fill(' ',255)
gettemppath(nbufferlength,lpbuffer)
return lpbuffer

end function

public function string of_get_directory_system ();/*函數作用:獲取系統文件夾名
   返回值:string    */             
string ls_buffer
ulong 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 ();/*函數作用:獲取windows文件夾名
   返回值:string    */                        
string ls_buffer
ulong 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_buffer
end function

public function string of_get_drive_type (string as_rootpathname);/*函數作用:獲取指定的驅動器的類型
  參數:as_drive string 驅動器名
  返回值:string   */ 
string ls_drivetype
as_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 choose
return ls_drivetype
end function

public function string of_get_drive_cdrom ();/*函數作用:獲取光驅的驅動器名
   返回值:string    */  
integer li_i,li_start,li_end
string ls_cdroms=""
li_start=asc("a")
li_end=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)
next
return ls_cdroms
end function

public function string of_directory_create_all (string as_directory);/*函數作用:建立一個新目錄(包含父文件夾)
  參數: as_directory string   文件夾名稱
  返回值:boolean                         */
string ls_ret,ls_path[]
int li_i,li_j,li_pos=1
ls_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)
loop
for li_j = li_i to 1 step -1  //建立目錄
 if 1 <> createdirectory(ls_path[li_j]) then
  ls_ret="fa" ; exit
 end if
next
return ls_ret

end function

public function boolean of_directory_delete (string as_directory);/*函數作用:刪除一個目錄,不能有子文件和文件夾
  參數: as_directory string   文件夾名稱
  返回值: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,k
stc_find_data lss_temp
string ls_swap
k=upperbound(as_file) + 1
if mid(as_first_directory,len(as_first_directory))<>"/" then
 as_first_directory=as_first_directory+"/"
end if

if 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 -1
end if
j=i
do 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)
loop
findclose(i)
return k - 1
end function

public function long of_directory_no_recursion (string as_directory, ref stc_find_data as_file[]);long i,j,k
stc_find_data lss_temp
string ls_swap
k=upperbound(as_file) + 1

if mid(as_directory,len(as_directory))<>"/" then
 as_directory=as_directory+"/"
end if
ls_swap=as_directory+"*"
i=findfirstfile(ls_swap,lss_temp)
if i= - 1 then
 return -1
end if
j=i
do 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)
loop
findclose(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,j
if 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 (mod(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 if
else
 if this.of_directory_no_recursion(as_directory,as_file)>0 then
  j=upperbound(as_file)
  for i=1 to j
   if (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 if
end if
//f_shu_debug(string(j))
return j
end 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 then
 lul_attrib = lul_attrib + 1
end if
if ab_hidden then
 lul_attrib = lul_attrib + 2
end if
if ab_system then
 lul_attrib = lul_attrib + 4
end 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)=0
end function

private function boolean of_file_delete (string as_filename);/*函數作用:刪除指定的文件
  參數: string  as_filename 需刪除的文件名稱    
  返回值:boolean    */
return deletefilea(as_filename) 

end function

public function boolean of_drive_isavailable (string as_drive);/*函數作用:判斷驅動器名是否合法
  參數: string  as_drive 驅動器名稱    
  返回值:boolean    */
return not isnull(of_get_drive_type(as_drive))
end function

public function string of_get_drive_serialnumber (string as_drive);/*函數作用:獲取指定的驅動器的序列號
  參數:as_drive string 驅動器名
  返回值:string    */ 
string ls_volumenamebuffer
ulong ll_volumeserialnumber
ulong ll_maximumcomponentlength
ulong ll_filesystemflags
string ls_filesystemnamebuffer
as_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 if
return string(ll_volumeserialnumber)
end function

public function string of_get_drive_volumename (string as_drive);/*函數作用:獲取指定的驅動器的卷標名稱
  參數:as_drive string 驅動器名
  返回值:string   */ 
string ls_volumenamebuffer
ulong ll_volumeserialnumber
ulong ll_maximumcomponentlength
ulong ll_filesystemflags
string ls_filesystemnamebuffer
as_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 if
return ls_volumenamebuffer
end function

private function unsignedlong of_bitwiseor (unsignedlong aul_value1, unsignedlong aul_value2);/*函數作用:對兩個long類型數據進行位或操作
  參數: aul_value1 unsignedlong
        aul_value2 unsignedlong
  返回值:unsignedlong                  */
unsignedlong lul_result = 0
unsignedlong  lul_multiple = 1
unsignedlong lul_bit
if isnull(aul_value1) or isnull(aul_value2) then
 setnull(lul_result)
 return lul_result
end if
do
 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 = 0
return lul_result

end function

private function string of_shbrowseforfolder (long alhparent, string asprompt, long alflags);constant long max_path=260
long   llidlist
stc_browseinfo lbi
string  lspath
lbi.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 if
else 
 lspath = ""
end if  
return trim(lspath)

end function

public function string of_directory_browseforfolder (long alhparent, string asprompt);/*函數作用:對獲取文件夾對話框
  參數: alparent  long 父對象的對象句柄
        as_prompt  string   對話框上標簽內容
  返回值:string                         */
constant long bif_returnonlyfsdirs=1
return this.of_shbrowseforfolder( alhparent, asprompt, bif_returnonlyfsdirs )
end function

public function string of_directory_browseforcomputer (long alhparent, string asprompt);/*函數作用:對獲取文件夾對話框(含網上鄰居)
  參數: alparent  long 父對象的對象句柄
        as_prompt string   對話框上標簽內容
  返回值:string                         */
constant ulong bif_browseforcomputer = 4096
return this.of_shbrowseforfolder( alhparent, asprompt, bif_browseforcomputer )
end function

public function string of_directory_browseforprinter (long alhparent, string asprompt);/*函數作用:對獲取文件夾對話框(含打印機)
  參數: alparent  long 父對象的對象句柄
        as_prompt string   對話框上標簽內容
  返回值: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);/*函數作用:斷開映射的本地驅動器
  參數: as_driver string   本地映射驅動器名稱      
  返回值:unsignedlong                         */
return wnetcancelconnection(as_driver,false)
end function

public function boolean of_drive_format (character as_drive);/*函數作用:對指定驅動器進行格式化
  參數: string  as_drive 需格式化的驅動器名稱    
  返回值: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_subdirs
dragobject il_lsb
string is_listitem
if 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])
next
aw_acton.closeuserobject(il_lsb)
destroy il_lsb

end subroutine

public function long of_get_directory_subdirs (window aw_acton, string as_directory, ref string as_subdirs[]);/*函數作用:獲取指定的文件夾的子文件夾列表
  參數:aw_window window 父窗口名稱
       as_directory  string 文件夾名稱,需絕對路徑
   as_subdirs[]  string  存儲子文件夾列表的string數組
  返回值:long    */
long ll_return
of_get_directory_subdirs(aw_acton,as_directory)
as_subdirs=is_subdirs
return il_subdirs_number
end function

private subroutine of_get_directory_subfiles (window aw_acton, string as_directory);long ll,li,il_subfiles
dragobject il_lsb
string is_listitem
if 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 if
next
il_subfiles_number=upperbound(is_subfiles)
aw_acton.closeuserobject(il_lsb)
destroy il_lsb
end subroutine

public function long of_get_directory_subfiles (window aw_acton, string as_directory, ref string as_subfiles[]);/*函數作用:獲取指定的文件夾的子文件列表
  參數:aw_window window 父窗口名稱
       as_directory  string 文件夾名稱,需絕對路徑
   as_subfiles[]  string  存儲子文件列表的string數組
  返回值:long    */
long ll_return
of_get_directory_subfiles(aw_acton,as_directory)
as_subfiles=is_subfiles
return il_subfiles_number
end function

public function long of_get_directory_capacity (window aw_window, string as_directory);/*函數作用:獲取指定的文件夾的實際大小
  參數:aw_window window 父窗口名稱
       as_directory  string 文件夾名稱,需絕對路徑
  返回值:long    */
long ll_directory_length=0,ll
string 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);/*函數作用:獲取指定的文件夾的占用空間大小
       as_directory  string 文件夾名稱,需絕對路徑
  返回值:long    */
constant long max_path = 260
constant long invalid_handle_value = -1
constant long file_attribute_directory =16
stc_find_data f
long hfile,hsize
if right(as_directory, 1) <> "/" then as_directory = as_directory+"/"
as_directory=as_directory
hfile = findfirstfile(as_directory, f)
if hfile = invalid_handle_value then return 0
if of_bitwiseand(f.att,file_attribute_directory) = 0 then
   il_directory_space = il_directory_space + f.l_size
end if
findclose (hfile) 
return il_directory_space


end function

private function unsignedlong of_bitwiseand (unsignedlong aul_value1, unsignedlong aul_value2);/*函數作用:對兩個long類型數據進行位與操作
  參數: aul_value1 unsignedlong
        aul_value2 unsignedlong
  返回值:unsignedlong                  */
unsignedlong lul_result = 0
unsignedlong  lul_multiple = 1
unsignedlong lul_bit
if isnull(aul_value1) or isnull(aul_value2) then
 setnull(lul_result)
 return lul_result
end if
do
 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 = 0
return lul_result


end function

private function integer of_get_last_pos (string as_string1, string as_string2, integer ai_bz);integer li_len,li_i
string ls_reverse
li_len = len(as_string1)
if ai_bz=0 then
 as_string1=upper(as_string1) ; as_string2=upper(as_string2)
end if
ls_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);/*函數作用:對壓縮文件夾進行解壓縮
  參數: string  as_documentname 需解壓縮的文件名,絕對路徑
        string  as_directory 目標文件夾,絕對路徑       
  返回值:long    */
return myzip_extractfileall(as_documentname,as_directory)
end function

public function long of_directory_compress (ref string as_directory, ref string as_newdocument);/*函數作用:對文件夾進行壓縮
  參數: string  as_directory 文件夾絕對路徑
        string  as_newdocument 壓縮后的文件名,絕對路徑
  返回值: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);/*函數作用:文件夾解密,只能用與win2000以上os
  參數: as_directory string   文件夾名稱
  返回值:boolean                         */
if right(as_directory,1)="/" then
 as_directory=mid(as_directory,1,len(as_directory) - 1)
end if
return decryptfile(as_directory,0)
end function

public function boolean of_directory_encrypt (ref string as_directory);/*函數作用:文件夾加密,只能用與win2000以上os
  參數: as_directory string   文件夾名稱
  返回值:boolean                         */
if right(as_directory,1)="/" then
 as_directory=mid(as_directory,1,len(as_directory) - 1)
end if
return encryptfile(as_directory)
end function

public function boolean of_directory_rename (ref string as_directory, ref string as_newname);/*函數作用:重命名文件夾
  參數: as_directory string   原文件夾名稱,需絕對路徑
        as_newname string   文件夾新名稱,不需帶路徑
  返回值:boolean                         */
string ls_directoryname
if right(as_directory,1)="/" then
 as_directory=mid(as_directory,len(as_directory) - 1)
end if
ls_directoryname=mid(as_directory,1,lastpos(as_directory,"/"))+as_newname
return movefilea(as_directory,ls_directoryname)
end function

public function boolean of_directory_create (string as_directory);/*函數作用:建立一個新目錄
  參數: as_directory1 string   文件夾名稱
  返回值:boolean                         */
string ls_securityattributes
setnull(ls_securityattributes)
return createdirectorya(as_directory,ls_securityattributes)

end function

public function boolean of_directory_isavailable (string as_directory);/*函數作用:判斷文件夾是否存在
  參數: as_directory string   文件夾名稱
  返回值:boolean                         */
string ls_attributes
nvo_file invo_file
ls_attributes=invo_file.of_get_file_attributes(as_directory)
if isnull(ls_attributes) then return false
return pos(ls_attributes,"d")>0
end function

public function unsignedlong of_directory_netaddconnection (ref string as_directory, ref string as_pass, ref string as_driver);/*函數作用:映射網絡文件夾為本地驅動器
  參數: as_directory string   文件夾名稱
        as_pass string 訪問口令
    as_driver   本地驅動器名稱
  返回值:unsignedlong                         */
return wnetaddconnection(as_directory, as_pass, as_driver)

end function

public function double of_get_drive_totalspace (string as_drive);/*函數作用:獲取指定的驅動器的空間大小
  參數:as_drive string 驅動器名
  返回值:real   */ 
double         ld_capacity
any ia_pass
if right(as_drive,1)<>":" then
 as_drive=as_drive+":"
end if
large_integer lngfreecaller,lngtotal,lngtotalfree
getdiskfreespaceexa(as_drive, lngfreecaller, lngtotal, lngtotalfree)
if lngtotal.highpart > 0 then
   ld_capacity = ( lngtotal.highpart * 1.0 * 4294967295 ) +lngtotal.lowpart
else
   ld_capacity = lngtotal.lowpart
end if
return ld_capacity

end function

public function double of_get_drive_freespace (string as_drive);/*函數作用:獲取指定的驅動器的可用空間大小
  參數:as_drive string 驅動器名
  返回值:real    */  
double         ld_capacity
any ia_pass
if right(as_drive,1)<>":" then
 as_drive=as_drive+":"
end if
large_integer lngfreecaller,lngtotal,lngtotalfree
getdiskfreespaceexa(as_drive, lngfreecaller, lngtotal, lngtotalfree)
if lngtotalfree.highpart > 0 then
   ld_capacity = ( lngtotalfree.highpart * 1.0 * 4294967295 ) +lngtotalfree.lowpart
else
   ld_capacity = lngtotalfree.lowpart
end if
return ld_capacity

end function

public function double of_get_drive_usedspace (string as_drive);/*函數作用:獲取指定的驅動器的已用空間大小
  參數:as_drive string 驅動器名
  返回值:double   */ 
double         ld_capacity1,ld_capacity2
any ia_pass
if right(as_drive,1)<>":" then
 as_drive=as_drive+":"
end if
large_integer lngfreecaller,lngtotal,lngtotalfree
getdiskfreespaceexa(as_drive, lngfreecaller, lngtotal, lngtotalfree)
if lngtotal.highpart > 0 then
   ld_capacity1 = ( lngtotal.highpart * 1.0 * 4294967295 ) +lngtotal.lowpart
else
   ld_capacity1 = lngtotal.lowpart
end if
if lngtotalfree.highpart > 0 then
   ld_capacity2 = ( lngtotalfree.highpart * 1.0 * 4294967295 ) +lngtotalfree.lowpart
else
   ld_capacity2 = lngtotalfree.lowpart
end if
return ld_capacity1 - ld_capacity2

end function

public function string of_get_drive_filesystemname (string as_drive);/*函數作用:獲取指定的驅動器的文件系統名稱
  參數:as_drive string 驅動器名
  返回值:string   */ 
string ls_volumenamebuffer
ulong ll_volumeserialnumber
ulong ll_maximumcomponentlength
ulong ll_filesystemflags
string ls_filesystemnamebuffer
if right(as_drive,1)<>"/" then
 as_drive=as_drive+"/"
end if
ls_volumenamebuffer=space(20)
ls_filesystemnamebuffer=space(20)
getvolumeinformationa(as_drive,ls_volumenamebuffer,20,ll_volumeserialnumber,ll_maximumcomponentlength,ll_filesystemflags,ls_filesystemnamebuffer,20)
return ls_filesystemnamebuffer
end function

public function string of_get_directory_attributes (string as_directory);long ll_fileattributes
string ls_fileattributes
ll_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 if
return ls_fileattributes
end function

public function datetime of_get_directory_createtime (string as_directory);/*函數作用:獲取文件夾的創建時間
  參數: as_filename string 文件名,需絕對文件路徑
  返回值:datetime                 */
long ll_code
datetime ldt_filedatetime
long lul_date,lul_time
int lui_year,lui_month,lui_day,lui_hour,lui_minute,lui_second
stc_find_data ls_file
ll_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 if
end if
return ldt_filedatetime
end function

public function datetime of_get_directory_writetime (string as_directory);/*函數作用:獲取文件夾的最后讀寫時間
  參數: as_filename string 文件名,需絕對文件路徑
  返回值:datetime                 */
long ll_code
datetime ldt_filedatetime
long lul_date,lul_time
int lui_year,lui_month,lui_day,lui_hour,lui_minute,lui_second
stc_find_data ls_file
ll_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 if
end if
return ldt_filedatetime
end function

public function datetime of_get_directory_accesstime (string as_directory);/*函數作用:獲取文件夾的最后訪問時間
  參數: as_filename string 文件名,需絕對文件路徑
  返回值:datetime                 */
long ll_code
datetime ldt_filedatetime
long lul_date,lul_time
int lui_year,lui_month,lui_day,lui_hour,lui_minute,lui_second
stc_find_data ls_file
ll_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 if
end if
return ldt_filedatetime
end function

private function long of_makechar (readonly string asstrings[], ref character acchar[]);
char  lcchar[], lcstring[]
long  llstringcount, llstringindex
long  llcharcount, llcharindex

// count number of strings in array
llstringcount = 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 must be double-null terminated
 lcchar[upperbound(lcchar) + 1] = char(0)
end if

// set reference argument
acchar = lcchar

// return length of char array
return upperbound( lcchar )

end function

public function string of_get_drive_list ();/*函數作用:獲取驅動器列表
  參數: none  
  返回值:string    */
long c,i,pos,l=255
string ls_drive
blob{255} b
c = getlogicaldrivestrings(l,ref b)
if c>0 then
 for i=1 to c
  if asc(char(blobmid(b,i,1))) <>0 then
   ls_drive = ls_drive+ char(blobmid(b,i,1))
  else
   ls_drive = ls_drive+";"
  end if
 next
end if
return ls_drive

end function

private function boolean of_shfileoperation (ref shfileopstruct lpfileop);
return ( shfileoperation(lpfileop) = 0)

end function

public function boolean of_directory_copy_all (readonly string asfrom[], readonly string asto);shfileopstruct lpfileop
char    lcfrom[]
long    lpstring
boolean   lbcopy = false

// convert array of strings into a single null-seperated char array
if 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 copied).

 // perform copy
 lbcopy = this.of_shfileoperation( lpfileop )

 // free allocated memory
 localfree( lpstring )
end if

// return results of copy
return lbcopy

end function
public function boolean of_directory_move_all (readonly string asfrom[], readonly string asto);shfileopstruct lpfileop
char    lcfrom[]
long    lpstring
boolean   lbmove = false

// convert array of strings into a single null-seperated char array
if 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 copied).

 // perform move
 lbmove = this.of_shfileoperation( lpfileop )

 // free allocated memory
 localfree( lpstring )
end if

// return results of move
return lbmove

end function

public function boolean of_directory_delete_all (readonly string asfrom[]);
shfileopstruct lpfileop
char    lcfrom[]
long    lpstring
boolean   lbdelete = false

// convert array of strings into a single null-seperated char array
if 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 )
end if

// return results of delete
return lbdelete

end function

public function boolean of_directory_move (ref string as_directory1, ref string as_directory2);/*函數作用:移動文件夾
  參數: as_directory1 string   被移動文件夾名稱
        as_directory2 string   目標文件夾
  返回值:boolean                         */
if right(as_directory1,1)="/" then
 as_directory1=mid(as_directory1,len(as_directory1) - 1)
end if
if right(as_directory2,1)="/" then
 as_directory2=mid(as_directory2,len(as_directory2) - 1)
end if
return movefilea(as_directory1,as_directory2)
end function

on nvo_directory.create
call super::create
triggerevent( this, "constructor" )
end on

on nvo_directory.destroy
triggerevent( this, "destructor" )
call super::destroy
end on

 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阜新| 屏边| 威宁| 岑溪市| 麦盖提县| 视频| 平罗县| 崇州市| 兴城市| 湄潭县| 莱芜市| 巴青县| 平谷区| 包头市| 汨罗市| 嘉义市| 汾西县| 北票市| 东城区| 深水埗区| 东辽县| 元阳县| 历史| 安平县| 武功县| 始兴县| 泽州县| 大渡口区| 乌兰浩特市| 调兵山市| 萨嘎县| 巴中市| 云林县| 鄂托克前旗| 富顺县| 文安县| 柳州市| 来宾市| 漳浦县| 宁河县| 汽车|