# File docs/makedocs.rb, line 80
def uploadDocs( url, docsdir )
        header "Uploading new docs snapshot to #{url}."

        case url
        
        # SSH target
        when %{^ssh://(.*)}
                target = $1
                if target =~ %{^([^/]+)/(.*)}
                        host, path = $1, $2
                        path = "/" + path unless path =~ /^(\/|\.)/
                        cmd = "tar -C #{docsdir} -cf - . | ssh #{host} 'tar -C #{path} -xvf -'"
                        unless $DEBUG
                                system( cmd )
                        else
                                message "Would have uploaded using the command:\n    #{cmd}\n\n"
                        end
                else
                        abort "--upload ssh://host/path"
                end
        when %{^file://(.*)}
                targetdir = $1
                targetdir.gsub!( %{^file://}, '' )

                File.makedirs targetdir, true
                Dir["#{docsdir}/**/*"].each {|file|
                        fname = file.gsub( %:#{docsdir}/:, '' )
                        if File.directory? file
                                unless $DEBUG
                                        File.makedirs File.join(targetdir, fname), true
                                else
                                        message %{File.makedirs %s, true\n} % File.join(targetdir, fname)
                                end
                        else
                                unless $DEBUG
                                        File.install( file, File.join(targetdir, fname), 0444, true )
                                else
                                        message %{File.install( %s, %s, 0444, true )\n} % [
                                                file,
                                                File.join(targetdir, fname),
                                        ]
                                end
                        end
                }

        else
                raise "I don't know how to upload to urls like '#{url}'."
        end
end