EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SolFSStream.Seek can cause file truncation

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#29369
Posted: 05/05/2014 17:03:37
by Jeremy Spiegel (Standard support level)
Joined: 01/29/2014
Posts: 16

I found that if I seek beyond the end of a file and then seek back to the beginning, the file is truncated to zero bytes. The following code demonstrates the problem:
Code
{
        SolFSStorage storage;
        storage.set_FileName("/tmp/storage");
        storage.Open(somCreateAlways);
        SolFSStream stream(&storage, "/file", "w");
        stream.Write("a", 1);
        stream.Seek(2, 0);
        stream.Seek(0, 0);
}
SolFSStorage storage;
storage.set_FileName("/tmp/storage");
storage.Open(somOpenExisting);
std::cout << SolFSStream(&storage, "/file", "r").get_Length() << std::endl;


The code above prints out "0", but if I remove either or both of the Seeks, it prints out "1".

Thanks!
#29371
Posted: 05/06/2014 01:33:18
by Eugene Mayevski (EldoS Corp.)

Moved to Helpdesk.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 2055 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!