I am running a file that works normally in a Windows environment on Linux.
Binary files created on Windows are read by Linux.
Data that was normally displayed on Windows does not work on Linux.
Is there any other way of reading data that is unique to Linux that I don't know?
What I have tried:
class File_ptr
{
FILE *p;
public:
File_ptr(const char *n, const char *a) { p = fopen(n, a); };
File_ptr(FILE *pp) { p = pp; };
~File_ptr()
{
if (p)
fclose(p);
};
operator FILE *() { return p; };
};
#pragma pack(push, 1)
typedef struct _CTE_
{
unsigned short Version;
unsigned short Signature;
unsigned short core;
unsigned short editmode
} CTE;
#pragma pack(pop) t
#pragma pack(push, 1)
typedef struct _GTE_
{
unsigned char LTL : 1;
unsigned char trans : 1;
uint_least8_t wcountry;
uint_least8_t wlanguage;
unsigned int count;
int WIDTH;
int HEIGHT;
} GTE;
#pragma pack(push, 1)
class WXR
{
_HEADERFILEINFO_ m_FileHeader;
_PROPERTIES_ m_properties;
public:
WXR();
~WXR();
const void OpenProjectFile(const int id);
const void LoadHeader(FILE *hFile);
}
WXR::WXR() :
m_FileHeader{1, 42,10, 0},
m_properties{1, 1, 9, 142, 0, 1920, 1080 }
{
}
WXR::~WXR()
{
m_FileHeader = {};
m_properties = {};
}
const void WXR::OpenProjectFile(const int id)
{
const char *dir = NULL;
if (id == 1)
{
dir = "data/1.pro/Project.txt";
}
else if (id == 2)
{
dir = "data/2.pro/Project.txt";
}
else if (id == 3)
{
dir = "data/3.pro/Project.txt";
}
else if (id == 4)
{
dir = "data/4.pro/Project.txt";
}
else
{
cout << "error file" << endl;
return;
}
File_ptr *fp = new File_ptr(dir, "rb+,ccs=UNICODE");
cout << __LINE__ << fp << endl;
if (fp == NULL)
{
fprintf(stderr, "Couldn't open file for reading\n");
exit(1);
}
LoadHeader(*fp);
LoadProperties(*fp);
delete fp;
}
const void WXR::LoadHeader(FILE *hFile)
{
cout << __LINE__ << hFile << endl;
cout << "headsize: " << sizeof(struct _HEADERFILEINFO_) << endl;
fread(&m_FileHeader, sizeof(struct _HEADERFILEINFO_), 1, hFile);
cout << __LINE__ << " " << m_FileHeader.Version << endl;
cout << __LINE__ << " " << m_FileHeader.Signature << endl;
cout << __LINE__ << " " << m_FileHeader.core << endl;
cout << __LINE__ << " " << m_FileHeader.editmode << endl;
}
const void WXR::LoadProperties(FILE *hFile)
{
cout << __LINE__ << hFile << endl;
cout << "properties: " << sizeof(struct _PROPERTIES_) << endl;
fread(&m_properties, sizeof(struct _PROPERTIES_), 1, hFile);
cout << __LINE__ << " " << m_properties.LTL << endl;
cout << __LINE__ << " " << m_properties.trans << endl;
cout << __LINE__ << " " << m_properties.wcountry << endl;
cout << __LINE__ << " " << m_properties.wlanguage << endl;
cout << __LINE__ << " " << m_properties.count << endl;
cout << __LINE__ << " " << m_properties.WIDTH << endl;
cout << __LINE__ << " " << m_properties.HEIGHT << endl;
}
=====================================================================================
Result:
windows(vscode) | Linux
*fp 000002990A254F80 0x66f1a10
hFile 000002990A3307A0 0x66f1a10
headsize: (size) 8 8
1 0
42 0
10 0
1 0
hFile: (size) 000002990A3307A0 0x66f1a10
properties 15 15
^@
^@
^@
^@
15 0
1920 0
1080 0