This function uses a POSIX-style function, which only calls its corresponding posix function on most platforms, implemented in nlib to read a text file and displays it on the console. Although the function can be used in the same way as its corresponding posix function, it returns an error value as the return value. Note that it will not return -1 or set an errno
.
NLIB_PATHMAPPER_FORSAMPLE
bool SampleMain(int, char**) {
InitPathMapperForSample();
char filename[1024];
g_pathmapper.ResolvePath(NULL, filename, "nlibpath:///readonly/readfile.cpp");
if (e != 0) return false;
if (e != 0) {
return false;
}
size_t filesize = static_cast<size_t>(filesize_);
if (!text) {
return false;
}
text[filesize] = '\0';
while (filesize > 0) {
size_t readsize;
if (e != 0) {
return false;
}
filesize -= readsize;
}
if (e != 0) return false;
return true;
}
NLIB_MAINFUNC