| ... | ... | @@ -811,6 +811,17 @@ pub const IterableDir = struct { |
| 811 | 811 | }; |
| 812 | 812 | |
| 813 | 813 | pub fn iterate(self: IterableDir) Iterator { |
| 814 | return self.iterateImpl(true); |
| 815 | } |
| 816 | |
| 817 | /// Like `iterate`, but will not reset the directory cursor before the first |
| 818 | /// iteration. This should only be used in cases where it is known that the |
| 819 | /// `IterableDir` has not had its cursor modified yet (e.g. it was just opened). |
| 820 | pub fn iterateAssumeFirstIteration(self: IterableDir) Iterator { |
| 821 | return self.iterateImpl(false); |
| 822 | } |
| 823 | |
| 824 | fn iterateImpl(self: IterableDir, first_iter_start_value: bool) Iterator { |
| 814 | 825 | switch (builtin.os.tag) { |
| 815 | 826 | .macos, |
| 816 | 827 | .ios, |
| ... | ... | @@ -825,20 +836,20 @@ pub const IterableDir = struct { |
| 825 | 836 | .index = 0, |
| 826 | 837 | .end_index = 0, |
| 827 | 838 | .buf = undefined, |
| 828 | | .first_iter = true, |
| 839 | .first_iter = first_iter_start_value, |
| 829 | 840 | }, |
| 830 | 841 | .linux, .haiku => return Iterator{ |
| 831 | 842 | .dir = self.dir, |
| 832 | 843 | .index = 0, |
| 833 | 844 | .end_index = 0, |
| 834 | 845 | .buf = undefined, |
| 835 | | .first_iter = true, |
| 846 | .first_iter = first_iter_start_value, |
| 836 | 847 | }, |
| 837 | 848 | .windows => return Iterator{ |
| 838 | 849 | .dir = self.dir, |
| 839 | 850 | .index = 0, |
| 840 | 851 | .end_index = 0, |
| 841 | | .first_iter = true, |
| 852 | .first_iter = first_iter_start_value, |
| 842 | 853 | .buf = undefined, |
| 843 | 854 | .name_data = undefined, |
| 844 | 855 | }, |