int main(void) { FILE *f; char data[65536]; struct acquisition_info info; f = fopen("teste", "r"); fread(&info, sizeof(info), 1, f); fread(data, 65536, 1, f); fclose(f); strcpy(info.filename, "test-tiff.tiff"); save_images(data, NULL, &info); }
static void save_height_maps(void) { save_images(heightmap_file_prefix, heightmap_image); }
static void save_normal_maps(void) { save_images(normal_file_prefix, normal_image); }
static void save_output_images(void) { save_images(output_file_prefix, output_image); }
void save_file(QString text , int pageid , int revid , QString page_title) { if(!check_links(text)) // check the html to see if there are any dependencies that needs to be downloaded { QDir dir(data_path); // set path to application data location dir.cd("WTL_appdata"); // change to the application data location QString Folder_name = dir.absoluteFilePath(QString::number(pageid)); // Folder_name = Generic location of application data ( varies from OS to OS ) + filename(pageid) QString fname = QString::number(pageid); if(QDir(Folder_name).exists()) // checks if the file already exists or not { qDebug() << " already exist "; } else{ // save the file QDir dir(data_path); dir.cd("WTL_appdata"); dir.mkdir(Folder_name); QString filename = dir.absoluteFilePath(Folder_name+".html"); QFile file(filename); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"main.css\">" +text; text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"wikitolearnskin.css\">" + text; text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"bootstrap.css\">" + text; out << text; // optional, as QFile destructor will already do it: file.close(); // move html file to their respective folder QString temp_name = dir.absoluteFilePath(filename); QString new_name = temp_name.replace(".html",""); QString css_path = new_name; new_name = new_name + "/" + fname +".html"; file.rename(filename,new_name); css_path = css_path + "/main.css"; file.copy(dir.absoluteFilePath("main.css"),css_path); bool success = add_in_db(pageid,revid,page_title); if(success == true) { qDebug() <<"entry added to DB successfully "; } else { qDebug() <<" failed to add in DB "; } } } else { dbmanager d; // created object of dbmanager to access private variables and functions of dbmanager.h QDir dir(data_path); dir.cd("WTL_appdata"); // imageDownloadPath is going to be the same path as of it's html file d.imageDownloadPath = dir.absoluteFilePath(QString::number(pageid)); imgpath = d.imageDownloadPath; if(QDir(d.imageDownloadPath).exists()) // checks if the files are already saved { qDebug() << " already exist "; } else{ dir.mkdir(d.imageDownloadPath); QString filename = d.imageDownloadPath+".html"; QFile file(filename); file.open(QIODevice::WriteOnly | QIODevice::Text); QTextStream out(&file); out << text; // optional, as QFile destructor will already do it: file.close(); // add entries to the database ( i.e. in Pages table ) bool success = add_in_db(pageid,revid,page_title); if(success == true) { qDebug() <<"entry added to DB successfully "; } else { qDebug() <<" failed to add in DB "; } // call save_images function save the images // filename is html filename which will be read to extract URLs from it // filename has the same name as of pageid success = save_images(filename,pageid); if(success == true) { qDebug() << "images downloaded successfully "; } else { qDebug() << "error in downloading images"; } } } }