SD Card root.ls seems to run in the background

I'm just starting to use an SD card on Arduino Nano. Ran the example CardInfo.ino file. This works just fine. Copied this code to my working directory.

Started working on learning the functions and noticed a weird behavior with root.ls().

I added code to open SD and then check for "MYDIR" and if it does not exist create it. This added code is after root.ls() in the setup(). See attached code below. The result was root.ls() listed what was to be created as a file and not a directory. Adding a delay(3000); after the root.ls(0) fixed the issue.

This seems like a bug.

I've appended code to the setup() routine after line 119
// list all files in the card with date and size
root.ls(LS_R | LS_DATE | LS_SIZE);

my code... SDCardIntroduction.ino (5.3 KB)

executed monitor results... execution results.ino (770 Bytes)

line #20 has "MYDIR"... yet it was not created until after root.ls()

Also when this is done it is not even a directory. It was created as a file. see this image... windows 10 file manger screen capture

Adding a delay(3000); after root.ls() results
withdelay.ino (743 Bytes)

Verified with windows10 file manger.... MYDIR was properly created