M
mag
Let's start off by saying I'm a noob to .Net but here's my problem.
I have many files, all with the same structure.
I know the structure, It was written in some version of C++.
Because it seem to be a null terminated or serialized file
structure.....
using text readers reads only until the first null and thinks it has
reached the EOF.
Using the BinaryReader and the BaseStream.Position I know where I'm at
in the file. However, most of the file is numeric and presenting no
dificulties, but one field is text and I cannot get it to display in a
Datagrid other than numeric. The numeric values of the text field do
not corrolate to ansi, ascii, or anything else I can determine.
Here is a small sampling of the code that wrote the file:
in.open(filename, ios::binary);
if (in.fail())
return false;
in.read((char*)&Version, sizeof(unsigned int));
if (Version != DB_VERSION) { // fixme
in.close();
return false;
}
Id << in;
in.read((char*)&totalX, sizeof(unsigned int));
in.read((char*)&totalY, sizeof(unsigned int));
in.read((char*)&totalZ, sizeof(unsigned int));
in.read((char*)&total1, sizeof(unsigned int));
through position 580 then the text part is added
const bool Namespace::Write(const char* path, const char* name)
{
const unsigned int currentVersion = DB_VERSION;
ofstream out;
ifstream in;
char filename[MAX_PATH + MAX_ID_STRING+1];
int i, j, n;
char namesUsed[3][MAX_NAME+1];
unsigned int nameCount[3];
bool done, newFile;
int mostIdx[3] = {-1,-1,-1};
unsigned int topNum;
int topIdx;
unsigned int Version;
n = (unsigned)strlen(path);
if (n > MAX_PATH)
n = MAX_PATH;
strncpy(filename, path, n);
steamId.ToStr(filename + n);
strcat(filename, ".some extension");
// replace ':' with '-' in filename
for (i=n, n=strlen(filename); i < n; i++) {
if (filename == ':')
filename = '-';
}
// Read file and store the namesUsed and nameCount variables
in.open(filename, ios::binary);
newFile = (in.fail() || in.peek() == EOF);
for(i=0; i<3; i++) {
namesUsed[0] = 0;
nameCount = 0;
}
Any Help would be Greatly appreciated. I have been working on this
issue for two weeks, using many google searches and samples.
Thanks
I have many files, all with the same structure.
I know the structure, It was written in some version of C++.
Because it seem to be a null terminated or serialized file
structure.....
using text readers reads only until the first null and thinks it has
reached the EOF.
Using the BinaryReader and the BaseStream.Position I know where I'm at
in the file. However, most of the file is numeric and presenting no
dificulties, but one field is text and I cannot get it to display in a
Datagrid other than numeric. The numeric values of the text field do
not corrolate to ansi, ascii, or anything else I can determine.
Here is a small sampling of the code that wrote the file:
in.open(filename, ios::binary);
if (in.fail())
return false;
in.read((char*)&Version, sizeof(unsigned int));
if (Version != DB_VERSION) { // fixme
in.close();
return false;
}
Id << in;
in.read((char*)&totalX, sizeof(unsigned int));
in.read((char*)&totalY, sizeof(unsigned int));
in.read((char*)&totalZ, sizeof(unsigned int));
in.read((char*)&total1, sizeof(unsigned int));
through position 580 then the text part is added
const bool Namespace::Write(const char* path, const char* name)
{
const unsigned int currentVersion = DB_VERSION;
ofstream out;
ifstream in;
char filename[MAX_PATH + MAX_ID_STRING+1];
int i, j, n;
char namesUsed[3][MAX_NAME+1];
unsigned int nameCount[3];
bool done, newFile;
int mostIdx[3] = {-1,-1,-1};
unsigned int topNum;
int topIdx;
unsigned int Version;
n = (unsigned)strlen(path);
if (n > MAX_PATH)
n = MAX_PATH;
strncpy(filename, path, n);
steamId.ToStr(filename + n);
strcat(filename, ".some extension");
// replace ':' with '-' in filename
for (i=n, n=strlen(filename); i < n; i++) {
if (filename == ':')
filename = '-';
}
// Read file and store the namesUsed and nameCount variables
in.open(filename, ios::binary);
newFile = (in.fail() || in.peek() == EOF);
for(i=0; i<3; i++) {
namesUsed[0] = 0;
nameCount = 0;
}
Any Help would be Greatly appreciated. I have been working on this
issue for two weeks, using many google searches and samples.
Thanks