bool Zipped::zipItem(const MappedFile& item, const wchar_t* basename, int compressionLevel, unsigned long long itemFiletime) { char s[MAX_BASENAME_LENGTH * 3 + 1]; //assume worst-case non-ASCII 3 bytes per character WideCharToMultiByte(CP_UTF8, 0, basename, -1, s, sizeof(s), 0, 0); zip_fileinfo fi; const zip_fileinfo* fip = setFileInfo(&fi, itemFiletime); zipOpenNewFileInZip(zip_, s, fip, 0, 0, 0, 0, 0, Z_DEFLATED, compressionLevel); unsigned int numMaps = item.numMaps(); unsigned int bytesToWrite = (numMaps > 1)? mapSize_: static_cast<unsigned int>(item.size()); unsigned long long remainingBytes = item.size(); for (unsigned int i = 0; i < numMaps;) { const unsigned char* src = item.map(i); if (++i == numMaps) { bytesToWrite = static_cast<unsigned int>(remainingBytes); } zipWriteInFileInZip(zip_, src, bytesToWrite); remainingBytes -= bytesToWrite; } zipCloseFileInZip(zip_); bool ok = true; return ok; }
bool FileRepository::readRepoMd5(const StringData *path, FileInfo& fileInfo) { MD5 md5; bool found; { UnitMd5Map::const_accessor acc; found = s_unitMd5Map.find(acc, path); if (found) { if (!acc->second.m_present) { return false; } md5 = acc->second.m_unitMd5; path = acc->first; } } if (!found) { UnitMd5Map::accessor acc; path = StringData::GetStaticString(path); if (s_unitMd5Map.insert(acc, path)) { if (!VM::Repo::get().findFile(path->data(), SourceRootInfo::GetCurrentSourceRoot(), md5)) { acc->second.m_present = false; return false; } acc->second.m_present = true; acc->second.m_unitMd5 = md5; } else { md5 = acc->second.m_unitMd5; path = acc->first; } } setFileInfo(path, md5.toString(), fileInfo, true); return true; }
void TPlaylistItem::setFilename(const QString &fileName, const QString& baseName) { mFilename = fileName; mBaseName = baseName; setFileInfo(); }
bool FileRepository::readActualFile(const StringData *name, const struct stat &s, FileInfo &fileInfo) { if (s.st_size > StringData::MaxSize) { throw FatalErrorException(0, "file %s is too big", name->data()); } int fileSize = s.st_size; if (!fileSize) return false; int fd = open(name->data(), O_RDONLY); if (!fd) return false; // ignore file open exception String str = String(fileSize, ReserveString); char *input = str.mutableSlice().ptr; if (!input) return false; int nbytes = read(fd, input, fileSize); close(fd); str.setSize(fileSize); fileInfo.m_inputString = str; if (nbytes != fileSize) return false; if (md5Enabled()) { string md5 = StringUtil::MD5(fileInfo.m_inputString).c_str(); setFileInfo(name, md5, fileInfo, false); } return true; }
void djvFileEdit::buttonCallback() { djvFileBrowser * fileBrowser = djvFileBrowser::global(); if (QDialog::Accepted == fileBrowser->exec()) { setFileInfo(fileBrowser->fileInfo()); } }
void QQChatDlg::openPathDialog(bool) { QString file_path = QFileDialog::getOpenFileName(this, tr("select the image to send"), QString(), tr("Image Files(*.png *.jpg *.bmp *.gif)")); if (file_path.isEmpty()) return; if (!img_sender_) { img_sender_ = createImgSender(); connect(img_sender_, SIGNAL(postResult(QString,FileInfo)), this, SLOT(setFileInfo(QString, FileInfo))); connect(img_sender_, SIGNAL(sendDone(const QString &, const QString&)), &te_input_, SLOT(setRealImg(const QString&,const QString&))); }
bool Buffer::open(const QString &fileName) { // Open the file QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { return false; } QTextStream input(&file); input.setCodec(m_encoding->name()); QString content = input.readAll(); setText(content.toUtf8()); file.close(); // File opened succesfully setFileInfo(QFileInfo(fileName)); emptyUndoBuffer(); setSavePoint(); return true; }
bool Buffer::save(const QString &fileName) { // Save the file QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { return false; } // Save the text to a file. QTextStream output(&file); QByteArray content = getText(textLength() + 1); output.setCodec(m_encoding->name()); output << QString::fromUtf8(content); output.flush(); file.close(); // File saved setFileInfo(QFileInfo(fileName)); setSavePoint(); return true; }
bool FileWriter::writeFrequenciesToFile(vector<double> frequencyList) { string writeFilename; setFileInfo(FREQUENCY); ofstream myFileAcceleration; writeFilename = oFreq_Directory + FREQUENCIES_FILENAME; myFileAcceleration.open(writeFilename.c_str()); myFileAcceleration << header << fileInfo << BREAK_TOP << FREQUENCY << " " << LIST_BEGIN2 << "\n"; for(unsigned int i = 0; i < frequencyList.size(); i ++) { myFileAcceleration << frequencyList[i] << "\n"; } myFileAcceleration << LIST_END2 << "\n\n" << BREAK_BOTTOM; myFileAcceleration.close(); return true; }
bool FileWriter::writeDirectionsToFile(vector<double> directionList) { string writeFilename; setFileInfo(DIRECTION); ofstream myFileAcceleration; writeFilename = oFreq_Directory + DIRECTIONS_FILENAME; myFileAcceleration.open(writeFilename.c_str()); myFileAcceleration << header << fileInfo << BREAK_TOP << DIRECTION << " " << LIST_BEGIN2 << "\n"; for(unsigned int i = 0; i < directionList.size(); i ++) { myFileAcceleration << directionList[i] << "\n"; } myFileAcceleration << LIST_END2 << "\n\n" << BREAK_BOTTOM; myFileAcceleration.close(); return true; }
void Buffer::clear() { // Clear the file name and the editor clearAll(); setFileInfo(QFileInfo("")); setSavePoint(); }
void djvFileEdit::editCallback() { setFileInfo(_p->edit->text()); }
bool FileWriter::writeToFile(int curWaveDirection) { ofstream myFileMotion; ofstream myFileVelocity; ofstream myFileAcceleration; string dirNum = boost::lexical_cast<string>(curWaveDirection); //cast int to string for comparison string currentDirectory = DIR_NAME + dirNum; //Create the current directory if (!create_directory(oFreq_Directory + currentDirectory)) { cerr << "Failed to create " + currentDirectory << endl; //This needs to be handled return false; } string filepath; filepath = currentDirectory + "/" + GLOBAL_MOTION_FILENAME; myFileMotion.open(filepath.c_str()); //Create the Motion file filepath = currentDirectory + "/" + GLOBAL_VELOCITY_FILENAME; myFileVelocity.open(filepath.c_str()); //Create the Velocity file filepath = currentDirectory + "/" + GLOBAL_ACCELERATION_FILENAME; myFileAcceleration.open(filepath.c_str()); //Create the Acceleration file setFileInfo(GLOBAL_ACCELERATION_OBJECT); myFileMotion << header << fileInfo << BREAK_TOP; setFileInfo(GLOBAL_VELOCITY_OBJECT); myFileVelocity << header << fileInfo << BREAK_TOP; setFileInfo(GLOBAL_ACCELERATION_OBJECT); myFileAcceleration << header << fileInfo << BREAK_TOP; for(unsigned int j = 0; j < theOutputsList.theBodyList.size(); j++) //iterate through all of the bodies { vector<cx_mat> globalMotSolutionList = theOutputsList.theOutputsBodyList[j].getOutputType(0); vector<cx_mat> globalVelSolutionList = theOutputsList.theOutputsBodyList[j].getOutputType(1); vector<cx_mat> globalAccSolutionList = theOutputsList.theOutputsBodyList[j].getOutputType(2); myFileMotion << BODY << " " << OBJECT_BEGIN2 << "\n " << NAME << " " << "\"" << theOutputsList.theBodyList[j].bodyName << "\"" << END << "\n"; myFileVelocity << BODY << " " << OBJECT_BEGIN2 << "\n " << NAME << " " << "\"" << theOutputsList.theBodyList[j].bodyName << "\"" << END << "\n"; myFileAcceleration << BODY << " " << OBJECT_BEGIN2 << "\n " << NAME << " " << "\"" << theOutputsList.theBodyList[j].bodyName << "\"" << END << "\n"; for(unsigned int k = 0; k < thefrequenciesList.size(); k++) //iterate through all of the frequencies { //Write Global Motion Files ******************************************************************************************* setFileInfo(GLOBAL_MOTION_OBJECT); myFileMotion << " " << DATA << " " << OBJECT_BEGIN2 << "\n" << " " << FREQUENCY << " " << (k+1) << "\n "<< VALUE << " " << LIST_BEGIN2 << "\n"; for(unsigned int a = 0; a < 6; a++) //print the 6 outputs per each frequency { myFileMotion.precision(15); myFileMotion << " " << globalMotSolutionList[k].at(a,0).real(); if(globalMotSolutionList[j].at(a,0).imag() < 0.0) myFileMotion << globalMotSolutionList[j].at(a,0).imag()<< "i\n"; else myFileMotion << "+" << globalMotSolutionList[j].at(a,0).imag()<< "i\n"; } myFileMotion << " " << LIST_END2 << "\n " << OBJECT_END2 << "\n"; //Write Global Velocity Files ***************************************************************************************** setFileInfo(GLOBAL_VELOCITY_OBJECT); myFileVelocity << " " << DATA << " " << OBJECT_BEGIN2 << "\n" << " " << FREQUENCY << " " << (k+1) << "\n "<< VALUE << " " << LIST_BEGIN2 << "\n"; for(unsigned int a = 0; a < 6; a++) //print the 6 outputs per each frequency { myFileVelocity.precision(15); myFileVelocity << " " << globalVelSolutionList[k].at(a,0).real(); if(globalVelSolutionList[j].at(a,0).imag() < 0.0) myFileVelocity << globalVelSolutionList[j].at(a,0).imag()<< "i\n"; else myFileVelocity << "+" << globalVelSolutionList[j].at(a,0).imag()<< "i\n"; } myFileVelocity << " " << LIST_END2 << "\n " << OBJECT_END2 << "\n"; //Write Global Acceleration Files ************************************************************************************* setFileInfo(GLOBAL_ACCELERATION_OBJECT); myFileAcceleration << " " << DATA << " " << OBJECT_BEGIN2 << "\n" << " " << FREQUENCY << " " << (k+1) << "\n "<< VALUE << " " << LIST_BEGIN2 << "\n"; for(unsigned int a = 0; a < 6; a++) //print the 6 outputs per each frequency { myFileAcceleration.precision(15); myFileAcceleration << " " << globalAccSolutionList[k].at(a,0).real(); if(globalAccSolutionList[j].at(a,0).imag() < 0.0) myFileAcceleration << globalAccSolutionList[j].at(a,0).imag()<< "i\n"; else myFileAcceleration << "+" << globalAccSolutionList[j].at(a,0).imag()<< "i\n"; } myFileAcceleration << " " << LIST_END2 << "\n " << OBJECT_END2 << "\n"; } myFileMotion << OBJECT_END2 << "\n"; myFileVelocity << OBJECT_END2 << "\n"; myFileAcceleration << OBJECT_END2 << "\n"; } myFileMotion << BREAK_BOTTOM; myFileVelocity << BREAK_BOTTOM; myFileAcceleration << BREAK_BOTTOM; myFileMotion.close(); myFileVelocity.close(); myFileAcceleration.close(); return true; }