tags:

views:

23

answers:

0

My code copies files from ftp (using text transfer mode) to local disk and then trys to process them. All files contain only text and values are seperated using new line. Sometimes files are moved to this ftp using binary transfer mode and looks like this will mess up line-ends. Using hex editor, I compared line ends depending the transfer mode used to send files to ftp: using text mode: file endings are 0D 0A using binary mode: file endings are 0D 0D 0A

Is it possible to modify my code so it could read files in both cases? Code from job that illustrates my problem and shows how i'm reading file: (here i use same file, that contains 14 rows of data)

int         i;
container   con;
container   files = ["c:\\temp\\axa_keio\\ascii.txt", "c:\\temp\\axa_keio\\binary.txt"];

boolean     purchLineFirstRow;
IO          inFile;
;
for(i=1; i<=conlen(files); i++)
{
    inFile = new AsciiIO(conpeek(files,i), "R");
    inFile.inFieldDelimiter('\n');

    con = inFile.read();
    info(int2str(conlen(con)));
}

Files come from Unix system to Windows sytem. Not sure but maybe the question could be: "Which inFieldDelimiter values should i use to read both Unix and Windows line ends?"