<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>C++ way of setting file position for file sizes larger than 32-bits? - C++ - tribe.net</title>
  <link rel="alternate" href="http://cpp.tribe.net/thread/5627843f-1135-4e23-97ef-11fc13a693a1?format=atom" />
  <subtitle>Tribe.net. Local Connections</subtitle>
  <entry>
    <title>Re: C++ way of setting file position for file sizes larger than 32-bits?</title>
    <link rel="alternate" href="http://CPP.tribe.net/thread/5627843f-1135-4e23-97ef-11fc13a693a1#b0995a48-9613-4063-9582-acdacc3003e6" />
    <author>
      <name>Hypno</name>
    </author>
    <id>http://CPP.tribe.net/thread/5627843f-1135-4e23-97ef-11fc13a693a1#b0995a48-9613-4063-9582-acdacc3003e6</id>
    <updated>2006-11-08T07:55:04Z</updated>
    <published>2006-11-08T07:55:04Z</published>
    <summary type="html">I can't speak for other platforms but there is fsetpos() which I think is standard.   I don't know that it does a clear and you may be on your own for that.&#xD;
&#xD;
This is Windows specific but when dealing with huge files under Windows I use MapViewOfFile()/UnmapViewofFile() which memory map a window into your file in multiples of SYSTEM_INFO.dwAllocationGranularity using the system's virtual memory functions.</summary>
    <dc:creator>Hypno</dc:creator>
    <dc:date>2006-11-08T07:55:04Z</dc:date>
  </entry>
  <entry>
    <title>C++ way of setting file position for file sizes larger than 32-bits?</title>
    <link rel="alternate" href="http://CPP.tribe.net/thread/5627843f-1135-4e23-97ef-11fc13a693a1#41813685-1e0d-468e-b2cf-4e9532096a24" />
    <author>
      <name>John Michael</name>
    </author>
    <id>http://CPP.tribe.net/thread/5627843f-1135-4e23-97ef-11fc13a693a1#41813685-1e0d-468e-b2cf-4e9532096a24</id>
    <updated>2006-11-07T19:48:45Z</updated>
    <published>2006-11-07T19:48:45Z</published>
    <summary type="html">Hello, all ...&#xD;
&#xD;
I need to create a file and set it to a specific size (the idea being that there is another thread that uses std::ofstream::seekp() to write blocks to the file as they arrive off of the network, likely out of order, so if the 10th block of the file arrives before the 1st, I need to be able to handle it).  The thing is, std::ofstream::seekp() doesn't seem to allow me to seek past the end of the file and set the file position there e.g. it sets the failbit true if I try.  In C, I used to do this with feek(), so I could code something like this:&#xD;
&#xD;
fseek( pFile, 10000000, SEEK_SET ); // makes the file 10000000 bytes long if it was shorter before&#xD;
&#xD;
... but fseek() expects a long for the seek position, and this is 2006, where a long isn't big enough (files could be much larger than 4G).  I have to do this in a portable way (Windows and Mac OSX / *nix).&#xD;
&#xD;
Ideas?&#xD;
&#xD;
Regards,&#xD;
&#xD;
John, looking for a simple solution&#xD;
&#xD;
Falling You - exploring the beauty of voice and sound&#xD;
http://www.fallingyou.com</summary>
    <dc:creator>John Michael</dc:creator>
    <dc:date>2006-11-07T19:48:45Z</dc:date>
  </entry>
</feed>



