# DirectoryIterator always checks for hidden file flag

**URL:** <https://forum.juce.com/t/directoryiterator-always-checks-for-hidden-file-flag/9791>\
**Category:** MacOSX and iOS\
**Created:** [January 8, 2013, 12:35am UTC](https://forum.juce.com/t/directoryiterator-always-checks-for-hidden-file-flag/9791 "2013-01-08T00:35:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dri](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dri/32/142_2.png) [@Dri](https://forum.juce.com/u/Dri)\
**Post date:** [January 8, 2013, 12:35am UTC](https://forum.juce.com/t/directoryiterator-always-checks-for-hidden-file-flag/9791/1 "2013-01-08T00:35:51Z")

</div>

Hi Jules,

I think there is a bug in juce\_mac\_Files.mm :

```auto
    bool next (String& filenameFound,
               bool* const isDir, bool* const isHidden, int64* const fileSize,
               Time* const modTime, Time* const creationTime, bool* const isReadOnly)
    {
[...]
        if (isHidden != nullptr)
                *isHidden = FileHelpers::isHiddenFile (fullPath);
```

In fact the isHidden bool\* is never null because the bool it refers to is defined as a stack variable (then ==false) in juce\_DirectoryIterator.cpp :

```auto
    bool isDirectory, isHidden;
    while (fileFinder.next (filename, &isDirectory, &isHidden, fileSize, modTime, creationTime, isReadOnly))
    {
```

This makes scanning much more time consuming than it should be since the OS function getting the file flags is really slow…

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [January 8, 2013, 10:13am UTC](https://forum.juce.com/t/directoryiterator-always-checks-for-hidden-file-flag/9791/2 "2013-01-08T10:13:51Z")

</div>

Interesting point, thanks… I think I can optimise that for some cases if the File::ignoreHiddenFiles flag hasn’t been set.
