lib/ffi/stat.rb in ffi-libfuse-0.3.4 vs lib/ffi/stat.rb in ffi-libfuse-0.4.0
- old
+ new
@@ -60,13 +60,13 @@
# @param [Integer] size
# @param [Integer] uid
# @param [Integer] gid
# @param [Hash] args additional system specific stat fields
# @return [self]
- def file(mode:, size:, uid: Process.uid, gid: Process.gid, **args)
+ def file(mode:, size:, nlink: 1, uid: Process.uid, gid: Process.gid, **args)
mode = ((S_IFREG & S_IFMT) | (mode & 0o777))
- fill(mode: mode, size: size, uid: uid, gid: gid, **args)
+ fill(mode: mode, size: size, nlink: nlink, uid: uid, gid: gid, **args)
end
# Fill content for a directory
# @param [Integer] mode
# @param [Integer] nlink
@@ -78,10 +78,22 @@
mode = ((S_IFDIR & S_IFMT) | (mode & 0o777))
fill(mode: mode, uid: uid, gid: gid, nlink: nlink, **args)
end
alias directory dir
+ # Fill content for a symbolic link
+ # @param [Integer] size length of the target name (including null terminator)
+ # @param [Integer] mode
+ # @param [Integer] uid
+ # @param [Integer] gid
+ # @param [Hash] args additional system specific stat fields
+ # @return [self]
+ def symlink(size:, mode: 0o777, nlink: 1, uid: Process.uid, gid: Process.gid, **args)
+ mode = ((S_IFLNK & S_IFMT) | (mode & 0o777))
+ fill(mode: mode, nlink: nlink, size: size, uid: uid, gid: gid, **args)
+ end
+
# Fill attributes from file (using native LIBC calls)
# @param [Integer|:to_s] file descriptor or a file path
# @param [Boolean] follow links
# @return [self]
def from(file, follow: true)
@@ -121,11 +133,11 @@
# Apply permissions mask to mode
# @param [Integer] mask (see umask)
# @param [Hash] overrides see {fill}
# @return self
- def mask(mask = 0o4000, **overrides)
+ def mask(mask = S_ISUID, **overrides)
fill(mode: mode & (~mask), **overrides)
end
def file?
mode & S_IFREG != 0
@@ -143,9 +155,13 @@
mode & S_ISGID != 0
end
def sticky?
mode & S_ISVTX != 0
+ end
+
+ def symlink?
+ mode & S_IFLNK != 0
end
class << self
# @!method file(stat,**fields)
# @return [Stat]