Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/mincore.rb

Overview

The File mincore extension

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cachedel(filename, count = 1) ⇒ Object

Attempts to delete cached pages of a file, one or more times

Example:

>> File.cachedel("/path/to/useless/file", 2)
=> 0

Arguments:

filename: (String)
count: (Int)


167
168
169
# File 'lib/mincore.rb', line 167

def self.cachedel(filename, count=1) 
  self._cachedel(filename, count)
end

.mincore(*args) ⇒ Object

Returns page cache status for a given file. Status is provided as a boolean array of size ( filesize + PAGESIZE -1 ) / PAGESIZE

Example:

>> File.mincore("/path/to/important/file")
=> [true, true, true....]

Arguments:

filename: (String)


182
183
184
# File 'lib/mincore.rb', line 182

def self.mincore(*args)
  self._mincore(*args)
end

.PAGESIZEObject

get system pagesize (4096 on Intel)

Example:

>> File.PAGESIZE
=> 4096


191
192
193
# File 'lib/mincore.rb', line 191

def self.PAGESIZE
  self._PAGESIZE
end

Instance Method Details

#numpagesObject

Returns the number of system pages required to store file in memory



151
152
153
154
# File 'lib/mincore.rb', line 151

def numpages
  pagesize = self.class.PAGESIZE
  (self.stat.size + pagesize -1 ) / pagesize
end