Obtaining a list of subdirectories (OpenInsight 16-Bit Specific)
At 12 MAR 2003 02:21:54AM Godfrey Farrugia wrote:
Is there a way to obtain a list of subdirectories? I've tried the following but it doesn't seem to work:
SetInitDirOptions("D")
initdir driv
List="
loop
SubList=DirList()until SubList="
List=SubListrepeat
Thanks
At 12 MAR 2003 05:55AM Oystein Reigem wrote:
Godfrey,
It might be an old problem. See Cameron Purdy's posting and Sprezzatura's subsequent reply.
Myself I often use Sprezzatura's Utility32 for stuff like this. But here's a function I just made for you. It works by letting DirList() find everything, pick out the folders and skip the files. I took it from some old programming where I needed the opposite of what you do - the files and not the folders:
function My_DirList( FolderName )
SubFolderNames="
InitDir FolderName : "\*.*"
loop
FileNames=DirList()
while FileNames
for I=1 to count(FileNames, @FM) + 1
FileName=FileNames[i]
FullName=FolderName : "\" : FileName
DirInfo=Dir(FullName)
Size=DirInfo /* file size. only files, not folders, have file size */
if][size=" then
SubFolderNames=FileName
end
next I
repeat
return SubFolderNames
I leave it to you to test it properly.
- Oystein -
At 12 MAR 2003 09:01AM Don Miller - C3 Inc. wrote:
Oystein ..
This is exactly what I do, too. It IS possible the get a zero-length data file this way. You can also check to see whether the extension is null, but this is no guarantee either. It's possible to retrieve the info with DIR *.*/AD which will only retrieve items whose file attribute is Directory.
Don M.
At 12 MAR 2003 01:47PM Oystein Reigem wrote:
Don,
Zero-length files… Didn't think of that.
![]()
But who got zero-length files anyway? What an absurd idea!
![]()
Hmmm… …joke aside… …I mean zero-length LH files aside… …are you sure there aren't cases where zero-length files exist and might cause trouble for this way of determining subfolders? I think I have seen files show up in Explorer with size 0 just after they were created, and before they were written and closed. So what if our subfolder determining functions pick up such unfinished files, say from other users on the server in a multi-user environment, or from other running programs, and mistake them for folders? Is that possible?
- Oystein -
At 12 MAR 2003 01:59PM Matt Sorrell wrote:
Wouldn't it depend on how you are doing your comaparison? I'm not familiar with the file size value returned for directories. If it returns a NULL for a directory, then you should still be okay. The file size for a 0 byte file would still be zero. The only thing that should hurt you in that case is if said Not(FileSize), because then NULL and 0 would evaluate the same. But, if you compare to NULL, then you should be alright.
My $0.02 worth.
At 12 MAR 2003 02:07PM Don Miller - C3 Inc. wrote:
Oystein ..
]Zero-length files… Didn't think of that.
![]()
]But who got zero-length files anyway? What an absurd idea!
![]()
Well .. there are any number of them around, particularly in Windows where a file gets created but not written to.
OSOPEN "FOO" TO FILE_OUT THEN
OSWRITE "" TO FILE_OUTOSCLOSE FILE_OUTEND
That makes a zero-length file with no extension. If you forget to delete it, then it's your red wagon.
]Hmmm… …joke aside… …I mean zero-length LH files aside… …are you sure there aren't cases where zero-length files exist and might cause trouble for this way of determining subfolders? I think I have seen files show up in Explorer with size 0 just after they were created, and before they were written and closed. So what if our subfolder determining functions pick up such unfinished files, say from other users on the server in a multi-user environment, or from other running programs, and mistake them for folders? Is that possible?
Well ..
The way I sometimes do this is via a call to the DOS processor:
DIR \MYPATH\*.* /AD ]] JUNK.TXT
Then I parse the text file
Here's a sample:
DIR C:\*.* /AD ]] JUNK.TXT
EDIT JUNK.TXT
Volume in drive C is DCMDEV
Volume Serial Number is 1443-12FC
Directory of C:\
WINDOWS 01-09-01 11:45a WINDOWS
ATI 01-09-01 12:07p ATI
ACROBAT3 01-09-01 1:15p ACROBAT3
MYDOCU~1 01-09-01 12:03p My Documents
PROGRA~1 01-09-01 11:45a Program Files
SPARAM 03-19-01 1:40p SPARAM
CANON DRV 01-09-01 1:15p CANON.DRV
CWSOUNDS 01-09-01 1:15p CWSOUNDS
GREV 01-09-01 1:15p GREV
MSOFFICE 01-09-01 1:15p MSOffice
MYMUSI~1 01-09-01 1:15p My Music
NETSPOT 01-09-01 1:15p NETSPOT
NOVELL 01-09-01 1:15p NOVELL
WINZIP 01-09-01 1:15p winzip
RECYCLED 01-09-01 1:35p RECYCLED
NCDTREE 01-12-01 1:58p NCDTREE
INSECURE 10-29-02 1:10p insecure
REVNPP 11-21-02 9:17a REVNPP
BRIDGE 02-19-02 12:32p BRIDGE
AOLEXT~1 01-18-01 3:17p aolextras
AOLINS~1 01-18-01 3:17p AOL Instant Messenger
TEMP 01-29-01 11:49a temp
INSTAL~2 01-18-01 3:17p Install ICQ
INSTAL~3 01-18-01 3:17p Install Spinner
INSTAL~4 01-18-01 3:17p Install Winamp
GRPHFLT 03-29-01 3:38p GRPHFLT
INCOMP~1 04-24-01 10:23a Incomplete
SPYGURU 03-13-01 9:39a SpyGuru
FONTS 04-26-01 12:00p fonts
XQXSETUP 05-31-01 3:21p xqxsetup
CABS 07-11-01 2:17p Cabs
OIPINST 12-31-02 11:48a OIPINST
PROGRAMF 12-31-02 12:01p PROGRAMF
UPGRADE 01-11-02 10:34a UPGRADE
SWMAP 01-15-02 9:45a SWMap
AOLDOW~1 07-16-02 1:32p AOL Downloads
KODAK_~1 04-22-02 9:27a KODAK_Pictures
KODAKP~1 04-22-02 9:31a Kodak Picture CD
AOLSAV~1 04-29-02 10:14a AOL Saved PFC
RBACKUPS 07-08-02 9:58a RBackups
MYDOWN~1 11-08-02 8:47a My Downloads
DJ940C 07-22-02 2:10p Dj940c
AOLSHARE 08-02-02 12:05p AOLSHARE
BANJOB~1 08-02-02 3:27p banjobackup
BANJOB~2 08-05-02 9:22a banjobackup2
WUTEMP 02-06-03 7:41a WUTemp
TABVIEW 09-04-02 10:23a Tabview
BB 10-01-02 9:25a BB
PRINTS~1 10-10-02 9:53a PrintScreen
MYROBO~1 10-16-02 2:36p My RoboForm Data
NEWCAN~1 12-26-02 11:48a NewCanonPrinter
FILESIZE 02-14-03 7:48a FileSize
FILETIP 02-14-03 10:08a FileTip
WMMATCH 02-14-03 10:14a WmMatch
INSTAL~1 0 03-12-03 9:28a Install CompuServe7.0
0 file(s) 0 bytes55 dir(s) 13,050.89 MB freeNotice that even directory entries with extensions get picked up. Also, note that in the 5th column you can get the long-filename as a side benefit.
Don M.
At 12 MAR 2003 03:26PM Justin Case wrote:
Function Directories(Root)
* Returns an FM delimited list of directories in Root
If RootLen(Root),1 # "\" Then
Root=Root:"\"End
InitDir Root:"*."; * Just like Unix….
Return DirList()
At 13 MAR 2003 05:54AM Oystein Reigem wrote:
Justin,
I tried your version on a folder containing a LH volume, with interesting results. The folder contained a lot of size 0 OV files and a size 0 REVLOCKS file. It erroneously identified REVLOCKS as a directory, but not the OV files.
I wish somebody could put this stuff out of its misery.
- Oystein -
At 13 MAR 2003 05:56AM Oystein Reigem wrote:
Matt,
I think you're right.
I do hope you're right.
- Oystein -
At 13 MAR 2003 05:58AM Oystein Reigem wrote:
Don,
Not nice, but OK if it works.
Are there problems with different versions of Windows, or different formatting in different countries?
- Oystein -
At 13 MAR 2003 09:03AM Don Miller - C3 Inc. wrote:
Oystein ..
The honest answer is "I don't know!" I don't have any need for multi-lingual support and all the headaches it has brought over the past.
Maybe someone else will know .. or you could try it yourself since you seem to have a lot of language-sets to deal with. Just imagine what it would be like in Farsi ..
Don M.
At 17 MAR 2003 10:53AM Godfrey Farrugia wrote:
Many thanks for all your responses. However, I found that the easiest way was to create a DOS textfile on-the-fly and then manipulate that to get what I want. It would be nice to have such a basic service, i.e. obtaining a list of sub-folders, within the INITDIR command itself though.