1541ultimate icon indicating copy to clipboard operation
1541ultimate copied to clipboard

Deleting directory with 'hidden' files (starting with '.') causes 'Illegal Access' error

Open eriktier opened this issue 4 years ago • 1 comments

Deleting a (nested) directory with any hidden files and or directories (created by MacOSX for example), is currently impossible. It will delete all 'non-hidden' files and then when attempting the delete the directory causes the Illegal Access error. The directory will still be on the file system, with no means to delete the 'hidden' files 'on device'. This is mostly a problem with drives connected to the 'internal' usb port.

eriktier avatar Feb 09 '22 16:02 eriktier

Apparently FileManager::get_directory(...) doesn't return files which are hidden or start with ".". This makes perfect sense most of the time but when you are trying to delete a directory structure with hidden files they are left behind causing problems.

...
while (1) {
    res = dir->get_entry(info);
    if (res != FR_OK)
        break;
    if ((info.lfname[0] == '.') || (info.attrib & AM_HID))
        continue; // skip files to be hidden.    
    if (matchPattern && (strlen(matchPattern) > 0) && !pattern_match(matchPattern, info.lfname, false)) {
        continue;
    }
    target.append(new FileInfo(info));
}
...

naali avatar Apr 12 '22 07:04 naali