Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="http://wikis.sun.com/display/WideFinder/Results" rel="nofollow noreferrer">Widefinder 2 has a lot of talk about efficient IO available</a> (or, more accurately, the links under the "Notes" column have a lot of information about efficient IO available).</p> <p>Answering your question:</p> <ol> <li>(Title) Remove first 500,000 bytes from a file with the [standard library]</li> </ol> <p>The standard library is somewhat limited when it comes to filesystem operations. If you're not limited to the standard library you can end a file prematurely very easily (that is, say "everything after this point is no longer part of this file"), but it's very hard to start a file late ("everything before this point is no longer part of this file").</p> <p>It would be efficient to simply seek 500,000 bytes into the file and then start a buffered copy to a new file. But once you've done that, the standard libary doesn't have a ready-made "rename this file" function. Native OS functions can rename files efficiently, as can Boost.Filesystem or STLSoft.</p> <ol start="2"> <li>(Actual question) Our logging class, on initialisation, seeks to 500,000 bytes before the end of the file, copies the rest to a <code>std::string</code> and then writes that back to the file.</li> </ol> <p>In this case you're dropping the last bit of the file, and it's very easy to do outside the standard library. Simply use the filesystem operations to set the file size to 500,000 bytes (e.g., <a href="http://pubs.opengroup.org/onlinepubs/007908799/xsh/ftruncate.html" rel="nofollow noreferrer"><code>ftruncate</code></a>, <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa365531.aspx" rel="nofollow noreferrer"><code>SetEndOfFile</code></a>). Anything after that will be ignored.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload