#ifndef ENVIOPEN_H #define ENVIOPEN_H #include #include #include #include #include #include #include "EnviHeader.h" #include "EnviFid.h" using namespace std; //return value is incorrect static EnviFidClass EnviOpen(string filename, char* mask = NULL, string mode = "r", int nBands = 0, int sX = 0) { //create a file ID object EnviFidClass fid; //set the file read/write mode fid.mode = mode; //set the mask (if specified) fid.mask = mask; // load the header file only while reading if(mode=="r") { //load the header file int error = fid.header.LoadHeader(filename); //if the LoadHeader function is not zero, the header is invalid if (error != 0) { fid.isValid = 0; return fid; } } //default header to be used in case of writing a file else { fid.header.datatype= 4; fid.header.nF= nBands; fid.header.sX=0; fid.header.sY=1; fid.header.headersize=0; } //load the binary file associated with this header //get the binary file name //find the binary file name //locate the position of the extension int pos = filename.find(".hdr"); string binaryname = filename.substr(0, pos); //load the binary file using fopen() //store the resulting FILE pointer in the EnviFidClass variable mode += "b"; fid.file = fopen (binaryname.c_str(), mode.c_str()); if(fid.file == NULL) { cout<<"Error opening binary file."<