[Serialization] Testing if a provided file is actually a serialized archive

Hi, I would like to know if there exists a way to check for a given file if it is actually a serialized archive or a pure txt-file, at best without the need to read in that file completely. At the moment, I use boost::serialization to store self-defined class-instances in txt-files, so using something like the system's "file"-command would not bring me far. Now I would like my program to distinguish if the provided input-argument is a text-file that needs to be parsed or if it can simply restore this previous instance. Of course, using a separate option indicating if an archive was passed would work, but IMHO is not very beautiful. Best, Cedric

Cedric Laczny wrote:
Hi,
I would like to know if there exists a way to check for a given file if it is actually a serialized archive or a pure txt-file, at best without the need to read in that file completely. At the moment, I use boost::serialization to store self-defined class-instances in txt-files, so using something like the system's "file"-command would not bring me far. Now I would like my program to distinguish if the provided input-argument is a text-file that needs to be parsed or if it can simply restore this previous instance. Of course, using a separate option indicating if an archive was passed would work, but IMHO is not very beautiful.
serialization archives can be identified by special common text in the first line. Robert Ramey
participants (2)
-
Cedric Laczny
-
Robert Ramey