title: How does a program determine the size of a file without reading it whole?
body: <p>In the question <a href="https://stackoverflow.com/questions/2409504/using-c-filestreams-fstream-how-can-you-determine-the-size-of-a-file">Using C++ filestreams (fstream), how can you determine the size of a file?</a>, the top answer is the following C++ snippet:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>ifstream file("example.txt", ios::binary | ios::ate);
  return file.tellg();
  </code></pre>
  
  <p>Running it myself I noticed that the size of arbitrarily large files could be determined instantaneously and with a <em>single</em> read operation.</p>
  
  <p>Conventionally I would assume that to determine the size of a file, one would have to move through it byte-by-byte, adding to a byte-counter. How is this achieved instead? Metadata?</p>