std::experimental::filesystem::file_size - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::experimental::filesystem::file_size

From cppreference.com
< cpp‎ | experimental‎ | fs

Defined in header `<experimental/filesystem>` |  |
uintmax_t file_size( const path& p ); | (1) | (filesystem TS)
uintmax_t file_size( const path& p, error_code& ec ); | (2) | (filesystem TS)

Returns the size of a regular file. If `p` does not resolve to a regular file, returns -1.

The second version sets `ec` to an appropriate error code if an error occurs. Otherwise, `ec` is cleared with a call to ec.clear().

| This section is incomplete Reason: does the first version throw if `p` is not a regular file?

### [edit] Parameters

p | - | path to the regular file
ec | - | error code to modify in case of error

### [edit] Return value

The size of the file or -1 on error.

### [edit] Exceptions

1) filesystem_error if an error occurs. The exception object is constructed with `p` as an argument. The error code is set to an appropriate error code for the error that caused the failure.
2)
`noexcept` specification:
noexcept

### [edit] See also

| This section is incomplete

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/experimental/fs/file_size&oldid=68533"
Categories:

- Todo with reason
- unconditionally noexcept
- Todo without reason