[fs.op.is.empty]

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

## 31.12 File systems [[filesystems]](filesystems#fs.op.is.empty)

### 31.12.13 Filesystem operation functions [[fs.op.funcs]](fs.op.funcs#fs.op.is.empty)

#### 31.12.13.20 Is empty [fs.op.is.empty]

[ð](#lib:is_empty,function)

`bool filesystem::is_empty(const path& p);
bool filesystem::is_empty(const path& p, error_code& ec);
`

[1](#1)

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

*Effects*: 

- [(1.1)](#1.1)

  Determine file_status s,
 as if by status(p) or status(p, ec), respectively[.](#1.1.sentence-1)

- [(1.2)](#1.2)

  For the signature with argument ec,
 return false if an error occurred[.](#1.2.sentence-1)

- [(1.3)](#1.3)

  Otherwise, if is_directory(s):
  * [(1.3.1)](#1.3.1)

      Create a variable itr,
 as if by directory_iterator itr(p) or directory_iterator itr(p, ec), respectively[.](#1.3.1.sentence-1)

  * [(1.3.2)](#1.3.2)

      For the signature with argument ec,
 return false if an error occurred[.](#1.3.2.sentence-1)

  * [(1.3.3)](#1.3.3)

      Otherwise, return itr == directory_iterator()[.](#1.3.3.sentence-1)

- [(1.4)](#1.4)

  Otherwise:
  * [(1.4.1)](#1.4.1)

      Determine uintmax_t sz,
 as if by file_size(p) or file_size(p, ec), respectively[.](#1.4.1.sentence-1)

  * [(1.4.2)](#1.4.2)

      For the signature with argument ec,
 return false if an error occurred[.](#1.4.2.sentence-1)

  * [(1.4.3)](#1.4.3)

      Otherwise, return sz == 0[.](#1.4.3.sentence-1)

[2](#2)

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

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