[MacRuby] #922: Writing a MacFUSE fs doesn't work when delegating methods

MacRuby ruby-noreply at macosforge.org
Sat Dec 4 12:22:51 PST 2010


#922: Writing a MacFUSE fs doesn't work when delegating methods
------------------------------+---------------------------------------------
 Reporter:  kourge@…          |        Owner:  lsansonetti@…        
     Type:  defect            |       Status:  closed               
 Priority:  major             |    Milestone:  MacRuby 0.8          
Component:  MacRuby           |   Resolution:  fixed                
 Keywords:                    |  
------------------------------+---------------------------------------------
Changes (by eloy.de.enige@…):

  * status:  new => closed
  * resolution:  => fixed
  * milestone:  MacRuby 0.7 => MacRuby 0.8


Comment:

 This works on trunk:

 {{{
 framework 'cocoa'
 framework 'macfuse'

 class Exception
   def to_ns(domain='', code=self.hash)
     user_info = {
       'NSLocalizedDescriptionKey' => self.message, 'Backtrace' =>
 self.backtrace
     }
     NSError.errorWithDomain(domain, code: code, userInfo: user_info)
   end
 end

 class HelloFS
   PATH = '/hello.txt'

   def contents(path)
     [PATH.lastPathComponent]
   end

   def read_file(path)
     return nil unless path == PATH
     "Hello, World!\n"
   end

   def size(path)
     read_file(path).size
   end

   def file?(path)
     path == '/hello.txt'
   end

   def contentsOfDirectoryAtPath(path, error: error)
     self.contents(path)
   rescue Exception => e
     error[0] = e.to_ns('GMUserFileSystemDomain')
     nil
   end

   def contentsAtPath(path)
     self.read_file(path).dataUsingEncoding(NSUTF8StringEncoding)
   end
 end

 d = HelloFS.new
 fs = GMUserFileSystem.alloc.initWithDelegate(d, isThreadSafe: true)
 fs.mountAtPath("/Volumes/Hello", withOptions: ['rdonly',
 'volname=HelloFS'])

 sleep 1

 puts `ls /Volumes/Hello`
 puts `cat /Volumes/Hello/hello.txt`

 fs.unmount
 }}}

 Outputs:

 {{{
 macruby(869,0x103f44000) malloc: *** auto malloc[869]: error: GC operation
 on unregistered thread. Thread registered implicitly. Break on
 auto_zone_thread_registration_error() to debug.

 macruby(869,0x103fc7000) malloc: *** auto malloc[869]: error: GC operation
 on unregistered thread. Thread registered implicitly. Break on
 auto_zone_thread_registration_error() to debug.

 hello.txt
 Hello, World!
 macruby at fuse0 unmount from /Volumes/Hello
 }}}

-- 
Ticket URL: <http://www.macruby.org/trac/ticket/922#comment:3>
MacRuby <http://macruby.org/>



More information about the macruby-tickets mailing list