Check that file exists: Difference between revisions

Content added Content deleted
m (Adjusted text formatting issues.)
m (Improved grammar in comments.)
Line 967: Line 967:


===Using C++ 17===
===Using C++ 17===
C++ 17 contains a Filesystem library which significantly improves manipulations with files.
C++ 17 contains a Filesystem library which significantly improves operations with files.
<syntaxhighlight lang="c++">
<syntaxhighlight lang="c++">


Line 987: Line 987:


int main() {
int main() {
file_exists("C:/input.txt");
file_exists("input.txt");
file_exists("C:/zero_length.txt");
file_exists("zero_length.txt");
file_exists("C:/docs/input2.txt");
file_exists("docs/input.txt");
file_exists("C:/docs/zero_length2.txt");
file_exists("docs/zero_length.txt");
}
}
</syntaxhighlight>
</syntaxhighlight>
{{ out }}
{{ out }}
</pre>
</pre>
"C:/input.txt" exists with a file size of 11 bytes.
"input.txt" exists with a file size of 11 bytes.


"C:/zero_length.txt" exists with a file size of 0 bytes.
"zero_length.txt" exists with a file size of 0 bytes.


"C:/docs/input2.txt" exists with a file size of 11 bytes.
"docs/input.txt" exists with a file size of 11 bytes.


"C:/docs/zero_length2.txt" exists with a file size of 0 bytes.
"docs/zero_length.txt" exists with a file size of 0 bytes.
</pre>
</pre>