本文整理汇总了C++中DataObjectRef::getFilePath方法的典型用法代码示例。如果您正苦于以下问题:C++ DataObjectRef::getFilePath方法的具体用法?C++ DataObjectRef::getFilePath怎么用?C++ DataObjectRef::getFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataObjectRef
的用法示例。
在下文中一共展示了DataObjectRef::getFilePath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encodeDataObject
DataObjectRef FragmentationEncoderService::encodeDataObject(const DataObjectRef originalDataObject, size_t startIndex,
size_t fragmentSize, NodeRef nodeRef) {
const char* filePathOriginalDataObject = fragmentationDataObjectUtility->getFilePath(originalDataObject).c_str();
string originalFileName = fragmentationDataObjectUtility->getFileName(originalDataObject);
string fragmentFile = this->fragmentationFileUtility->createFragmentFileName(originalFileName.c_str());
HAGGLE_DBG2("Creating fragment file name %s\n", fragmentFile.c_str());
FILE* originaldataObjectFilePointer = fopen(filePathOriginalDataObject, "rb");
if (NULL == originaldataObjectFilePointer) {
HAGGLE_ERR("Unable to open file %s\n", filePathOriginalDataObject);
return NULL;
}
FILE* fragmentFilePointer = fopen(fragmentFile.c_str(), "wb");
if (NULL == fragmentFilePointer) {
HAGGLE_ERR("Error opening fragment file %s\n", fragmentFile.c_str());
fclose(originaldataObjectFilePointer);
return NULL;
}
this->fragmentationEncoderStorage->addDataObject(originalDataObject->getIdStr(), originalDataObject);
fseek(originaldataObjectFilePointer, 0, SEEK_END);
size_t fileSize = ftell(originaldataObjectFilePointer);
size_t dataLen = fragmentationDataObjectUtility->getFileLength(originalDataObject);
size_t totalNumberOfFragments = this->fragmentationDataObjectUtility->calculateTotalNumberOfFragments(dataLen,
fragmentSize);
int* fragmentSequenceNumberList = this->getIndexesOfFragmentsToCreate(totalNumberOfFragments);
string sequenceNumberListCsv = "";
size_t numberOfFragmentsToWrite = this->fragmentationConfiguration->getNumberFragmentsPerDataObject();
if (numberOfFragmentsToWrite > totalNumberOfFragments) {
HAGGLE_DBG2( "numberOfFragmentsToWrite=%d > totalNumberOfFragments=%d\n",
numberOfFragmentsToWrite, totalNumberOfFragments);
numberOfFragmentsToWrite = totalNumberOfFragments;
}
for (int count = 0; count < numberOfFragmentsToWrite && startIndex < totalNumberOfFragments;
count++, startIndex++) {
size_t sequenceNumberToWrite = fragmentSequenceNumberList[startIndex];
HAGGLE_DBG2( "sequenceNumberToWrite=%d startIndex=%d totalNumberOfFragments=%d\n",
sequenceNumberToWrite, startIndex, totalNumberOfFragments);
FragmentationPositionInfo fragmentationPositionInfo =
this->fragmentationDataObjectUtility->calculateFragmentationPositionInfo(sequenceNumberToWrite,
fragmentSize, fileSize);
char intbuffer[33];
memset(intbuffer, 0, sizeof(intbuffer));
sprintf(intbuffer, "%d", sequenceNumberToWrite);
sequenceNumberListCsv = sequenceNumberListCsv + intbuffer + ",";
fseek(originaldataObjectFilePointer, fragmentationPositionInfo.startPosition, SEEK_SET);
char* buffer = new char[fragmentationPositionInfo.actualFragmentSize + 1];
memset(buffer, 0, fragmentationPositionInfo.actualFragmentSize + 1);
size_t bytesRead = fread(buffer, 1, fragmentationPositionInfo.actualFragmentSize,
originaldataObjectFilePointer);
if (ferror(originaldataObjectFilePointer)) {
HAGGLE_ERR("Error reading file %s\n", filePathOriginalDataObject);
delete[] buffer;
delete[] fragmentSequenceNumberList;
fclose(fragmentFilePointer);
fclose(originaldataObjectFilePointer);
return NULL;
}
HAGGLE_DBG2( "bytesRead=%d read for sequenceNumber=%d actualFragmentSize=%d startPosition=%d\n",
bytesRead, sequenceNumberToWrite, fragmentationPositionInfo.actualFragmentSize, fragmentationPositionInfo.startPosition);
/*write to fragment*/
fwrite(buffer, fragmentationPositionInfo.actualFragmentSize, 1, fragmentFilePointer);
if (ferror(fragmentFilePointer)) {
HAGGLE_ERR("Error writing file %s\n", fragmentFile.c_str());
delete[] buffer;
delete[] fragmentSequenceNumberList;
fclose(fragmentFilePointer);
fclose(originaldataObjectFilePointer);
return NULL;
}
HAGGLE_DBG2("wrote fragment file %s - sequenceNumber=%d\n", fragmentFile.c_str(), sequenceNumberToWrite);
delete[] buffer;
}
delete[] fragmentSequenceNumberList;
fclose(fragmentFilePointer);
fclose(originaldataObjectFilePointer);
sequenceNumberListCsv = sequenceNumberListCsv.substr(0, sequenceNumberListCsv.size() - 1);
HAGGLE_DBG2("sequenceNumberListCsv=%s\n", sequenceNumberListCsv.c_str());
DataObjectRef fragmentDataObjectRef = DataObject::create(fragmentFile, fragmentationDataObjectUtility->getFileName(originalDataObject));
if(!fragmentDataObjectRef) {
HAGGLE_ERR("Unable to create data object for file %s (%s)\n", fragmentFile.c_str(), originalDataObject->getFileName().c_str());
return NULL;
}
bool addedAttributes = this->addAttributes(originalDataObject, fragmentDataObjectRef, sequenceNumberListCsv);
//.........这里部分代码省略.........