Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File functions
Message
From
11/12/1998 12:42:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00166520
Message ID:
00166651
Views:
24
>If you find it, let me know.
>
>Thanks,
>
>-Michelle
Michelle,
I found it :) I don't know when last updated. Pls check before actual use. As I could see I haven't included error checking for RO, H, S files.
function DelTree
lParameters cPath
cPath = upper(alltrim(cPath))
cPath = cPath+iif(right(cPath,1) # "\","\","")
if substr(cPath,1,1) = "\"
	cPath = sys(5)+cPath
endif	
if cPath == "\" or substr(cPath,2) == ":\"  && Oooops. Root directory
	messagebox(cPath + " is a root directory !")
	return .f.
endif	
if !directory(cPath)
	messagebox(cPath + " is not a directory !")
	return .f.
endif
if sys(5)+curdir() == cPath
	messagebox(cPath + " is current directory")
	return .f.
endif	
if sys(5)+curdir() = cPath
	messagebox("Current directory is a subdirectory of "+cPath)
	return .f.
endif	

return iif(messagebox("Are you sure to remove ["+cPath + "] ?",4+32+256) = 7,;
	.f.,removedir(cPath))

function removeDir
lparameters cDirPath
local lcCursorName, llRHSExists
lcCursorName = "C_"+sys(2015)
llRHSExists=gettree(cDirPath,lcCursorName)
if llRHSExists
   messagebox("Read Only, Hidden or System dir encountered...")
   use
   return .f.
endif   
index on trim(dirname) tag dirname descending
scan
	erase (trim(dirs.dirname)+"\*.*")    && Erase files
	rmdir (trim(dirs.dirname))
endscan
use

function gettree
lparameters tcPath, tcCursorName
local lcTopDir
lcTopDir = sys(5)+curdir()
set defa to (tcPath)
create cursor (tcCursorName) ;
	(dirname c(127),attr c(5))
lcCurdir = sys(5)+curdir()
insert into (tcCursorName) ;
		(dirname) values (tcPath)
=getsubdirs(lcCurdir, tcCursorName)
set default to (lcTopDir)
locate for !empty(chrtran(attr,"AD.",""))
return !eof()

function getsubdirs
lparameters tcPath, tcCursorName
local lcCurDir, lnSubDirs, ix
local array laDirs[1]
lnSubdirs=adir(laDirs,tcPath+"*.*","HD")
for ix = 1 to lnSubDirs
    if laDirs[ix,1]#"." and "D"$laDirs[ix,5]
		insert into (tcCursorName) ;
			values (tcPath+laDirs[ix,1],laDirs[ix,5])
       	=getsubdirs(tcPath+laDirs[ix,1]+"\", tcCursorName)
    endif
endfor
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform