How to determine if invisible files are currently shown in the Finder? - objective-c

In a macOS application written in Swift or Objective-C and targeted for the Mac App Store, how to determine programmatically if invisible files are currently shown in the Finder? I have tried to call defaults read com.apple.finder AppleShowAllFiles using NSTask, but it does not work in the sandbox. Any help is greatly appreciated, thanks.

Finder
It's irrelevant if com.apple.finder AppleShowAllFiles contains false or true. You probably misunderstood how it activates file viewer with URLs.
Example:
/Users/zrzka/.rustup
Finder is activated with content of the /Users/zrzka folder
.rustup folder is selected
/Users/zrzka/.rustup/toolchains
Finder is activated with content of the /Users/zrzka/.rustup folder
toolchains folder is selected
Sandbox
You can ask Apple for temporary exceptions. Here's more detailed answer. But it really depends on what files/folders do you want to reveal.

Related

Photoshop - simple Open File action on MAC

Could anyone send the ATN file with only one action -> opening PSD file on Mac?
I've made an action with a lot of steps, it's working good but only on Windows. There is no relative paths in PS actions, and i have no friend that has Mac. Could anyone prepare ATN file (so i will be able to copy "open psd file" step)?
Regards,
Luke
Short answer: this won't work. Even though Photoshop has "shortcuts" paths that are similar for both OSX and Windown (like ~/Desktop is a shortcut for desktop folder no matter of OS and username), Actions don't seem to recognize them. Furthermore, if you record an Open Action on Windows or Mac and open it in a different OS, you'll get a File or folder not found message for this step:
Here're two examples. In bot cases the top Action was made in Windows and the bottom one on Mac. This is a Mac screenshot:
and Windows:
Notice how Action1 on the Mac screenshot has File or folder not found message and on Windows there's the same message for Action2 from fromMac set.
Here's what you can do though.
insert Open as a Menu Item. This way user will be asked for a file you need every time a user calls the Action.
give the file you need to open as a pattern file (.pat) and ask a user to install it. This way you can fill a document with it using the Fill command.
most powerful: use a script. You can convert your action to a script file using the xtools: there's a script within it called ActionToJavascript: this will give you a .jsx file that you can use in Photoshop and that will work exactly as your action. And in this script you can specify a path for your action. Like here I'm specifying a file on my Desktop:
And this script will work on Mac.

In a Cocoa Application for macOS, I save a bundle to disk using NSFileWrapper. How can I get the finder show the correct icon for my bundle?

In a Cocoa Application for macOS, I save a bundle to disk using NSFileWrapper. The Bundle is correctly saved and recognised as a bundle (Show package contents appear) but I cannot get the finder display the Icon I provide for the bundle. Here are my settings for the imported/exported UTIs:
Unfortunately, the bundle appears always with a blank file icon:
As you can see, the Finder recognises the file kind, but does not display an image for it. Any help is greatly appreciated. Thanks
In the Exported UTIs section, try setting Conforms To to com.apple.package, public.archive.
I'm no UTI expert, but that has always worked for my apps.

Chrome app file system in kiosk mode

i have an app (signage player) that loads video and placed it in folder which user pointed on the beginning (named 'media').
Then i define source attr of video element as "media/name_of_file.mp4"
In plain mode is works well - local video plays. But i and don't know why. In Kiosk mode app can't find a files at all.
Do you have any ideas about it?
What features has or hasn't file system in kiosk mode - it's really hard to debug it there.
Many thanks for any information about file system in kiosk mode.
https://productforums.google.com/forum/#!topic/chromebook-central/zv1nxWBAce4;context-place=forum/chromebook-central
According to this answer, app in kiosk mode hasn't any access to file system.(but from my experience it isn't quite true, i can wright files and folders, read them via file api)
Main problem that i can't reach them from dom src property.
But anyway google demand additional license for this option, so any
kludges can be blocked in further versions of chrome os...
Create a shortcut to your Chrome executable, right click it, select "Properties" and then make sure the target field looks like this (for example):
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --kiosk "file:///C:/Users/JohnDoe/Desktop/MyHTMLFile.HTML"
The executable must be in double quotes, as well as the file path.
You may need to embed your MP4 inside an HTML5 element on a local HTML file for this to work.

How to read a shortcut file (and get its target) in a Windows RT metro app?

I have accessed normal files and folders, but unable to read the target value from a shortcut file. Any idea how to read a shortcut file in WinRT?
My actual requirement is to find the most recently used/opened files in the system This info was previously available through Environment.GetFolderPath(Environment.SpecialFolder.Recent)
Thank you in advance :)
There is a file AppData\Local\recently-used.xbel which contains this information on Win8. Parsing it should be easy, but the problem will probably be to get access to this file as it isn't in the folders that can be accessed via any manifest declaration. Also the AppData folder is hidden, making it inaccessible via the FileOpenPicker.
My guess would be that this is an intentional change by Microsoft since it is no business of a sandboxed app, which documents were used by other apps. If you want to open files that were recently opened by your app, you can roll your own "recently changed" implementation. Which should be easy because you have to save their token to the FutureAccessList anyhow.

Add an icon (mac & pc) to a file with Cocoa

I want to add an icon (icns & ico) to a file within my iPhone app and I'm not quite sure where to start looking! So when this file is viewed in Finder or Windows Explorer it will have a custom icon.
Can anyone point me in the right direction?
You can use -setIcon:forFile:options: method on NSWorkspace if you want to change the icon of a file or folder in Mac OS X.
I do not have an answer for Windows Explorer. For MacOS, the custom icon of a file is stored in the resource fork of the file as kIconFamilyType with id kCustomIconResource. The custom icon for a folder is stored in a file named Icon\r (\r meaning mac newline) in the folder. For volumes, the custom icon is in a .VolumeIcon.icns file at the root of the volume. In each case, you must set the kHasCustomIcon Finder flag for the item.
Cocoa does not give you access to the resource fork or the Finder flags. Use FSSetCatalogInfo to set the Finder flags. Use FSCreateResourceFork, AddResource and CloseResFile to add a custom icon family to a file. The same resource fork calls are used for the custom icon file in a folder.
The usual way to set an icon is to either paste it in from the Get Info Finder window, or send the Finder an apple event. You can send apple events from cocoa, but that is no help from an iPhone.
To create a file on an iPhone that has a resource fork, you would probably have to build a zip archive that would create a resource fork when unzipped. You would have to manually build a resource fork wrapper around the icon family data. The resource fork structure is well documented.
It would probably be easier to have a helper application on MacOS.