Class: File

### Home Classes Methods

### In Files

- lib/inline.rb

### Parent

Object

### Methods

- ::write_with_backup

### Files

- History.txt
- Manifest.txt
- README.txt

### Class/Module Index

Quicksearch

- Inline
- Inline::C
- CompilationError
- Dir
- File
- Module

No matching classes.

# File

### Public Class Methods

write_with_backup(path) click to toggle source

Equivalent to +File::open+ with an associated block, but moves any existing file with the same name to the side first.

    # File lib/inline.rb, line 867
    def self.write_with_backup(path) # returns true if file already existed

      # move previous version to the side if it exists
      renamed = false
      if test ff, path then
        renamed = true
        File.rename path, path + ".old"
      end

      File.open(path, "w") do |io|
        yield(io)
      end

      return renamed
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.