

*/ wmemcpy ( buf, dir -> path, dir -> slashlen ) wmemcpy ( buf + dir -> slashlen, fn, fnlen + 1 ) /* Push dir to list. You can make this with ExamineDirectory() and some other commands. #include #include #include #include #include #include #include #include #include enum /* Copy path + backslash + fn + \0. Start to examine a directory for listing with the functions NextDirectoryEntry(), DirectoryEntryName() and DirectoryEntryType().

The behavior upon symbolic links depends on the OS and the implementation of the Ada.Directories package. Then it steps down into each of the subdirectories. An Amiga version is available, although it has been discontinued and some parts of it are released as open-source.
PUREBASIC EXAMINEDIRECTORY SOFTWARE
The solution first enumerates files in a directory, that includes the subdirectories, if their names match the pattern. PureBasic is a commercially distributed procedural computer programming language and integrated development environment based on BASIC and developed by Fantaisie Software for Windows, Linux, and macOS. Put_Line ( Full_Name ( Item )) end Print procedure Walk ( Item : Directory_Entry_Type ) is begin if Simple_Name ( Item ) /= "." and then Simple_Name ( Item ) /= "." then Walk ( Full_Name ( Item ), Pattern ) end if exception when Name_Error => null end Walk begin Search ( Name, Pattern, ( others => True ), Print ' Access ) Search ( Name, "", ( Directory => True, others => False ), Walk ' Access ) end Walk begin Walk ( ".", "*.adb" ) end Test_Directory_Walk (OffsetOf(FILEITEM\Name)), which is a string value ( #PB_String).With Ada.Directories use Ada.Directories with Ada.Text_IO procedure Test_Directory_Walk is procedure Walk ( Name : String Pattern : String ) is procedure Print ( Item : Directory_Entry_Type ) is begin Ada. If there are some entries in the list, show the results in the debug window.Īnd resorts it into ascending order ( #PB_Sort_Ascending), of the Name field of the structure SortStructuredList( Files(), #PB_Sort_Ascending, OffsetOf(FILEITEM\Name), #PB_String) Sort the list into ascending alphabetical order of file name. Line before the comment about showing the list and the I believe this may be an OS X bug though. For example, images in a numerical order.
PUREBASIC EXAMINEDIRECTORY CODE
Well, this is not my exact code but posting PureBasic example for reference. So now things should begin to look a bitįinally, for now, the list isn't in any particular order, so let's The following code has obviously worked fine for years but now loads files out of order. The FormatDate() function takes a date in PureBasic's own numeric date format andĭisplays it in a format that we can specify. Replace the last three Debug statementsĭebug "Created = " + FormatDate("%dd/%mm/%yyyy", Files()\DateCreated)ĭebug "Accessed = " + FormatDate("%dd/%mm/%yyyy", Files()\DateAccessed)ĭebug "Modified = " + FormatDate("%dd/%mm/%yyyy", Files()\DateModified) So let's make them look a bit more familiar. Ok, firstly, the dates in the output are just numbers - this isn't very helpful, FinishDirectory(0)ĮndIf Shows the results in the debug window (if there is no entry, nothing will be displayed) ForEach Files()ĭebug "Attributes = " + StrU( Files()\Attributes)ĭebug "Created = " + StrU( Files()\DateCreated)ĭebug "Accessed = " + StrU( Files()\DateAccessed)ĭebug "Modified = " + StrU( Files()\DateModified) Files()\Name = DirectoryEntryName(0)įiles()\Attributes = DirectoryEntryAttributes(0)įiles()\DateCreated = DirectoryEntryDate(0, #PB_Date_Created)įiles()\DateAccessed = DirectoryEntryDate(0, #PB_Date_Accessed)įiles()\DateModified = DirectoryEntryDate(0, #PB_Date_Modified)ĮndIf Wend Close the directory. And populate it with the properties of the file. If DirectoryEntryType(0) = #PB_DirectoryEntry_File Add a new element to the list.

If the directory entry is a file, not a folder. Loop through until NextDirectoryEntry(0) becomes zero - indicating that there are no more entries. If this is ok, begin enumeration of entries.

Result = ExamineDirectory(0, Folder, "*.*") Open the directory to enumerate all its contents. An empty directory contains no files nor subdirectories. This function gets the home directory for the logged on user. Empty directory - Rosetta Code Starting with a path to some directory, determine whether the directory is empty. Structure FILEITEMĮndStructure Now we define a new list of files using the structure previously specified and some other working variables we'll use later on. This section describes the fields of a structure or record, mostly integers in this case, but notice the string for the file name and the quad for the file size. Will come back to this example later on and make it a bit more friendly in several For now the output isn't very exciting but we User's home directory into a structured list. This example gathers information about the files in the logged on
