How can I receive notifications of filesystem changes in OS X? - macos

In Windows, I can use the FindNextChangeNotification API to watch a file or folder for changes. For example, I can watch a folder and get notified when a file is added or removed.
Is there a similar API on OS X?

Mac OS X v10.5 introduces the File System Events API. Have a look at:
Technology Overview
Using the File System Events API
File System Events Programming Guide (PDF)

FSEvents is nice, but for watching just a small set of files or folders it's rather overkill, and it does require Leopard or newer. (The underlying technology was introduced in Tiger, but the API wasn't public.)
As a possible alternative, note that OS X inherits kqueue from FreeBSD (at least as of Panther). You can search for examples of EVFILT_VNODE usage, that's what you want to use to watch for file alterations.

Related

Create an OS X today widget without a host app

Is it possible to create an OS X Yosemite Today Widget without a host app, like the builtin Weather, Stocks and World Clock apps?
You can not do that simply because your executable is still running in the companion app rather in the extension. It means that codes are actually belonged to the companion app. So, you must have your companion app.
Info from the official documentation:
An app extension is different from an app. Although you must use an
app to contain and deliver your extensions, each extension is a
separate binary that runs independent of the app used to deliver it.

Mac OS X - best place for the demo files of application?

I am new to developing for the Mac OS X.
What's best place for storing the demo files of application on Mac OS X?
What's best practices?
I suggest the "/Library/Application Support" directory, which the documentation defines as: -
The Application Support directory is where your app stores any type of file that supports the app but is not required for the app to run, such as document templates or configuration files. The files should be app-specific but should never store user data.

Google Chrome App filesystem events, shell/finder integration

For a new desktop app project I'm researching if it's feasible to create a cross-platform implementation instead of native Windows and OS X apps. Chrome Apps seemed promising, but after browsing through the Chrome APIs there are some things I didn't see that I'll need in my app:
Notifications on changes to files in the local filesystem. (File System Events API on OS X, FileSystemWatcher on Windows.) At first I thought the syncFileSystem API might help with this, but it's apparently only for syncing with Google Drive, which is not what I need. I guess I could workaround this by scanning the directories I'm watching on a timer, but that won't perform well if there are a lot of directories and/or files.
Ability to add context menus in Windows shell and OS X Finder, as I would be able to with a Windows shell extension or OS X Finder plugin.
Ideally (although probably not a hard requirement) get the app into the Windows System Tray / OS X Menu Bar (NSStatusItem).
Can anyone confirm whether it's possible to access this functionality with a Chrome App? If not, can you recommend an alternative cross-platform tool for building an app with these features?
All of the listed features have bugs logged, but no real progress at the moment:
Watch: https://code.google.com/p/chromium/issues/detail?id=148873
File manager integration: https://code.google.com/p/chromium/issues/detail?id=130455
Sys tray: https://code.google.com/p/chromium/issues/detail?id=142450
The first of these to be made available will probably be file manager integration, which is being worked on now.
We'd love to improve watching but it is a significant task to support this on all operating systems and we don't have anyone working on it now.
Sys tray support is something we have no plans to release soon as we're not sure how we want to support this on ChromeOS.
I could not find anything close to the items you have mentioned. I did however find this product: node-webkit that likely would get you onto both your target platforms, use the same basic code-base (HTML5/CSS/JS) and allow some possible per-OS customization. There is even a 'watch' project under NPM that covers your first bullet point. Check node-webkit/wiki for notes on how to add C/C++ extensions to their node build (under using-node-modules.) Project seems active and appears to be backed by Intel (they re-built their XDK product on it to do cross platform.)

OSX per app network throughput via nettop

The OSX command line tool nettop (I think it was added with Lion) can display per app network throughput without requiring root privileges. I browsed through the Darwin source code on http://www.opensource.apple.com/ but couldn't find it's source code. Is it open source at all or did I just missed it. Incase the source is not publicly available, does anyone have an idea via which api nettop is getting its data?
nettop is open source only in its BSD version, but Apple's version uses their private NetworkStatistics framework (new in Lion) so I doubt you will find the sources since Apple tends to not release private code.

Creating cursor rsrc files on Mac from png

I want to create cursor rsrc files on the Mac from png files. The application that uses the cursors requires it to be in a .rsrc format and I cannot change that. Does anybody know of any way I can create the cursor .rsrc files from png images.
You can use Rezilla to edit resource files on Mac OS X, it has a CURS (and crsr) editor among others. It's a PowerPC binary but it runs well under rosetta on intel.
Also, you don't create a CURS resource file, you create a resource file and add as many CURS resources to it as you need. Resource forks are generic and can contain any number/kind of resources.
Its been a long time since I've thought about MacOS resource forks. Are you using the classic MacOS (i.e. before MacOS X)?
As I recall, ResEdit was the application most often used to manipulate the resource fork of a classic Mac application. I know it can edit cursor resources, but I don't recall if it can read PNG files. You may need to convert the files to GIF.
ResEdit is a Classic MacOS application. MacOS X prior to 10.5 could run Classic apps in emulation, but in 10.5 this support has been removed. You'd need to find a system either running the classic MacOS directly, or running 10.4 with Classic installed.
According to this link http://www.macfixit.com/article.php?story=20060621071707921 I need to have a Power PC Mac to run Mac classic. Is this right? I have a Intel Mac running Mac OS 10.4.11 . Are there any other tools capable of running on Intel Mac and could help me create CURS rsrc files. I tried using ResKnife but it didnt seem to have an option to create CURS rsrc files.
If by .rsrc file you mean a standard Mac resource file, you can use the Resource Manager to save the image in a file of the appropriate format.

Resources