Skip to content

Instantly share code, notes, and snippets.

@kourge
Created February 10, 2011 10:47
Show Gist options
  • Save kourge/820296 to your computer and use it in GitHub Desktop.
Save kourge/820296 to your computer and use it in GitHub Desktop.
MacFUSE fs in MacRuby, with custom volume icon
framework 'cocoa'
class HelloFS
PATH = '/hello.txt'
def contentsOfDirectoryAtPath(path, error: error)
[PATH.lastPathComponent]
end
def contentsAtPath(path)
return nil unless path == PATH
"Hello World!\n".dataUsingEncoding(NSUTF8StringEncoding)
end
end
mountpoint = File.expand_path(ARGV.first || "/Volumes/Hello")
icon = File.expand_path("~/Desktop/fsicon.icns")
d = HelloFS.new
framework 'macfuse'
fs = GMUserFileSystem.alloc.initWithDelegate(d, isThreadSafe: true)
puts "GMUserFileSystem initialized"
fs.mountAtPath(mountpoint, withOptions: [
'rdonly', 'volname=HelloFS', "volicon=#{icon}"
])
at_exit { fs.unmount }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment