programming.nbk: Home | Index | Next Page: Ruby: for | Previous Page: Ruby: Data Storage
Ruby: File I/O
File.open(<filename>, <mode>)
Modes:
- r = read only
- r+ = read/write
- w = write only - creates a new file, or replaces an existing file
- w+ = read/write - creates a new file, or replaces an existing file
- a = write only - appends to end of existing file, or creates new file
- a+ = read/write - appends to end of existing file, or creates new file
- b = binary - DOS/Windows only - binary mode, may appear with any of the above.
File.open opens the file if no block is given. If a block is given, the
file is passed to the block as an argument, and the file is closed when
the block terminates.
File::seek(<offset>)
Offsets:
- IO::SEEK_CUR - Seeks to first integer number parameter plus current position
- IO::SEEK_END - Seeks to first integer number parameter plus end of stream (you probably want a negative value for first integer number parameter)
- IO::SEEK_SET - Seeks to the absolute location given by first integer number parameter
programming.nbk: Home | Index | Next Page: Ruby: for | Previous Page: Ruby: Data Storage
Notebook exported on Monday, 7 July 2008, 18:56:06 PM Eastern Daylight Time