ファイルの取り扱い
File handling
異なる環境で利用される可能性のあるアプリケーションを構築する際の難点のひとつは
ドキュメントのコピーです。
これは、他のマシンの異なるディレクトリにドキュメントが移動されるかもしれないためです。
フルパス名へのポインタをもつファイルを保存すると、本質的に可搬性がなくなります。
ひとつの方法はファイル名だけを保存し、ディレクトリ情報を保存しないという方法です。
この場合、アプリケーションはローカルで定義されているいくつかのディレクトリを検索して
ファイルを見つけ出します。
これをサポートするために wxPathList クラスでは
ディレクトリの追加とファイルの検索を容易にしており、
ファイル名を保存しなければならない場合には
グローバル関数 wxFileNameFromPath で
パス名からファイル名を取り出せます。
この場合、別のディレクトリに同じ名前のドキュメントがあるユーザにとっては
望ましくない副作用が生じます。
When building an application which may be used under different
environments, one difficulty is coping with documents which may be
moved to different directories on other machines. Saving a file which
has pointers to full pathnames is going to be inherently unportable. One
approach is to store filenames on their own, with no directory
information. The application searches through a number of locally
defined directories to find the file. To support this, the class wxPathList makes adding directories and searching for files easy, and
the global function wxFileNameFromPath allows the application to
strip off the filename from the path if the filename must be stored.
This has undesirable ramifications for people who have documents of the
same name in different directories.
DOS の 大小文字区別のない 8+3 ファイル名の制限と制限のない Unix ファイル名に関して言えば、
アプリケーションにとって最良の解決法は DOS ファイル名を使用するということになります。
また、 もし ユーザーが定期的にプラットフォームを
切り替えるようであれば、ドキュメントのファイル名についても同じことが言えます。
明らかに、後者の選択はアプリケーションのユーザ次第です。
(YACC や LEX のように) プログラムによっては DOS と互換性のないファイル名を生成します;
この場合の最良の解決法は、 DOS に転送する前に生成されたファイルの名前を Unix makefile で
より互換性のあるものに変更することです。
DOS ファイルの Unix への転送には問題がありません。
もちろん、 EOL (行末) の変換は別で、これには (dos2unix のような) ユーティリティが利用可能です。
As regards the limitations of DOS 8+3 single-case filenames versus
unrestricted Unix filenames, the best solution is to use DOS filenames
for your application, and also for document filenames if the user
is likely to be switching platforms regularly. Obviously this latter
choice is up to the application user to decide. Some programs (such as
YACC and LEX) generate filenames incompatible with DOS; the best
solution here is to have your Unix makefile rename the generated files
to something more compatible before transferring the source to DOS.
Transferring DOS files to Unix is no problem, of course, apart from EOL
conversion for which there should be a utility available (such as
dos2unix).
雑多なファイル操作関数についてはリファレンスマニュアルのファイル関数 (File Functions) の章も
参照してください。
See also the File Functions section of the reference manual for
descriptions of miscellaneous file handling functions.