1 require 'mogilefs/backend'
4 # NFSFile wraps up the new file operations for storing files onto an NFS
7 # You really don't want to create an NFSFile by hand. Instead you want to
8 # create a new file using MogileFS::MogileFS.new_file.
10 class MogileFS::NFSFile < File
13 # The path of this file not including the local mount point.
18 # The key for this file. This key won't represent a real file until you've
24 # The class of this file.
31 # Wraps up File.new with MogileFS-specific data. Use
32 # MogileFS::MogileFS#new_file instead of this method.
34 def new(mg, fid, path, devid, klass, key)
35 fp = super join(mg.root, path), 'w+'
36 fp.send :setup, mg, fid, path, devid, klass, key
41 # Wraps up File.open with MogileFS-specific data. Use
42 # MogileFS::MogileFS#new_file instead of this method.
44 def open(mg, fid, path, devid, klass, key, &block)
45 fp = new mg, fid, path, devid, klass, key
47 return fp if block.nil?
59 # Closes the file handle and marks it as closed in MogileFS.
63 @mg.backend.create_close(:fid => @fid, :devid => @devid,
64 :domain => @mg.domain, :key => @key,
71 def setup(mg, fid, path, devid, klass, key)