void MainWindow::synTwoFiles(QString fileA, QString fileB) { if(isPathExcept(fileA)) return; QFileInfo aFile(fileA); QFileInfo bFile(fileB); // qDebug() << "fileA:" + fileA; // qDebug() << "fileB:" + fileB; // 同步增加或修改 if(aFile.exists()) { // 同步修改 if(bFile.exists() && synModify && aFile.lastModified() != bFile.lastModified()) { if(!QFile::remove(fileB)) qDebug() << "can't delete : " + fileB; if(!QFile::copy(fileA, fileB)) { qDebug() << "can't copy : " + fileA; } else { lastSynFileNotify("正在修改: " + fileB); qDebug() << "copy : " + fileA; } } else if(!bFile.exists() && synAdd) { // 同步增加 if(!QFile::copy(fileA, fileB)) { qDebug() << "can't copy : " + fileA; } else { lastSynFileNotify("正在增加: " + fileB); qDebug() << "copy : " + fileA; } } } // 同步删除 else { if(bFile.exists() && synDel) { if(!QFile::remove(fileB)) qDebug() << "can't delete : " + fileB; else { lastSynFileNotify("正在删除: " + fileB); qDebug() << "del :" + fileB; } } } }
KANGAROO_EXPORT void SavePXMBoundingBox( const std::string filename, roo::BoundingBox BBox) { std::ofstream bFile( filename.c_str(), std::ios::out | std::ios::binary ); bFile << BBox.boxmin.x << " " << BBox.boxmin.y << " " << BBox.boxmin.z << std::endl; bFile << BBox.boxmax.x << " " << BBox.boxmax.y << " " << BBox.boxmax.z << std::endl; bFile.close(); }
bool CheckIfBBfileExist(std::string filename) { std::ifstream bFile( filename.c_str(), std::ios::in | std::ios::binary ); if(bFile.fail()==true) { return false; } bFile.close(); return true; }
TypedImage LoadImage( const std::string& filename, const PixelFormat& raw_fmt, size_t raw_width, size_t raw_height, size_t raw_pitch ) { TypedImage img(raw_width, raw_height, raw_fmt, raw_pitch); // Read from file, row at a time. std::ifstream bFile( filename.c_str(), std::ios::in | std::ios::binary ); for(size_t r=0; r<img.h; ++r) { bFile.read( (char*)img.ptr + r*img.pitch, img.pitch ); if(bFile.fail()) { pango_print_warn("Unable to read raw image file to completion."); break; } } return img; }
TypedImage LoadPpm(const std::string& filename) { std::ifstream bFile( filename.c_str(), std::ios::in | std::ios::binary ); return LoadPpm(bFile); }