Class: Fox::FXFileStream

Inherits:
FXStream show all
Defined in:
rdoc-sources/FXFileStream.rb,
lib/fox16/iterators.rb

Overview

File Store Definition

Instance Attribute Summary collapse

Attributes inherited from FXStream

#container, #direction, #space, #status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FXStream

#bigEndian=, #bigEndian?, #bytesSwapped=, #bytesSwapped?, #close, #eof?, #error=, #flush, #getSpace, #setSpace

Constructor Details

#initialize(cont = nil) ⇒ FXFileStream

Return an initialized FXFileStream instance.



10
11
# File 'rdoc-sources/FXFileStream.rb', line 10

def initialize(cont=nil) # :yields: theFileStream
end

Instance Attribute Details

#positionObject (readonly)

Returns the value of attribute position.



5
6
7
# File 'rdoc-sources/FXFileStream.rb', line 5

def position
  @position
end

Class Method Details

.open(filename, save_or_load, size = 8192, container = nil) ⇒ Object

Construct a new FXFileStream object with the specified data flow direction (save_or_load) and container object. If an optional code block is given, it will be passed this file stream as an argument, and the file stream will automatically be closed when the block terminates. If no code block is provided, this method just returns the new file stream in an opened state.

Raises FXStreamNoWriteError if save_or_load is FXStreamSave but the file cannot be opened for writing. Raises FXStreamNoReadError if save_or_load is FXStreamLoad but the file cannot be opened for reading.



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/fox16/iterators.rb', line 283

def FXFileStream.open(filename, save_or_load, size=8192, container=nil) # :yields: theFileStream
  fstream = FXFileStream.new(container)
  if fstream.open(filename, save_or_load, size)
  	if block_given?
  	  begin
  	    yield fstream
  	  ensure
  	    fstream.close
  	  end
  	else
  	  fstream
  	end
  else
    # FXFileStream#open returned false, so report error
  	raise FXStreamError.makeStreamError(fstream.status)
  end
end

Instance Method Details

#open(filename, save_or_load, size = 8192) ⇒ Object

Open binary data file stream; allocate a buffer of the given size for the file I/O; the buffer must be at least 16 bytes. Returns true on success, false on failure.

Parameters:

filename

name of the file to open [String]

save_or_load

access mode, either FXStreamSave or FXStreamLoad [Integer]

size

buffer size [Integer]



24
# File 'rdoc-sources/FXFileStream.rb', line 24

def open(filename, save_or_load, size=8192); end