1

私は FTP サーバー (Qt/C++ で) を作成しています。現在、「TYPE A」に「200 Ok」を使用していますが、実際には「TYPE I」と同じように扱います。ファイルはそのまま送信されます。

TYPE Aを適切に実装するにはどうすればよいですか? ファイルをバイナリ モードではなくテキスト モードで開くだけで十分でしょうか?

また、 SIZE メソッドは、ディスク上のファイルのサイズを返すよりも複雑である必要があると思います。それを読み取ってテキスト置換を実行し、その方法でサイズを返す必要がありますか?

編集:コメントに応じて、RFC959 仕様からの関連する抜粋を次に示します。

     3.1.1.1.  ASCII TYPE

        This is the default type and must be accepted by all FTP
        implementations.  It is intended primarily for the transfer
        of text files, except when both hosts would find the EBCDIC
        type more convenient.

        The sender converts the data from an internal character
        representation to the standard 8-bit NVT-ASCII
        representation (see the Telnet specification).  The receiver
        will convert the data from the standard form to his own
        internal form.

        In accordance with the NVT standard, the <CRLF> sequence
        should be used where necessary to denote the end of a line
        of text.  (See the discussion of file structure at the end
        of the Section on Data Representation and Storage.)

        Using the standard NVT-ASCII representation means that data
        must be interpreted as 8-bit bytes.

        The Format parameter for ASCII and EBCDIC types is discussed
        below.
4

1 に答える 1

3

ASCII モード (タイプ A) でファイルを転送するには、ファイルをテキスト モードで開き、行末 CRLF で転送する必要があります。SIZE コマンドを実装する場合は、転送タイプに従ってサイズを報告する必要があります。550 SIZE not allowed in ASCII modeコマンドがイメージ モード以外で使用された場合、サーバーが返す適切なサイズを取得するためだけにファイル全体をスキャンするには明らかにオーバーヘッドが大きすぎるためです。

于 2014-05-10T10:47:17.540 に答える