std::experimental::filesystem::path:: extension
| Technical Specification | ||||
| Filesystem library (filesystem TS) | ||||
| Library fundamentals (library fundamentals TS) | ||||
| Library fundamentals 2 (library fundamentals TS v2) | ||||
| Library fundamentals 3 (library fundamentals TS v3) | ||||
| Extensions for parallelism (parallelism TS) | ||||
| Extensions for parallelism 2 (parallelism TS v2) | ||||
| Extensions for concurrency (concurrency TS) | ||||
| Extensions for concurrency 2 (concurrency TS v2) | ||||
| Concepts (concepts TS) | ||||
| Ranges (ranges TS) | ||||
| Reflection (reflection TS) | ||||
| Mathematical special functions (special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Classes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| File types | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Path decomposition | ||||
| Non-member functions | ||||
|
path extension
(
)
const
;
|
(filesystem TS) | |
パスのファイル名コンポーネントの拡張子を返します * this 。
パスの
filename()
コンポーネントがピリオド(
.
)を含み、かつ特別なファイルシステム要素である
dot
または
dot-dot
でない場合、
extension
は、最も右側のピリオド(ピリオドを含む)からパス名の終わりまでの部分文字列である。
パス名が
.
または
..
の場合、あるいは
filename()
が
.
文字を含まない場合、空のパスが返されます。
実装によっては、ファイルシステムに対して拡張子に追加の要素(代替データストリームや区分データセット名など)を付加する動作が定義される場合があります。
目次 |
パラメータ
(なし)
戻り値
現在のパス名の拡張子、または拡張子がない場合は空のパス。
例外
実装定義の例外をスローする可能性があります。
注記
この関数が返す拡張子には、ピリオドが含まれています。これにより、ピリオドで終わるファイル(関数が "." を返す場合)と拡張子がないファイル(関数が "" を返す場合)を区別することが可能になります。
任意のパス
p
について、
p.
stem
(
)
+
p.
extension
(
)
==
p.
filename
(
)
が成り立ちます。
例
#include <experimental/filesystem> #include <iostream> namespace fs = std::experimental::filesystem; int main() { std::cout << fs::path("/foo/bar.txt").extension() << '\n' << fs::path("/foo/bar.").extension() << '\n' << fs::path("/foo/bar").extension() << '\n' << fs::path("/foo/bar.txt/bar.cc").extension() << '\n' << fs::path("/foo/bar.txt/bar.").extension() << '\n' << fs::path("/foo/bar.txt/bar").extension() << '\n' << fs::path("/foo/.").extension() << '\n' << fs::path("/foo/..").extension() << '\n' << fs::path("/foo/.hidden").extension() << '\n'; }
出力:
".txt" "." "" ".cc" "." "" "" "" ".hidden"
関連項目
|
ファイル名パスコンポーネントを返す
(公開メンバ関数) |
|
|
ステムパスコンポーネントを返す
(公開メンバ関数) |
|
|
拡張子を置換する
(公開メンバ関数) |
|
|
対応するパス要素が空でないかチェックする
(公開メンバ関数) |