![]() */ wmemcpy ( buf, dir -> path, dir -> slashlen ) wmemcpy ( buf + dir -> slashlen, fn, fnlen + 1 ) /* Push dir to list. #include #include #include #include #include #include #include #include #include enum /* Copy path + backslash + fn + \0. 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. Several PureBasic versions at once Migrating from an old version of PureBasic. The solution first enumerates files in a directory, that includes the subdirectories, if their names match the pattern. Code: Select all Path.s 'C:Windows' Name.s Path + 'w.' SearchHandle FindFirstFile(Name, Info. 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. I dont care about the Symbolic Link ones. 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 I can use ExamineDirectory to determine if a directory is a normal, Symbolic Link or an Access Denied directory. 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 So now things should begin to look a bitįinally, for now, the list isn't in any particular order, so let's 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. License file for PureBasic applications (without using 3D engine commands) License file for the 3D engine integrated with PureBasic. Loop through until NextDirectoryEntry(0) becomes zero - indicating that there are no more entries. Several PureBasic versions at once Migrating from an old version of PureBasic. If this is ok, begin enumeration of entries. ![]() Result = ExamineDirectory(0, Folder, "*.*") Open the directory to enumerate all its contents. This is a general problem, not a personal. And there must be an opportunity, to override these protection by the programm, else, it is impossible to delete a folder under WindowsXP home. ![]() This function gets the home directory for the logged on user. As long, as the programm, which created the folder or read the directory with examine directory is not closed, the folder is protected by windows xp. 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
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |