Sha256: 1ccd2f698de5f6f954eae468a4169928b75073378e09a14e07dd0a6b118be93a
Contents?: true
Size: 1.04 KB
Versions: 6
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module FakeFtp module ServerCommands class List def run(ctx, *args) if ctx.active? && ctx.command_state[:active_connection].nil? ctx.respond_with('425 Ain\'t no data port!') return end ctx.respond_with('150 Listing status ok, about to open data connection') data_client = if ctx.active? ctx.command_state[:active_connection] else ctx.data_server.accept end wildcards = ctx.build_wildcards(args) statlines = ctx.matching_files(wildcards).map do |f| %W[ -rw-r--r-- 1 owner group #{f.bytes} #{f.created.strftime('%b %d %H:%M')} #{f.name} ].join("\t") end data_client.write(statlines.join("\n")) data_client.close ctx.command_state[:active_connection] = nil '226 List information transferred' end end end end
Version data entries
6 entries across 6 versions & 2 rubygems