|
PowerBASIC Forums
![]() PowerBASIC Console Compiler
![]() Dir$
|
| next newest topic | next oldest topic |
| Author | Topic: Dir$ |
|
Bob Westbrook unregistered |
Does dir$ work by reading the fat file? Can it be used to compile directories as well as files? If not is there a function that does? Bob Westbrook ------------------ IP: Logged |
|
Lance Edmonds Member |
IN PB/CC, DIR$ reports files, directories, and the volume label. However, it does not perform direct disk access - no Windows applications (ring-3) can or should. That is, DIR$ uses the Windows API to operate. If you are after direct disk access, you might research using Ring-0 (ie, device driver or kernel-mode driver) to do it. Info on direct hardware and port access can be found at www.lvr.com ------------------ IP: Logged |
|
Bob Westbrook unregistered |
Lance: Using the dir$ exemplar in the help file, I don't see how one Can you direct? Bob ------------------ IP: Logged |
|
Tom Hanlin Member |
See Samples\Util\FileFind.bas for fancier work. ------------------ IP: Logged |
|
Eros Olmi Member |
Tom, in your example, DIR$ returns both directories and files. Regards
[This message has been edited by Eros Olmi (edited July 28, 2002).] IP: Logged |
|
Mel Bishop Member |
quote: For each DIR$ envoked, check the attribute bit. I can't remember Normally, a directory will have an attribute of 16. The function ------------------ IP: Logged |
|
Lance Edmonds Member |
Filenames of "regular" files are always returned, in addition to those with the specified attribute. See "DIR$ function" in the doc's for more information. To filter out directories, use a simple bitwise evaluation within the loop:
------------------ IP: Logged |
|
Tom Hanlin Member |
You may also wish to screen out the virtual directories, "." and "..". Check for them by exact name, since it's quite valid for a filename to start with ".", these days. ------------------ IP: Logged |
|
Bob Westbrook unregistered |
f$ = DIR$(mask$, %subdir) The %subdir feature here returns all of the files AND directories I installed the Getattr feature and it returns the attr correctly. I'm curious the image.dat file returns an attr of 33. Not listed What is 33? Bob ------------------ IP: Logged |
|
Bob Westbrook unregistered |
using the getattr function on my c:\ directory, I note that a system file setuplog.txt is being returned as a 16 attribute. Clearly not a directory. Is there a way to get around this? Bob ------------------ IP: Logged |
|
Tom Hanlin Member |
As explained in the help file, attributes are additive. That's why Lance's example uses AND to test for a specific flag. 33 decomposes to 32 (%ARCHIVE) + 1 (%READONLY). 16 (%SUBDIR) will never be returned for anything but a subdirectory. That is, gotta be this: IF (GETATTR(f$) AND %SUBDIR) THEN Not this: IF GETATTR(f$) AND %SUBDIR THEN ------------------ IP: Logged |
All times are EasternTime (US) | next newest topic | next oldest topic |
![]() |
|
Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.