Revision history for KeyPgDir


Revision [21746]

Last edited on 2017-03-13 06:00:57 by CountingPine [Add a little whitespacing for clearer code alignment]
Additions:
Searches for and returns information about an item in the filesystem; performs a directory searchattrib
If (out_attr And fbHidden ) <> 0 Then Print ", hidden";
If (out_attr And fbSystem ) <> 0 Then Print ", system";
If (out_attr And fbArchive ) <> 0 Then Print ", archived";
Deletions:
Searches for and returns information about an item in the filesystem; performs a directory search
If (out_attr And fbHidden) <> 0 Then Print ", hidden";
If (out_attr And fbSystem) <> 0 Then Print ", system";
If (out_attr And fbArchive) <> 0 Then Print ", archived";


Revision [21673]

Edited on 2016-11-07 06:45:23 by fxm [Formatting]
Additions:







Revision [21293]

Edited on 2016-04-01 09:23:38 by fxm [Added link to CHDIR]
Additions:
- ##[[KeyPgChdir|Chdir]]##


Revision [20906]

Edited on 2016-03-12 17:00:45 by fxm [Formatting]
Additions:













Revision [20202]

Edited on 2016-02-10 15:59:12 by DkLwikki [Update link format]
Additions:
# [[KeyPgInclude|include]] "dir.bi"
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Dir** ( [[KeyPgByref|byref]] //item_spec// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]], [[KeyPgByval|byval]] //attrib_mask// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = **fbNormal**, [[KeyPgByref|byref]] //out_attrib// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] [[KeyPgString|string]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Dir** ( [[KeyPgByref|byref]] //item_spec// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]], [[KeyPgByval|byval]] //attrib_mask// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = **fbNormal**, [[KeyPgByval|byval]] //p_out_attrib// [[KeyPgAs|as]] [[KeyPgInteger|integer]] [[KeyPgPtr|ptr]] = 0 ) [[KeyPgAs|as]] [[KeyPgString|string]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Dir** ( [[KeyPgByval|byval]] //attrib_mask// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = **fbNormal**, [[KeyPgByref|byref]] //out_attrib// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgAs|as]] [[KeyPgString|string]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Dir** ( [[KeyPgByval|byval]] //attrib_mask// [[KeyPgAs|as]] [[KeyPgInteger|integer]] = **fbNormal**, [[KeyPgByval|byval]] //p_out_attrib// [[KeyPgAs|as]] [[KeyPgInteger|integer]] [[KeyPgPtr|ptr]] = 0 ) [[KeyPgAs|as]] [[KeyPgString|string]]
If ##//item_spec//## contains an absolute path, then the first procedure searches the filesystem for an item that matches the name ##//item_spec//## and whose attributes are all contained in ##//attrib_mask//##. Otherwise, it searches relative to the current directory (see ##[[KeyPgCurdir|CurDir]]##). In any case, if a matching item is not found, ##//out_attrib//## is assigned to zero and an empty string is returned. Otherwise, ##//out_attrib//## is assigned with the attribute flags of the item, and the name of the item, without a path, is returned.
The following defined constants are used as bit-flags in ##//attrib_mask//## and in ##//out_attrib//## or ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr|Operator Or]]##. These values are the metadata that the returned files are **allowed** to have. For example, ##fbDirectory## will only allow the directory attribute not to be set, meaning that only files or directories with no other attributes set will be matched. ##(fbReadOnly [[KeyPgOpOr|Or]] fbDirectory)## will allow read-only directories and files, and writable directories and files.
More powerful filtering can be done by checking the returned ##//out_attrib//## for specifc flags using ##[[KeyPgOpAnd|Operator And]]##. To access the defined flags, you must ##[[KeyPgInclude|#Include]] "dir.bi"##.
Items found having no attributes are **always** matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##. For example, ##//fbArchive// [[KeyPgOpOr|Or]] //fbDirectory//## will match against archived files, archived directories, non-archived files and non-archived directories. It will not match against, for example, read-only files.
Print fname,
If (out_attr And fbDirectory) <> 0 Then
Print "- directory";
dircount += 1
Else
Print "- file";
filecount += 1
End If
If (out_attr And fbReadOnly) <> 0 Then Print ", read-only";
If (out_attr And fbHidden) <> 0 Then Print ", hidden";
If (out_attr And fbSystem) <> 0 Then Print ", system";
If (out_attr And fbArchive) <> 0 Then Print ", archived";
Print
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Dir""**##.
- ##[[KeyPgOpen|Open]]##
- ##[[KeyPgCurdir|Curdir]]##
- ##[[KeyPgMkdir|Mkdir]]##
- ##[[KeyPgRmdir|Rmdir]]##
Deletions:
# [[KeyPgInclude include]] "dir.bi"
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //item_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //item_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
If ##//item_spec//## contains an absolute path, then the first procedure searches the filesystem for an item that matches the name ##//item_spec//## and whose attributes are all contained in ##//attrib_mask//##. Otherwise, it searches relative to the current directory (see ##[[KeyPgCurdir CurDir]]##). In any case, if a matching item is not found, ##//out_attrib//## is assigned to zero and an empty string is returned. Otherwise, ##//out_attrib//## is assigned with the attribute flags of the item, and the name of the item, without a path, is returned.
The following defined constants are used as bit-flags in ##//attrib_mask//## and in ##//out_attrib//## or ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. These values are the metadata that the returned files are **allowed** to have. For example, ##fbDirectory## will only allow the directory attribute not to be set, meaning that only files or directories with no other attributes set will be matched. ##(fbReadOnly [[KeyPgOpOr Or]] fbDirectory)## will allow read-only directories and files, and writable directories and files.
More powerful filtering can be done by checking the returned ##//out_attrib//## for specifc flags using ##[[KeyPgOpAnd Operator And]]##. To access the defined flags, you must ##[[KeyPgInclude #Include]] "dir.bi"##.
Items found having no attributes are **always** matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##. For example, ##//fbArchive// [[KeyPgOpOr Or]] //fbDirectory//## will match against archived files, archived directories, non-archived files and non-archived directories. It will not match against, for example, read-only files.
Print fname,
If (out_attr And fbDirectory) <> 0 Then
Print "- directory";
dircount += 1
Else
Print "- file";
filecount += 1
End If
If (out_attr And fbReadOnly) <> 0 Then Print ", read-only";
If (out_attr And fbHidden) <> 0 Then Print ", hidden";
If (out_attr And fbSystem) <> 0 Then Print ", system";
If (out_attr And fbArchive) <> 0 Then Print ", archived";
Print
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Dir""**##.
- ##[[KeyPgOpen Open]]##
- ##[[KeyPgCurdir Curdir]]##
- ##[[KeyPgMkdir Mkdir]]##
- ##[[KeyPgRmdir Rmdir]]##


Revision [17669]

Edited on 2015-06-12 05:53:51 by FxMwikki [Suppressed the no-relevant keyword 'Overload' in Syntax]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //item_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload overload]] ( [[KeyPgByref byref]] //item_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]


Revision [16979]

Edited on 2013-11-24 10:58:48 by CountingPine [More explicit info about how attrib_mask works.]
Additions:
##//item_spec//## may include an asterisk (##*##, for matching any adjacent characters) or one or more question marks (##?##, for matching any individual character). If it does, the procedure searches for the first such item. If found, subsequent calls with ##//item_spec//## omitted, or set to an empty string, will return the next item matching the name ##//item_spec//## until no more such items are found. If ##//attrib_mask//## is omitted from these subsequent calls, the procedure searches for items with the same attributes as in the previous call.
The second syntax behaves the same as ##**Dir**( //item_spec//, //attrib_mask//, *//p_out_attrib// )##.
The third syntax behaves the same as ##**Dir**( "####", , //out_attrib// )##.
The fourth syntax behaves the same as ##**Dir**( "####", , *//p_out_attrib// )##.
Files and directories and other items can be said to possess so-called file attributes; metadata that describes the item. The meaning of this metadata may vary depending on the operating system and the file system it uses.
The following defined constants are used as bit-flags in ##//attrib_mask//## and in ##//out_attrib//## or ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. These values are the metadata that the returned files are **allowed** to have. For example, ##fbDirectory## will only allow the directory attribute not to be set, meaning that only files or directories with no other attributes set will be matched. ##(fbReadOnly [[KeyPgOpOr Or]] fbDirectory)## will allow read-only directories and files, and writable directories and files.
More powerful filtering can be done by checking the returned ##//out_attrib//## for specifc flags using ##[[KeyPgOpAnd Operator And]]##. To access the defined flags, you must ##[[KeyPgInclude #Include]] "dir.bi"##.
Deletions:
##//item_spec//## may include an asterisk (##*##, for matching any adjacent characters) or one or more question marks (##?##, for matching any individual character). If it does, the procedure searches for the first such item. If found, subsequent calls with ##//item_spec//## equal to an empty string will return the next item matching the name ##//item_spec//## until no more such items are found. If ##//attrib_mask//## is omitted from these subsequent calls, the procedure searches for items with the same attributes as in the previous call.
The second procedure behaves the same as ##**Dir**( //item_spec//, //attrib_mask//, *//p_out_attrib// )##.

The third procedure behaves the same as ##**Dir**( "####", , //out_attrib// )##.
The fourth procedure behaves the same as ##**Dir**( "####", , *//p_out_attrib// )##.
Files and directories and other items can be said to possess so-called file attributes; metadata that describes the item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##, or individual values can be checked using ##[[KeyPgOpAnd Operator And]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.


Revision [16805]

Edited on 2013-05-09 12:06:03 by CountingPine [Subtle emphasis]
Additions:
Items found having no attributes are **always** matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##. For example, ##//fbArchive// [[KeyPgOpOr Or]] //fbDirectory//## will match against archived files, archived directories, non-archived files and non-archived directories. It will not match against, for example, read-only files.
Deletions:
Items found having no attributes are always matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##. For example, ##//fbArchive// [[KeyPgOpOr Or]] //fbDirectory//## will match against archived files, archived directories, non-archived files and non-archived directories. It will not match against, for example, read-only files.


Revision [16224]

Edited on 2012-07-25 09:46:48 by CountingPine [Some rewording, try to explain better how attributes work/don't work]
Additions:
//The item is read-only or "archived".//
(If ##//attrib_mask//## does not include ##**fbArchive**##, then ##**Dir**## may widen the check to include ##**fbDirectory**##, but it is recommended to add ##**fbDirectory**## explicitly, if that is the behaviour sought.)
Items found having no attributes are always matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##. For example, ##//fbArchive// [[KeyPgOpOr Or]] //fbDirectory//## will match against archived files, archived directories, non-archived files and non-archived directories. It will not match against, for example, read-only files.
In general it is not possible to use ##//attrib_mask//## to include a file/folder with one set of attributes while excluding a file/folder with a different set. For example, it is not possible to scan for read-only directories while excluding read-only files (unless the files also have other attributes). Finer control can be gained by checking the ##//out_attrib//## value for the desired set of attributes.
Deletions:
//The item is a file or directory.//
Items found having no attributes are always matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##.
If ##//attrib_mask//## does not include ##**fbArchive**##, then ##**Dir**## may widen the check to include ##**fbDirectory**##, but it is recommended to add ##**fbDirectory**## explicitly, if that is the behaviour sought. Finer control can be gained by checking the ##//out_attrib//## value for the desired set of attributes.


Revision [16102]

Edited on 2012-02-05 15:06:54 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
do while len(filename) > 0 ' If len(filename) is 0, exit the loop: no more filenames are left to be read.
Deletions:
do while len(filename) ' If len(filename) is 0, exit the loop: no more filenames are left to be read.


Revision [16101]

Edited on 2012-02-05 14:41:36 by MySoft [Some rewording, try to explain better how attributes work/don't work]
Additions:
do while len(filename) ' If len(filename) is 0, exit the loop: no more filenames are left to be read.
Deletions:
do while len(filename) > 0 ' If len(filename) is 0, exit the loop: no more filenames are left to be read.


Revision [16100]

Edited on 2012-02-05 14:36:01 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
Searches for and returns information about an item in the filesystem; performs a directory search
Deletions:
Searches for and returns information about an item in the filesystem; performs a directory search.


Revision [16096]

Edited on 2012-02-05 14:33:27 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
Searches for and returns information about an item in the filesystem; performs a directory search.
dim as string filename = dir(filespec, attrib) ' Start a file search with the specified filespec/attrib *AND* get the first filename.
Deletions:
Searches for and returns information about an item in the filesystem, performs a directory search.
dim as string filename = dir(filespec, attrib) ' Sets the filespec/attrib to search for *AND* gets the first filename.


Revision [16091]

Edited on 2012-02-05 14:19:47 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
dim as string filename = dir(filespec, attrib) ' Sets the filespec/attrib to search for *AND* gets the first filename.
Deletions:
dim as string filename = dir(filespec, attrib) ' Sets the filespec/attrib *AND* gets the first filename.


Revision [16090]

Edited on 2012-02-05 14:13:12 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
do while len(filename) > 0 ' If len(filename) is 0, exit the loop: no more filenames are left to be read.
loop
Deletions:
if len(filename) = 0 then exit sub ' No files matched: exit.
do
loop while len(filename) > 0 ' If len(filename) is 0, exit do: no more filenames are left to read.


Revision [16089]

Edited on 2012-02-05 14:08:40 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
if len(filename) = 0 then exit sub ' No files matched: exit.
Deletions:
if len(filename) = 0 then exit sub ' No files matched: exit.


Revision [16088]

Edited on 2012-02-05 14:06:52 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
if len(filename) = 0 then exit sub ' No files matched: exit.


Revision [16087]

Edited on 2012-02-05 14:03:34 by AgAmemnus [Some rewording, try to explain better how attributes work/don't work]
Additions:
do
Deletions:
do


Revision [16086]

Edited on 2012-02-05 14:02:53 by AgAmemnus [Fine. I'll add comments.]
Additions:
dim as string filename = dir(filespec, attrib) ' Sets the filespec/attrib *AND* gets the first filename.
do
loop while len(filename) > 0 ' If len(filename) is 0, exit do: no more filenames are left to read.
Deletions:
dim as string filename = dir(filespec,attrib)
while len(filename)
wend


Revision [16068]

Edited on 2012-02-03 17:39:18 by MySoft [duh, the loser way.... and len() is faster than = "" to verify empty strings, as well maybe teach so]
Additions:
dim as string filename = dir(filespec,attrib)
while len(filename)
print filename
filename = dir()
wend
Deletions:
dim filename as string
do
if filename = "" then filename = dir(filespec, attrib) else filename = dir()
if filename = "" then exit do
print filename
loop


Revision [16067]

Edited on 2012-02-03 17:28:18 by AgAmemnus [The logic of getting and testing the dir was split up into three parts (two in loop, one outside) No]
Additions:
sub list_files (byref filespec as string, byval attrib as integer)
dim filename as string
do
if filename = "" then filename = dir(filespec, attrib) else filename = dir()
if filename = "" then exit do
print filename
loop
end sub
print "directories:"
print
print "archive files:"
Deletions:
Sub list_files (byref filespec as string, byval attrib as integer)
Dim filename As String
filename = dir( filespec, attrib )
Do
Print filename
filename = dir( )
Loop While len( filename ) > 0
End Sub
Print "directories:"
Print "archive files:"


Revision [15131]

Edited on 2011-07-27 05:46:34 by CountingPine ['if a and b' to 'if (a and b)<>0' in example, some changes to text]
Additions:
Pointer to a bit mask that's assigned each of the found item's attributes, if any.
Files and directories and other items can be said to possess so-called file attributes; metadata that describes the item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##, or individual values can be checked using ##[[KeyPgOpAnd Operator And]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.
Items found having no attributes are always matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##.
If ##//attrib_mask//## does not include ##**fbArchive**##, then ##**Dir**## may widen the check to include ##**fbDirectory**##, but it is recommended to add ##**fbDirectory**## explicitly, if that is the behaviour sought. Finer control can be gained by checking the ##//out_attrib//## value for the desired set of attributes.
If (out_attr And fbDirectory) <> 0 Then
If (out_attr And fbReadOnly) <> 0 Then Print ", read-only";
If (out_attr And fbHidden) <> 0 Then Print ", hidden";
If (out_attr And fbSystem) <> 0 Then Print ", system";
If (out_attr And fbArchive) <> 0 Then Print ", archived";
Deletions:
The address of a bit mask that's assigned each of the found item's attributes, if any.
Files and directories and other items can be said to possess so-called file attributes; metadata that describes the item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.
Items found having no attributes are always matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##. Further, if ##//attrib_mask// [[KeyPgOpAnd And]] **fbArchive**## is zero, then ##//attrib_mask//## is assigned to ##//attrib_mask// [[KeyPgOpOr Or]] **fbDirectory**## before checking the file for matching attributes.
If out_attr And fbDirectory Then
If out_attr And fbReadOnly Then Print ", read-only";
If out_attr And fbHidden Then Print ", hidden";
If out_attr And fbSystem Then Print ", system";
If out_attr And fbArchive Then Print ", archived";


Revision [15062]

Edited on 2011-04-01 14:36:15 by LaananFisher [fixed: some typo]
Additions:
Files and directories and other items can be said to possess so-called file attributes; metadata that describes the item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.
Deletions:
Files and directories and other items can be said to possess so-called file attributes; metadata that describes item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.


Revision [15042]

Edited on 2011-02-24 03:16:23 by DoS386 [you can't randomly change the "D" attrib , please finalize the fix about input attributes]
Additions:
**DOS & Windows & Linux**: The item is a directory.
**DOS & Windows**: The item has the "archive" attribute set (automatically set after every write access to a file).
Deletions:
**DOS & Windows**: The item has the "directory" attribute set.
**Linux**: The item is a directory.
**DOS & Windows**: The item has the "archive" attribute set.


Revision [14514]

Edited on 2009-11-05 23:35:45 by DoS386 [no it doesn't return both, and risk of mess]
Additions:
- In DOS, the attrib mask value of ##&h37## (##&h3F## usually works also, but ##&h37## is safer) returns all files and directories, including "." and "..", but no Volume: the value ##8## returns the Volume, even if current directory is not the main directory.
Deletions:
- In DOS, an attrib mask value of ##&h8## returns the Volume, even if current directory is not the main directory. The value ##&h37## (##&h3f [[KeyPgOpAnd And]] [[KeyPgOpNot Not]] &h8##) can be used to return all files and directories, including ##.## and ##..##, but no Volume. A value of ##&h3f## returns both.


Revision [14212]

Edited on 2009-08-15 11:21:26 by CountingPine [name case fixup]
Additions:
- In DOS, an attrib mask value of ##&h8## returns the Volume, even if current directory is not the main directory. The value ##&h37## (##&h3f [[KeyPgOpAnd And]] [[KeyPgOpNot Not]] &h8##) can be used to return all files and directories, including ##.## and ##..##, but no Volume. A value of ##&h3f## returns both.
Deletions:
- In DOS, an attrib mask value of ##&h8## returns the Volume, even if current directory is not the main directory. The value ##&h37## (##&h3f [[KeyPgOpand And]] [[KeyPgOpNot Not]] &h8##) can be used to return all files and directories, including ##.## and ##..##, but no Volume. A value of ##&h3f## returns both.


Revision [14185]

Edited on 2009-06-29 01:23:34 by CountingPine [name case fixup]
Additions:
**Linux**:The item has no write permissions associated with the current user or group, nor is it globally writable. (Whether or not the user has root permissions is ignored.)
- Path separators in Linux are forward slashes ##/##. Windows uses backslashes ##\## but it allows for forward slashes. DOS uses backslashes.
- In DOS, an attrib mask value of ##&h8## returns the Volume, even if current directory is not the main directory. The value ##&h37## (##&h3f [[KeyPgOpand And]] [[KeyPgOpNot Not]] &h8##) can be used to return all files and directories, including ##.## and ##..##, but no Volume. A value of ##&h3f## returns both.
- Not found in ""QBasic"" but present in Visual Basic. The ##//out_attrib//## parameter is new to ""FreeBASIC"".
Deletions:
**Linux**:The item has no write permissions associated with the current user or group, nor is it globally writable.
- Path separators in Linux are forward slashes (##"/"##). Windows uses backslashes (##"\"##) but it allows for forward slashes. DOS uses backslashes.
- In DOS, the attrib mask value of &h37 (&h3F usually works also, but &h37 is safer) returns all files and directories, including "." and "..", but no Volume: the value 8 returns the Volume, even if current directory is not the main directory.
- The ##//attrib_mask//## and ##//out_attrib//## parameters are new to ""FreeBASIC"".


Revision [14160]

Edited on 2009-06-14 06:22:36 by DoS386 [re-added stuff]
Additions:
Searches for and returns information about an item in the filesystem, performs a directory search.
- In DOS, the attrib mask value of &h37 (&h3F usually works also, but &h37 is safer) returns all files and directories, including "." and "..", but no Volume: the value 8 returns the Volume, even if current directory is not the main directory.
Deletions:
Searches for and returns information about an item in the filesystem.


Revision [14159]

Edited on 2009-06-13 11:30:16 by LaananFisher [fixed: fbDirectory matches "." and ".." too.]
Additions:
//The item is a directory. Includes the current (##.##) and parent (##..##) directories as well.//
Deletions:
//The item is a directory.//


Revision [14158]

Edited on 2009-06-13 10:20:49 by LaananFisher [fixed: clarified attrib matching behavior]
Additions:
Files and directories and other items can be said to possess so-called file attributes; metadata that describes item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.
Items found having no attributes are always matched, regardless of the value of ##//attrib_mask//##. An item will not be matched if it has one or more attributes that aren't specified in ##//attrib_mask//##. Further, if ##//attrib_mask// [[KeyPgOpAnd And]] **fbArchive**## is zero, then ##//attrib_mask//## is assigned to ##//attrib_mask// [[KeyPgOpOr Or]] **fbDirectory**## before checking the file for matching attributes.
Deletions:
In all procedures, if ##//attrib_mask// [[KeyPgOpAnd And]] **fbArchive**## is zero, then ##//attrib_mask//## is assigned to ##//attrib_mask// [[KeyPgOpOr Or]] **fbDirectory**## before checking the file for matching attributes.
Files and directories and other items can be said to possess so-called file attributes; metadata that describes item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##, and their platform-specific meanings are also listed. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.


Revision [14157]

Edited on 2009-06-13 09:52:02 by LaananFisher [fixed: added behavior with no fbArchive flag set]
Additions:
In all procedures, if ##//attrib_mask// [[KeyPgOpAnd And]] **fbArchive**## is zero, then ##//attrib_mask//## is assigned to ##//attrib_mask// [[KeyPgOpOr Or]] **fbDirectory**## before checking the file for matching attributes.
**Linux**: The item is not a directory; typical filesystems do not support this metadata.
Deletions:
**Linux**: The item is not a directory; typical filesystems do not recognize this as a property.


Revision [14154]

Edited on 2009-06-11 21:23:41 by LaananFisher [updated; clear desc. of behavior and Linux attributes]
Additions:
Searches for and returns information about an item in the filesystem.
# [[KeyPgInclude include]] "dir.bi"
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload overload]] ( [[KeyPgByref byref]] //item_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //item_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]], [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = **fbNormal**, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
//result// = **Dir**( //item_spec//, [ //attrib_mask// ], //out_attrib// ] )
//result// = **Dir**( //item_spec// [, [ //attrib_mask// ] [, //p_out_attrib// ] ] )
//result// = **Dir**( //out_attrib// )
//result// = **Dir**( [ //p_out_attrib// ] )
##//item_spec//##
The pattern to match an item's name against.
The bit mask to match an item's attributes against.
Reference to a bit mask that's assigned each of the found item's attributes, if any.
The address of a bit mask that's assigned each of the found item's attributes, if any.
If no item matching the name ##//item_spec//## or the attribute mask ##//attrib_mask//## was found, then ##//out_attrib//## (or ##*//p_out_attrib//##) is assigned to zero and an empty string is returned. Otherwise, ##//out_attrib//## (or ##*//p_out_attrib//##) is assigned the attribute mask of the item, and the item name, without a path, is returned.
If ##//item_spec//## contains an absolute path, then the first procedure searches the filesystem for an item that matches the name ##//item_spec//## and whose attributes are all contained in ##//attrib_mask//##. Otherwise, it searches relative to the current directory (see ##[[KeyPgCurdir CurDir]]##). In any case, if a matching item is not found, ##//out_attrib//## is assigned to zero and an empty string is returned. Otherwise, ##//out_attrib//## is assigned with the attribute flags of the item, and the name of the item, without a path, is returned.
##//item_spec//## may include an asterisk (##*##, for matching any adjacent characters) or one or more question marks (##?##, for matching any individual character). If it does, the procedure searches for the first such item. If found, subsequent calls with ##//item_spec//## equal to an empty string will return the next item matching the name ##//item_spec//## until no more such items are found. If ##//attrib_mask//## is omitted from these subsequent calls, the procedure searches for items with the same attributes as in the previous call.
The second procedure behaves the same as ##**Dir**( //item_spec//, //attrib_mask//, *//p_out_attrib// )##.
The third procedure behaves the same as ##**Dir**( "####", , //out_attrib// )##.
The fourth procedure behaves the same as ##**Dir**( "####", , *//p_out_attrib// )##.
**File Attributes:**
Files and directories and other items can be said to possess so-called file attributes; metadata that describes item. The meaning of this metadata varies with operating system and the file system it uses. The following macros are used as bit-flags with ##//attrib_mask//##, ##//out_attrib//## and ##*//p_out_attrib//##, and their platform-specific meanings are also listed. Their values can be combined to form a mask using ##[[KeyPgOpOr Operator Or]]##. To access them, ##[[KeyPgInclude Include]] "dir.bi"##.
## # define fbReadOnly &h01 ##
//The item cannot be written to or deleted.//
**DOS & Windows**: The item has the "read-only" attribute set.
**Linux**:The item has no write permissions associated with the current user or group, nor is it globally writable.
## # define fbHidden &h02 ##
//The item is hidden in ordinary directory listings.//
**DOS & Windows**: The item has the "hidden" attribute set.
**Linux**: The item's name has a period (##.##) as the first character.
## # define fbSystem &h04 ##
//The item is used almost exclusively by the system.//
**DOS & Windows**: The item has the "system" attribute set.
**Linux**: The item is either a character device, block device, named pipe (FIFO) or Unix socket.
## # define fbDirectory &h10 ##
//The item is a directory.//
**DOS & Windows**: The item has the "directory" attribute set.
**Linux**: The item is a directory.
## # define fbArchive &h20 ##
//The item may be backed up after some automated operations.//
**DOS & Windows**: The item has the "archive" attribute set.
**Linux**: The item is not a directory; typical filesystems do not recognize this as a property.
## # define fbNormal (fbReadOnly or fbArchive) ##
//The item is a file or directory.//
Deletions:
Returns a file or directory
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload Overload]] ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
//result// = **Dir**( //file_spec//, [[//attrib_mask//], //out_attrib//] )
//result// = **Dir**( //file_spec//, [[//attrib_mask//], //p_out_attrib//] )
##//or//##
//result// = **Dir**( [//out_attrib//] )
//result// = **Dir**( [//p_out_attrib//] )
##//file_spec//##
Optional ##[[KeyPgString string]]## argument specifying the name of the files or directories to be matched.
Optional ##[[KeyPgInteger integer]]## mask specifying the file attributes of the files or directories to be matched.
Optional ##[[KeyPgInteger integer]]## or ##[[KeyPgUinteger uinteger]]## which is set to the attributes of the file or directory returned.
An ##[[KeyPgInteger integer]] [[KeyPgPtr ptr]]## that can be used instead of ##//out_attrib//##, pointing to an ##[[KeyPgInteger integer]]## address where the attributes can be written.
A ##[[KeyPgString string]]## containing the name of the file or directory returned.
Returns files and/or directories that match ##//file_spec//## and ##//attrib_mask//##. The ##//file_spec//## parameter can include wildcards (##"*"## and/or ##"?"##) and paths.
The //##attrib_mask##// optional parameter is a combination of the following flags (any file with attributes not included in this parameter will be skipped over):
{{table columns="3" cellpadding="1" cells="Value;Description;Constant;&h01;Read Only;fbReadOnly;&h02;Hidden;fbHidden;&h04;System;fbSystem;&h10;Directory;fbDirectory;&h20;Archive;fbArchive;&h21;Normal;fbNormal"}}
The named constants can be used by including ##"dir.bi"##. Multiple flags can be specified by adding them together, or by combining them using the bit-wise ##[[KeyPgOpOr or]]## operator.
By default //##attrib_mask##// is set to ##&h21## (ie.: search for files with possibly the archive or read-only flags set).
The value of ##&h37## (##&h3F## usually works also, but ##&h37## is safer) returns all files and directories, including ##"."## and ##".."##, but no Volume: the value ##8## returns the Volume, even if current directory is not the main directory.
The ##//out_attrib//## optional parameter if passed will be loaded with the attributes of the file been returned.
When ##//file_spec//## is set to an empty string or no arguments are passed (or just ##//file_attrib//##), then ##**Dir**## will return the next file found.
The result will be an empty string when no files were found.


Revision [13951]

Edited on 2008-11-30 07:38:46 by JeffMarshall [name case fixup]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload Overload]] ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstQualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload Overload]] ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]


Revision [13895]

Edited on 2008-11-28 18:43:49 by LaananFisher [Fixed: const-correctness]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload Overload]] ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgConstqualifier const]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload Overload]] ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]


Revision [13627]

Edited on 2008-07-24 17:10:48 by CountingPine [Add new overload; misc changes]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** [[KeyPgOverload Overload]] ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByval byval]] //p_out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
//result// = **Dir**( //file_spec//, [[//attrib_mask//], //out_attrib//] )
//result// = **Dir**( //file_spec//, [[//attrib_mask//], //p_out_attrib//] )
//result// = **Dir**( [//out_attrib//] )
//result// = **Dir**( [//p_out_attrib//] )
Optional ##[[KeyPgInteger integer]]## or ##[[KeyPgUinteger uinteger]]## which is set to the attributes of the file or directory returned.
##//p_out_attrib//##
An ##[[KeyPgInteger integer]] [[KeyPgPtr ptr]]## that can be used instead of ##//out_attrib//##, pointing to an ##[[KeyPgInteger integer]]## address where the attributes can be written.
Returns files and/or directories that match ##//file_spec//## and ##//attrib_mask//##. The ##//file_spec//## parameter can include wildcards (##"*"## and/or ##"?"##) and paths.
The //##attrib_mask##// optional parameter is a combination of the following flags (any file with attributes not included in this parameter will be skipped over):
The named constants can be used by including ##"dir.bi"##. Multiple flags can be specified by adding them together, or by combining them using the bit-wise ##[[KeyPgOpOr or]]## operator.
By default //##attrib_mask##// is set to ##&h21## (ie.: search for files with possibly the archive or read-only flags set).
The value of ##&h37## (##&h3F## usually works also, but ##&h37## is safer) returns all files and directories, including ##"."## and ##".."##, but no Volume: the value ##8## returns the Volume, even if current directory is not the main directory.
The ##//out_attrib//## optional parameter if passed will be loaded with the attributes of the file been returned.
When ##//file_spec//## is set to an empty string or no arguments are passed (or just ##//file_attrib//##), then ##**Dir**## will return the next file found.
'' set input attribute mask to allow files that are normal, hidden, system or directory
Const attrib_mask = fbNormal Or fbHidden Or fbSystem Or fbDirectory ' = &h37
Dim As UInteger out_attr '' unsigned integer to hold retrieved attributes
Dim As String fname '' file/directory name returned with
Dim As Integer filecount, dircount
fname = Dir("*.*", attrib_mask, out_attr) '' Get first file name/attributes, according to supplied file spec and attribute mask
Print "File listing in " & CurDir & ":"
Do Until Len(fname) = 0 '' loop until Dir returns empty string
Print fname,
If out_attr And fbDirectory Then
Print "- directory";
Else
Print "- file";
End If
If out_attr And fbReadOnly Then Print ", read-only";
If out_attr And fbHidden Then Print ", hidden";
If out_attr And fbSystem Then Print ", system";
If out_attr And fbArchive Then Print ", archived";
Print
fname = Dir(out_attr) '' find next name/attributes
Print "Found " & filecount & " files and " & dircount & " subdirs"
- Linux requires the ##//filename//## case to match the real name of the file. Windows and DOS are case insensitive.
- Path separators in Linux are forward slashes (##"/"##). Windows uses backslashes (##"\"##) but it allows for forward slashes. DOS uses backslashes.
- The ##//attrib_mask//## and ##//out_attrib//## parameters are new to ""FreeBASIC"".
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByref byref]] //file_spec// [[KeyPgAs as]] [[KeyPgString string]] = "####", [[KeyPgByval byval]] //attrib_mask// [[KeyPgAs as]] [[KeyPgInteger integer]] = &h21, [[KeyPgByval byval]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Dir** ( [[KeyPgByval byval]] //out_attrib// [[KeyPgAs as]] [[KeyPgInteger integer]] [[KeyPgPtr ptr]] = 0 ) [[KeyPgAs as]] [[KeyPgString string]]
//result// = **Dir**( //file_spec//, //attrib_mask//, //out_attrib// )
//result// = **Dir**( //out_attrib// )
Optional ##[[KeyPgInteger integer]] [[KeyPgPtr ptr]]## which is set to the attributes of the file or directory returned.
Returns files and/or directories that match //file_spec// and //attrib_mask//. The //file_spec// parameter can include wildcards ("*" and/or "?") and paths.
The //attrib_mask// optional parameter is a combination of the following flags (each file with any of them set will be matched):
Constants can be used by including ##"dir.bi"##
By default //attrib_mask// is set to &h21 (ie.: search for files with possibly the archive or read-only flags set).
The value of 55 (63 usually works also, but 55 is safer) returns all files and directories, incl. "." and "..", but no Volume, the value 8 returns the Volume, even if current directory is not the main directory.
The //out_attrib// optional parameter if passed will be loaded with the attributes of the file been returned.
When //file_spec// is set to an empty string or no arguments are passed (or just //file_attrib//), then ##**Dir**## will return the next file found.
Dim As Integer out_attr '' integer to hold retrieved attributes (must currently be a signed int)
Dim As String fname '' file/directory name returned with
dim as integer filecount, dircount
fname = Dir("*.*", 55, @out_attr) '' 55 - Input ATTR mask - all files and subdirs
Print "File listing in " & curdir & ":"
Do until len(fname) = 0 '' loop until Dir returns empty string

print fname,

if out_attr and fbDirectory then
print "- directory";
else
print "- file";
end if
if out_attr and fbReadOnly then print ", read-only";
if out_attr and fbHidden then print ", hidden";
if out_attr and fbSystem then print ", system";
if out_attr and fbArchive then print ", archived";
print

fname = Dir(@out_attr) '' find next name
print
print "Found " & filecount & " files and " & dircount & " subdirs"
- Linux requires the //filename// case matches the real name of the file. Windows and DOS are case insensitive.
- Path separators in Linux are forward slashes / . Windows uses backward slashes \ but it allows for forward slashes . DOS uses backward \ slashes.
- The //attrib_mask// and //out_attrib// parameters are new to FreeBASIC


Revision [13209]

The oldest known version of this page was created on 2008-04-24 15:45:24 by JeffMarshall [Add new overload; misc changes]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode