Class: Ole::Storage::RangesIOMigrateable

### Home Classes Methods

### In Files

- lib/ole/storage/base.rb

### Parent

Ole::Storage::RangesIOResizeable

### Methods

- ::new
- #first_block
- #first_block=
- #truncate

### Files

- ChangeLog
- README

### Class/Module Index

Quicksearch

- Ole
- Ole::IOMode
- Ole::IOMode::Constants
- Ole::Storage
- Ole::Storage::AllocationTable
- Ole::Storage::AllocationTable::Big
- Ole::Storage::AllocationTable::Small
- Ole::Storage::DirClass
- Ole::Storage::DirClass::Dir
- Ole::Storage::Dirent
- Ole::Storage::FileClass
- Ole::Storage::FileClass::Stat
- Ole::Storage::Header
- Ole::Storage::MetaData
- Ole::Storage::RangesIOMigrateable
- Ole::Storage::RangesIOResizeable
- Ole::Types
- Ole::Types::Clsid
- Ole::Types::Data
- Ole::Types::FileTime
- Ole::Types::Lpstr
- Ole::Types::Lpwstr
- Ole::Types::PropertySet
- Ole::Types::PropertySet::Constants
- Ole::Types::PropertySet::Section
- Ole::Types::Variant
- Ole::Types::Variant::Constants
- RangesIO

No matching classes.

# Ole::Storage::RangesIOMigrateable

like RangesIOResizeable, but Ole::Storage::Dirent specific. provides for migration between bats based on size, and updating the dirent.

### Attributes

dirent[R]

### Public Class Methods

new(dirent, mode='r') click to toggle source

    # File lib/ole/storage/base.rb, line 635
    def initialize dirent, mode='r'
      @dirent = dirent
      super @dirent.ole.bat_for_size(@dirent.size), mode,
        :first_block => @dirent.first_block, :size => @dirent.size
    end

### Public Instance Methods

first_block() click to toggle source

forward this to the dirent

    # File lib/ole/storage/base.rb, line 670
    def first_block
      @dirent.first_block
    end

first_block=(val) click to toggle source

    # File lib/ole/storage/base.rb, line 674
    def first_block= val
      @dirent.first_block = val
    end

truncate(size) click to toggle source

    # File lib/ole/storage/base.rb, line 641
    def truncate size
      bat = @dirent.ole.bat_for_size size
      if bat.class != @bat.class
        # bat migration needed! we need to backup some data. the amount of data
        # should be <= @ole.header.threshold, so we can just hold it all in one buffer.
        # backup this
        pos = [@pos, size].min
        self.pos = 0
        keep = read [@size, size].min
        # this does a normal truncate to 0, removing our presence from the old bat, and
        # rewrite the dirent's first_block
        super 0
        @bat = bat
        # just change the underlying io from right under everyone :)
        @io = bat.io
        # important to do this now, before the write. as the below write will always
        # migrate us back to sbat! this will now allocate us +size+ in the new bat.
        super
        self.pos = 0
        write keep
        self.pos = pos
      else
        super
      end
      # now just update the file
      @dirent.size = size
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.