0

I am creating a script for Chrome browser to handle files (using File System Access API). This is totally fine on Windows, but on MAC I have this issue:

The files are stored in folders which look like files on MAC. For example folder name is thisisfolder.xyz and inside there are files like file.xml.

thisisfolder.xyz
  file.xml
  file2.xml
  ...

If I choose directory handler (handle.getDirectoryHandle(someDirectory)), those folders (thisisfolder.xyz) are greyed out and can't be selected. If I choose file handler (handle.getFileHandle(someDirectories)), I can select thisisfolder.xyz and similar, but later when I want to access files in this folder, I can't, because API thinks those folders are files.

var subdirHandle = await handle.getDirectoryHandle(someDirectory);

for await (var [name, entry] of subdirHandle.entries()) {
    ...
}                                   

Do I have any possibility here?

koubin
  • 579
  • 5
  • 9
  • 30
  • Are you talking about [Bundles](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1)? – trojanfoe Oct 04 '21 at 15:08
  • no, those are regular folders and files accessed for example on Mac's desktop. The folders with files are created by some software and I need to parse the XML's inside them – koubin Oct 04 '21 at 15:29

1 Answers1

1

This is working as intended. If you try to create a folder named test.txt on a Mac, the Finder even helpfully warns you about the issue you are experiencing:

Are you sure you want to add the extensions ".txt" to the end of the name? If you make this change, your folder may appear as a single file.

Finder warning: Are you sure you want to add the extensions ".txt" to the end of the name? If you make this change, your folder may appear as a single file.

DenverCoder9
  • 2,024
  • 11
  • 32
  • thank you for input. The problem here is that the folders (with .xyz at the end) are created automatically by some specific software. So I can't change it and have to deal with that. – koubin Nov 09 '21 at 10:33
  • Not an expert here, but it seems judging from [this answer](https://apple.stackexchange.com/a/123059) that Mac treats folders with such an extension as associated to apps. I guess as a front-end user you're not supposed to create such folders, but doing so works just fine on the console. – DenverCoder9 Nov 09 '21 at 10:41
  • The best option for me would be to select it as files, but to be able to deal with it as with folders in API (that means change the kind of it). Not sure though if that wouldn't be a security violation. – koubin Nov 09 '21 at 10:44