[fs.op.file.size]

# 31 Input/output library [[input.output]](./#input.output)

## 31.12 File systems [[filesystems]](filesystems#fs.op.file.size)

### 31.12.13 Filesystem operation functions [[fs.op.funcs]](fs.op.funcs#fs.op.file.size)

#### 31.12.13.15 File size [fs.op.file.size]

[ð](#lib:file_size)

`uintmax_t filesystem::file_size(const path& p);
uintmax_t filesystem::file_size(const path& p, error_code& ec) noexcept;
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17879)

*Effects*: If exists(p) is false, an error is reported ([[fs.err.report]](fs.err.report "31.12.5 Error reporting"))[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17883)

*Returns*: 

- [(2.1)](#2.1)

  If is_regular_file(p), the size in bytes of the file p resolves to, determined as if by the value of the POSIX stat class member st_size obtained as if by POSIX [stat](http://pubs.opengroup.org/onlinepubs/9699919799/functions/stat.html)[.](#2.1.sentence-1)

- [(2.2)](#2.2)

  Otherwise, the result is implementation-defined[.](#2.2.sentence-1)

The signature with argument ec returns static_cast<uintmax_t>(-1) if an error occurs[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L17896)

*Throws*: As specified in [[fs.err.report]](fs.err.report "31.12.5 Error reporting")[.](#3.sentence-1)
