Method: Fasttrack::File#initialize

Defined in:
lib/fasttrack/file.rb

#initialize(path, mode = "r") ⇒ File

Instantiates a new Fasttrack::File object, which is a representation of a file on disk and its associated XMP metadata. To create a new file on disk you should use Fasttrack::XMP#to_s instead.

Parameters:

  • path (String)

    path to the file on disk; must exist

  • mode (String) (defaults to: "r")

    file mode; accepted values are “r” (read-only; default), “w” and “rw” (read-write)

Raises:



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fasttrack/file.rb', line 51

def initialize path, mode="r"
  @open = false
  @path = Pathname.new(path).expand_path
  if not @path.exist?
    raise Errno::ENOENT, "#{@path} does not exist"
  end

  @file_ptr = Exempi.xmp_files_new
  @read_mode = mode
  open @read_mode

  ObjectSpace.define_finalizer(self, self.class.finalize(@file_ptr))
end