Skip to content

Instantly share code, notes, and snippets.

@vjdhama
Created September 23, 2015 09:22
Show Gist options
  • Save vjdhama/ba30a922909620a65cf5 to your computer and use it in GitHub Desktop.
Save vjdhama/ba30a922909620a65cf5 to your computer and use it in GitHub Desktop.
# Returns a File::Stat object for the named file or raises
# `Errno::ENOENT` (See `File::Stat`)
#
# ```
# echo "foo" > foo
# File.stat("foo").size #=> 4
# File.stat("foo").mtime #=> 2015-09-23 06:24:19 UTC
# ```
def self.lstat(path)
if LibC.lstat(path, out stat) != 0
raise Errno.new("Unable to get lstat for '#{path}'")
end
Stat.new(stat)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment