tags:

views:

112

answers:

2

We have an application that reads in a flat file and parses out the data. This file contains no header information or total data with which to do a checksum. So I would like to create test cases to make sure our application properly handles "incomplete" files.

Is there a way to create a flat file with no EOF marker? Perhaps a tool that I can use to remove the EOF marker from an existing text file?

+3  A: 

Flat files do not contain an end of file marker.

Almost all modern filesystems are stream based, just a bunch of bytes on disk, they don't have record/file markers.
Any end-of-file signal is added by the std library reading the file

You should test that it deals properly with incomplete lines (ie 3 values rather than 4) and missing/differnet end of lines (CR or LF rather than CR/LF)

Martin Beckett
A: 

There is no standard EOF character - EOF is a condition returned by the method that reads from a file. For example, in C, getchar will return a system-specific negative value when it reaches the end of a file.

Terminals will send back ASCII 4 (EOT, for end of transmission) when they are done transmitting, but this doesn't help you much as you aren't going to have EOTs in your files to begin with.

So, this is good news for you - all your files are going to be treated the same, and you don't have to worry about handling files with no end.

danben