Lumino
ln::FileSystem Class Reference

ファイルやディレクトリの作成、コピー、削除や列挙など、一般的な操作を提供します。 More...

#include <FileSystem.hpp>

Static Public Member Functions

static bool existsFile (const StringRef &filePath)
 指定されたファイルが存在するか確認します。 More...
 
static FileAttribute getAttribute (const StringRef &filePath)
 ファイルの属性を取得します。 More...
 
static void setAttribute (const StringRef &filePath, FileAttribute attr)
 ファイルの属性を設定します。 More...
 
static void copyFile (const StringRef &sourceFileName, const StringRef &destFileName, FileCopyOption option=FileCopyOption::None)
 ファイルをコピーします。 More...
 
static void removeFile (const StringRef &filePath)
 ファイルを削除します。 More...
 
static bool existsDirectory (const StringRef &path)
 指定したディレクトリが存在するかを確認します。 More...
 
static void createDirectory (const StringRef &path)
 ディレクトリを作成します。 More...
 
static void removeDirectory (const StringRef &path, bool recursive=false)
 ディレクトリを削除します。 More...
 
static void copyDirectory (const StringRef &srcPath, const StringRef &dstPath, bool overwrite, bool recursive)
 ディレクトリをコピーします。 More...
 
static bool matchPath (const StringRef &filePath, const StringRef &pattern)
 パスのファイル名とファイル名パターンを照合します。
 
static uint64_t getFileSize (const StringRef &filePath)
 ファイルサイズを取得します。
 
static ByteBuffer readAllBytes (const StringRef &filePath)
 ファイルの内容をバイナリ形式としてすべて読み込みます。 More...
 
static String readAllText (const StringRef &filePath, TextEncoding *encoding=nullptr)
 ファイルの内容をテキスト形式としてすべて読み込ます。 More...
 
static void writeAllBytes (const StringRef &filePath, const void *buffer, size_t size)
 指定されたバッファの内容をバイナリデータとしてすべてファイルに書き込みます。 More...
 
static void writeAllText (const StringRef &filePath, const String &str, TextEncoding *encoding=nullptr)
 文字列をテキストデータとしてすべてファイルに書き込みます。 More...
 
static Path getFile (const StringRef &dirPath, const StringRef &pattern=StringRef())
 指定したディレクトリ内の1つのファイルパス返します。 More...
 
static DirectoryIteratorRange getFiles (const StringRef &dirPath, const StringRef &pattern=StringRef(), SearchOption searchOption=SearchOption::TopDirectoryOnly)
 指定したディレクトリ内のファイルパス返します。 More...
 
static DirectoryIteratorRange getDirectories (const StringRef &dirPath, const StringRef &pattern=StringRef(), SearchOption searchOption=SearchOption::TopDirectoryOnly)
 指定したディレクトリ内のディレクトリパス返します。 More...
 

Detailed Description

ファイルやディレクトリの作成、コピー、削除や列挙など、一般的な操作を提供します。

Member Function Documentation

◆ copyDirectory()

static void ln::FileSystem::copyDirectory ( const StringRef srcPath,
const StringRef dstPath,
bool  overwrite,
bool  recursive 
)
static

ディレクトリをコピーします。

Parameters
[in]srcPath: コピー元ディレクトリパス
[in]dstPath: コピー先ディレクトリパス
[in]overwrite: コピー先のファイルとディレクトリを上書きする場合は true
[in]recursive: 全てのサブディレクトリも含めて削除する場合は true

◆ copyFile()

static void ln::FileSystem::copyFile ( const StringRef sourceFileName,
const StringRef destFileName,
FileCopyOption  option = FileCopyOption::None 
)
static

ファイルをコピーします。

Parameters
[in]sourceFileName: コピー元ファイル名
[in]destFileName: コピー先ファイル名
[in]option: コピー先を上書きするかどうか

◆ createDirectory()

static void ln::FileSystem::createDirectory ( const StringRef path)
static

ディレクトリを作成します。

指定したパスへの全てのディレクトリを作成します。 例えば "a/b" を指定した場合、ディレクトリ a が無ければ作成してから、b を作成します。

◆ existsDirectory()

static bool ln::FileSystem::existsDirectory ( const StringRef path)
static

指定したディレクトリが存在するかを確認します。

Parameters
[in]path: ディレクトリのパス

◆ existsFile()

static bool ln::FileSystem::existsFile ( const StringRef filePath)
static

指定されたファイルが存在するか確認します。

この関数はファイルが存在し、かつ必要なアクセス許可を持つ場合 true を返します。

◆ getAttribute()

static FileAttribute ln::FileSystem::getAttribute ( const StringRef filePath)
static

ファイルの属性を取得します。

Parameters
[in]filePath: ファイル名
Returns
ファイルの属性 (FileAttribute のビットの組み合わせ)

◆ getDirectories()

static DirectoryIteratorRange ln::FileSystem::getDirectories ( const StringRef dirPath,
const StringRef pattern = StringRef(),
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

指定したディレクトリ内のディレクトリパス返します。

Parameters
[in]dirPath: 検索するディレクトリのパス
[in]pattern: ディレクトリ名の検索文字列 (ワイルドカード (* および ?) を含めることができます。省略した場合はすべてのファイルを列挙します)
[in]searchOption: サブディレクトリも含めて検索するかどうか

◆ getFile()

static Path ln::FileSystem::getFile ( const StringRef dirPath,
const StringRef pattern = StringRef() 
)
static

指定したディレクトリ内の1つのファイルパス返します。

Parameters
[in]dirPath: 検索するディレクトリのパス
[in]pattern: ファイル名の検索文字列 (ワイルドカード (* および ?) を含めることができます。省略した場合はすべてのファイルを列挙します)
Returns
ファイルが見つからない場合は空の Path を返します。

これは getFiles() のユーティリティです。getFiles() で見つかった最初のファイルパスを返します。 特定の拡張子を持つファイルを1つだけ検索したい場合に使用します。

◆ getFiles()

static DirectoryIteratorRange ln::FileSystem::getFiles ( const StringRef dirPath,
const StringRef pattern = StringRef(),
SearchOption  searchOption = SearchOption::TopDirectoryOnly 
)
static

指定したディレクトリ内のファイルパス返します。

Parameters
[in]dirPath: 検索するディレクトリのパス
[in]pattern: ファイル名の検索文字列 (ワイルドカード (* および ?) を含めることができます。省略した場合はすべてのファイルを列挙します)
[in]searchOption: サブディレクトリも含めて検索するかどうか

◆ readAllBytes()

static ByteBuffer ln::FileSystem::readAllBytes ( const StringRef filePath)
static

ファイルの内容をバイナリ形式としてすべて読み込みます。

Parameters
[in]filePath: 読み込むファイルのパス
Returns
読み込んだバイナリデータ

◆ readAllText()

static String ln::FileSystem::readAllText ( const StringRef filePath,
TextEncoding encoding = nullptr 
)
static

ファイルの内容をテキスト形式としてすべて読み込ます。

Parameters
[in]filePath: 読み込むファイルのパス
[in]encoding: ファイルのエンコーディング (省略した場合、UTF8 テキストとして読み込みます)
Returns
読み込んだ文字列

ファイル先頭に UTF 系の BOM が含まれている場合、それに対応するエンコーディングで読み込みます。

◆ removeDirectory()

static void ln::FileSystem::removeDirectory ( const StringRef path,
bool  recursive = false 
)
static

ディレクトリを削除します。

Parameters
[in]path: 削除するディレクトリのパス
[in]recursive: 全てのサブディレクトリも含めて削除する場合は true

◆ removeFile()

static void ln::FileSystem::removeFile ( const StringRef filePath)
static

ファイルを削除します。

Parameters
[in]filePath: 削除するファイルのパス

削除するファイルが存在しない場合、例外はスローされません。

◆ setAttribute()

static void ln::FileSystem::setAttribute ( const StringRef filePath,
FileAttribute  attr 
)
static

ファイルの属性を設定します。

Parameters
[in]filePath: ファイル名
[in]attr: ファイルの属性 (FileAttribute のビットの組み合わせ)

この関数により変更できる属性は、読み取り属性のみです。(Unix では隠し属性はファイル名で表現されるためです) それ以外のフラグビットは無視されます。

◆ writeAllBytes()

static void ln::FileSystem::writeAllBytes ( const StringRef filePath,
const void *  buffer,
size_t  size 
)
static

指定されたバッファの内容をバイナリデータとしてすべてファイルに書き込みます。

Parameters
[in]filePath: 書き込み先のファイルのパス
[in]buffer: バッファの先頭アドレス
[in]size: バッファのバイト数

◆ writeAllText()

static void ln::FileSystem::writeAllText ( const StringRef filePath,
const String str,
TextEncoding encoding = nullptr 
)
static

文字列をテキストデータとしてすべてファイルに書き込みます。

Parameters
[in]filePath: 書き込み先のファイルのパス
[in]str: ファイルに書き込む文字列
[in]encoding: 文字列に適用するエンコーディング (省略した場合、UTF8 テキストとして書き込みます)

The documentation for this class was generated from the following file: