# File lib/fuse/rfusefs-fuse.rb, line 258
      def open(ctx,path,ffi)
        return wrap_context(ctx,__method__,path,ffi) if ctx
        fh = FileHandle.new(path,ffi.flags)

        #Save the value return from raw_open to be passed back in raw_read/write etc..
        if (FuseFS::RFUSEFS_COMPATIBILITY)
          fh.raw = @root.raw_open(path,fh.raw_mode,true)
        else
          fh.raw = @root.raw_open(path,fh.raw_mode)
        end

        unless fh.raw
          if fh.rdonly?
            fh.contents = @root.read_file(path)
          elsif fh.writing?
            unless @root.can_write?(path)
              raise Errno::EACCES.new(path)
            end

            if @created_files.has_key?(path)
              fh.create
            else
              if fh.rdwr? || fh.append?
                fh.contents = @root.read_file(path)
              else #wronly && !append
                #We should get a truncate 0, but might as well play it safe
                fh.contents = ""
              end
            end
          else
            raise Errno::ENOPERM.new(path)
          end
        end

        #If we get this far, save our filehandle in the FUSE structure
        ffi.fh=fh
      end