title: Can a std::ifstream/FILE* change size?
body: <p>Say I have the following code (which just opens a file, gets its size, and reads it all in one go):</p>
  
  <pre><code>std::ifstream file(path, std::ios_base::binary | std::ios_base::ate);
  std::istream::streampos file_size = file.tellg();
  file.seekg(0);
  char* buffer = new char[file_size];
  file.read(buffer, file_size);
  </code></pre>
  
  <p>Is it possible for the file to change size in between the <code>file.tellg()</code> and the <code>file.read()</code> calls (i.e. another program modifies the file)? That is, if <code>file.read()</code> succeeds, is it guaranteed that <code>file.gcount() == file_size</code>?</p>
  
  <p>And extending this to C* (i.e. doing <code>fopen("rb")</code>, <code>fseek()</code>, <code>ftell()</code>, <code>rewind()</code>, <code>fread()</code>), if <code>fread()</code> succeeds, will it always return the file size (as previously reported by <code>ftell()</code>)?</p>
  
  <p>I'm leaning towards this being implementation defined, but I'm curious if the C++ standard (or C standard, as the C++ standard refers to it for the <code>FILE</code>-related functions) makes any guarantees here or not.</p>
  
  <p><sub>*I'm working in C++, and there are two ways for me to work with files: <code>std::fstream</code> and <code>FILE*</code>. The C++ standard defers to the C standard regarding the <code>FILE*</code> functions, which is why I bring up C explicitly here.</sub></p>