Add fsquery method

bug/bundler_fix
William Vu 2015-02-25 17:09:44 -06:00
parent 1f981dd336
commit 5d3c7f3b4a
1 changed files with 20 additions and 0 deletions

View File

@ -117,6 +117,26 @@ class Client
@sock.put(%Q{#{FSINIT} VOLUME = "#{volume}"\n}) @sock.put(%Q{#{FSINIT} VOLUME = "#{volume}"\n})
end end
# Query a file
#
# @param path [String] Remote path
# @return [Boolean] True if file exists
def fsquery(path)
if path !~ /^[0-2]:/
raise ArgumentError, "Path must begin with 0:, 1:, or 2:"
end
file = false
@sock.put(%Q{#{FSQUERY} NAME = "#{path}"\n})
if @sock.get(DEFAULT_TIMEOUT) =~ /TYPE=(FILE|DIR)/m
file = true
end
file
end
# List a directory # List a directory
# #
# @param path [String] Remote path # @param path [String] Remote path