Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
CLEAR
? IsFolderExists([C:],[finger_com])
FUNCTION IsFolderExists(lcWhereToSearch, lcFolderSearched)
LOCAL ret_val, lnFor
LOCAL lnFolders, laFolders[1]
lcWhereToSearch = ADDBS(lcWhereToSearch)
ret_val = []
IF DIRECTORY(lcWhereToSearch+lcFolderSearched)
ret_val = lcWhereToSearch+lcFolderSearched
ELSE
lnFolders = ADIR(laFolders,ADDBS(lcWhereToSearch)+[*.*],[D])
FOR lnFor = 1 TO lnFolders
IF NOT LEFT(laFolders[lnFor,1],1) == [.] AND;
[D] $ laFolders[lnFor,5]
ret_val = IsFolderExists(lcWhereToSearch+laFolders[lnFor,1], lcFolderSearched)
IF NOT EMPTY(ret_val)
EXIT
ENDIF
ENDIF
NEXT
ENDIF
RETURN ret_val
* Remove *~
* to use this code!
* Recurse.prg, DW 12/20/2006, based on ideas from FoxWiki forum
* Include the code below to call the function, replacing lcPath with x:\path, which should be
* a full path to the folder to recurse
* Declare the array to fill with the full tree of folder names. Hide the array from upper
* level programs
*~PRIVATE lnRetVal
*~IF TYPE("laDirListing") # "U"
*~ DIMENSION laDirListing[1]
*~ELSE
*~ PRIVATE laDirListing
*~ DIMENSION laDirListing[1]
*~ENDIF
* Call the recurse function with a full path and a True
*~lnRetVal = Recurse("SOME NICE PATH", .T.)
* When function has finished, you can look at the array and do stuff with it
*~IF lnRetVal > 0
*~* Sort by folder name column, all rows, descending order, case insensitive
*~* This way, we process the deepest folders first.
*~ =ASORT(laDirListing,1,-1,1,0)
*~ FOR i = 1 TO ALEN(laDirListing)
*~* DO STUFF WITH THE FOLDER NAMES HERE.
*~* SPACES ARE PRESERVED IN THE FOLDER NAMES FOR YOUR ENJOYMENT!
*~ ?laDirListing[i]
*~ ENDFOR
*~ENDIF
*~* Only the local, private copy of the variables are released!
*~RELEASE laDirListing, lnRetVal
****************************************
FUNCTION Recurse
LPARAMETERS lcFullPathDir, lbInit
LOCAL lnPtr, lnFileCount, lcDir, lnRetVal
LOCAL ARRAY laFileList[1,5]
* Trim off any trailing backslash
lcFullPathDir = ALLTRIM(lcFullPathDir)
IF RIGHT(lcFullPathDir,1) == "\"
lcFullPathDir = LEFT(lcFullPathDir, LEN(lcFullPathDir) - 1)
ENDIF
* Read the chosen directory.
lnFileCount = ADIR(laFileList, lcFullPathDir + '\*.*', 'D')
* If there are files, sort the array so directories are listed first
IF lnFileCount = 0
RETURN 0
ENDIF
=ASORT(laFileList,5)
lnDirs = 0
FOR lnPtr = 1 TO lnFileCount
IF 'D' $ laFileList[lnPtr, 5]
* Get directory name.
lcDir = laFileList[lnPtr, 1]
* Ignore current and parent directory pointers.
IF lcDir != '.' AND lcDir != '..'
* Move the first child level folder names into the permanent array
lnDirs = lnDirs + 1
IF !EMPTY(laDirListing[1])
DIMENSION laDirListing[ALEN(laDirListing)+1]
ENDIF
laDirListing[ALEN(laDirListing)] = lcFullPathDir + "\" + ALLTRIM(laFileList[lnPtr,1])
ENDIF
ENDIF
ENDFOR
IF lnDirs = 0
* If there are no folders, return now.
RETURN 0
ENDIF
* We have some folders in the first directory we wanted and they are in the permanent array.
* Now traverse the permanent array, looking for subfolders.
IF lbInit
j = ALEN(laDirListing)
lnTempi = 1
DO WHILE lnTempi <= j
lnRetVal = Recurse(laDirListing[lnTempi], .F.)
j = ALEN(laDirListing)
lnTempi = lnTempi + 1
ENDDO
ENDIF
RETURN ALEN(laDirListing)
ENDFUNC
****************************************