本文整理汇总了C++中FileInfo类的典型用法代码示例。如果您正苦于以下问题:C++ FileInfo类的具体用法?C++ FileInfo怎么用?C++ FileInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PassesAttributesFilter
bool FileInfosFilter::PassesAttributesFilter(const FileInfo& fi) const {
if (query_->ExcludeHiddenAndSystem && fi.IsHiddenOrSystem()) {
return false;
}
if (query_->ExcludeFolders && fi.IsDirectory()) {
return false;
}
if (query_->ExcludeFiles && !fi.IsDirectory()) {
return false;
}
return true;
}
示例2: copyCurrentUrlToClipboard
void MainWindow::copyCurrentUrlToClipboard()
{
FileInfo * currentItem = _selectionModel->currentItem();
if ( currentItem )
{
QClipboard * clipboard = QApplication::clipboard();
QString url = currentItem->url();
clipboard->setText( url );
showProgress( tr( "Copied to system clipboard: %1" ).arg( url ) );
}
else
{
showProgress( tr( "No current item" ) );
}
}
示例3: strdup
void
Scanner::_ChangeToDesired()
{
if (fBusy || fDesiredPath.size() <= 0)
return;
char* workPath = strdup(fDesiredPath.c_str());
char* pathPtr = &workPath[1]; // skip leading '/'
char* endOfPath = pathPtr + strlen(pathPtr);
// Check the name of the root directory. It is a special case because
// it has no parent data structure.
FileInfo* checkDir = fSnapshot->rootDir;
FileInfo* prefDir = NULL;
char* sep = strchr(pathPtr, '/');
if (sep != NULL)
*sep = '\0';
if (strcmp(pathPtr, checkDir->ref.name) == 0) {
// Root directory matches, so follow the remainder of the path as
// far as possible.
prefDir = checkDir;
pathPtr += 1 + strlen(pathPtr);
while (pathPtr < endOfPath) {
sep = strchr(pathPtr, '/');
if (sep != NULL)
*sep = '\0';
checkDir = prefDir->FindChild(pathPtr);
if (checkDir == NULL || checkDir->children.size() == 0)
break;
pathPtr += 1 + strlen(pathPtr);
prefDir = checkDir;
}
}
// If the desired path is the volume's root directory, default to the
// volume display.
if (prefDir == fSnapshot->rootDir)
prefDir = NULL;
ChangeDir(prefDir);
free(workPath);
fDesiredPath.erase();
}
示例4: AnswerFile
void ServerContext::AnswerFile(RestApiOutput& output,
const std::string& instancePublicId,
FileContentType content)
{
FileInfo attachment;
if (!index_.LookupAttachment(attachment, instancePublicId, content))
{
throw OrthancException(ErrorCode_InternalError);
}
accessor_.SetCompressionForNextOperations(attachment.GetCompressionType());
std::auto_ptr<HttpFileSender> sender(accessor_.ConstructHttpFileSender(attachment.GetUuid()));
sender->SetContentType("application/dicom");
sender->SetDownloadFilename(instancePublicId + ".dcm");
output.AnswerFile(*sender);
}
示例5: directory_create
bool FileContainerTemporary::directory_create(const std::string &dirname)
{
if (!is_opened()) return false;
if (is_file(dirname)) return false;
if (is_directory(dirname)) return true;
if (!container_->directory_check_name(dirname)) return false;
FileInfo info;
info.name = fix_slashes(dirname);
info.split_name();
info.is_directory = true;
if (info.name_part_localname.empty()
|| !is_directory(info.name_part_directory)) return false;
files_[info.name] = info;
return true;
}
示例6: main
//===----------------------------------------------------------------------===//
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "llvm coverage tool\n");
GCOVFile GF;
if (InputGCNO.empty())
errs() << " " << argv[0] << ": No gcov input file!\n";
OwningPtr<MemoryBuffer> GCNO_Buff;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
errs() << InputGCNO << ": " << ec.message() << "\n";
return 1;
}
GCOVBuffer GCNO_GB(GCNO_Buff.take());
if (!GF.read(GCNO_GB)) {
errs() << "Invalid .gcno File!\n";
return 1;
}
if (!InputGCDA.empty()) {
OwningPtr<MemoryBuffer> GCDA_Buff;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
errs() << InputGCDA << ": " << ec.message() << "\n";
return 1;
}
GCOVBuffer GCDA_GB(GCDA_Buff.take());
if (!GF.read(GCDA_GB)) {
errs() << "Invalid .gcda File!\n";
return 1;
}
}
if (DumpGCOV)
GF.dump();
FileInfo FI;
GF.collectLineCounts(FI);
FI.print(InputGCNO, InputGCDA);
return 0;
}
示例7: CalcHashes
void NZBFile::CalcHashes()
{
TempFileList fileList;
for (FileList::iterator it = m_pNZBInfo->GetFileList()->begin(); it != m_pNZBInfo->GetFileList()->end(); it++)
{
fileList.push_back(*it);
}
fileList.sort(CompareFileInfo);
unsigned int iFullContentHash = 0;
unsigned int iFilteredContentHash = 0;
int iUseForFilteredCount = 0;
for (TempFileList::iterator it = fileList.begin(); it != fileList.end(); it++)
{
FileInfo* pFileInfo = *it;
// check file extension
bool bSkip = !pFileInfo->GetParFile() &&
Util::MatchFileExt(pFileInfo->GetFilename(), g_pOptions->GetExtCleanupDisk(), ",;");
for (FileInfo::Articles::iterator it = pFileInfo->GetArticles()->begin(); it != pFileInfo->GetArticles()->end(); it++)
{
ArticleInfo* pArticle = *it;
int iLen = strlen(pArticle->GetMessageID());
iFullContentHash = Util::HashBJ96(pArticle->GetMessageID(), iLen, iFullContentHash);
if (!bSkip)
{
iFilteredContentHash = Util::HashBJ96(pArticle->GetMessageID(), iLen, iFilteredContentHash);
iUseForFilteredCount++;
}
}
}
// if filtered hash is based on less than a half of files - do not use filtered hash at all
if (iUseForFilteredCount < (int)fileList.size() / 2)
{
iFilteredContentHash = 0;
}
m_pNZBInfo->SetFullContentHash(iFullContentHash);
m_pNZBInfo->SetFilteredContentHash(iFilteredContentHash);
}
示例8: WriteToDisk
FileHandle::~FileHandle()
{
WriteToDisk();
FileInfo* fp = first_file_;
while (fp != NULL)
{
FileInfo* fpn = fp->GetNext();
BlockInfo* bp = fp->GetFirstBlock();
while (bp != NULL)
{
BlockInfo* bpn = bp->GetNext();
delete bp;
bp = bpn;
}
delete fp;
fp = fpn;
}
}
示例9: LOG
void ServerContext::ChangeAttachmentCompression(const std::string& resourceId,
FileContentType attachmentType,
CompressionType compression)
{
LOG(INFO) << "Changing compression type for attachment "
<< EnumerationToString(attachmentType)
<< " of resource " << resourceId << " to "
<< compression;
FileInfo attachment;
if (!index_.LookupAttachment(attachment, resourceId, attachmentType))
{
throw OrthancException(ErrorCode_UnknownResource);
}
if (attachment.GetCompressionType() == compression)
{
// Nothing to do
return;
}
std::string content;
StorageAccessor accessor(area_);
accessor.Read(content, attachment);
FileInfo modified = accessor.Write(content.empty() ? NULL : content.c_str(),
content.size(), attachmentType, compression, storeMD5_);
try
{
StoreStatus status = index_.AddAttachment(modified, resourceId);
if (status != StoreStatus_Success)
{
accessor.Remove(modified);
throw OrthancException(ErrorCode_Database);
}
}
catch (OrthancException&)
{
accessor.Remove(modified);
throw;
}
}
示例10: ReorderFiles
void QueueEditor::ReorderFiles(DownloadQueue* pDownloadQueue, ItemList* pItemList)
{
if (pItemList->size() == 0)
{
return;
}
EditItem* pFirstItem = pItemList->front();
NZBInfo* pNZBInfo = pFirstItem->m_pFileInfo->GetNZBInfo();
unsigned int iInsertPos = 0;
// find first file of the group
for (FileQueue::iterator it = pDownloadQueue->GetFileQueue()->begin(); it != pDownloadQueue->GetFileQueue()->end(); it++)
{
FileInfo* pFileInfo = *it;
if (pFileInfo->GetNZBInfo() == pNZBInfo)
{
break;
}
iInsertPos++;
}
// now can reorder
for (ItemList::iterator it = pItemList->begin(); it != pItemList->end(); it++)
{
EditItem* pItem = *it;
FileInfo* pFileInfo = pItem->m_pFileInfo;
// move file item
for (FileQueue::iterator it = pDownloadQueue->GetFileQueue()->begin(); it != pDownloadQueue->GetFileQueue()->end(); it++)
{
FileInfo* pFileInfo1 = *it;
if (pFileInfo1 == pFileInfo)
{
pDownloadQueue->GetFileQueue()->erase(it);
pDownloadQueue->GetFileQueue()->insert(pDownloadQueue->GetFileQueue()->begin() + iInsertPos, pFileInfo);
iInsertPos++;
break;
}
}
delete pItem;
}
}
示例11: collectLineCounts
/// collectLineCounts - Collect line counts. This must be used after
/// reading .gcno and .gcda files.
void GCOVFunction::collectLineCounts(FileInfo &FI) {
// If the line number is zero, this is a function that doesn't actually appear
// in the source file, so there isn't anything we can do with it.
if (LineNumber == 0)
return;
for (const auto &Block : Blocks)
Block->collectLineCounts(FI);
FI.addFunctionLine(Filename, LineNumber, this);
}
示例12: treeLevel
int FileInfo::treeLevel() const
{
int level = 0;
FileInfo * parent = _parent;
while ( parent )
{
level++;
parent = parent->parent();
}
return level;
if ( _parent )
return _parent->treeLevel() + 1;
else
return 0;
}
示例13: strncpy
/**
* Check if deletion of already downloaded files is possible (when nzb id deleted from queue).
* The deletion is most always possible, except the case if all remaining files in queue
* (belonging to this nzb-file) are PARS.
*/
bool QueueEditor::CanCleanupDisk(DownloadQueue* pDownloadQueue, NZBInfo* pNZBInfo)
{
for (FileQueue::iterator it = pDownloadQueue->GetFileQueue()->begin(); it != pDownloadQueue->GetFileQueue()->end(); it++)
{
FileInfo* pFileInfo = *it;
char szLoFileName[1024];
strncpy(szLoFileName, pFileInfo->GetFilename(), 1024);
szLoFileName[1024-1] = '\0';
for (char* p = szLoFileName; *p; p++) *p = tolower(*p); // convert string to lowercase
if (!strstr(szLoFileName, ".par2"))
{
// non-par file found
return true;
}
}
return false;
}
示例14: max
void FileInfoListView::addRange(FileInfo **filesInfo, size_t count)
{
int index = max(0, (getCount() - 1));
size_t i = 0;
FileInfo *arr = *filesInfo;
for (i = 0; i < count; i++) {
FileInfo *fi = &arr[i];
if (fi->isDirectory()) {
addItem(index++, fi);
}
}
for (i = 0; i < count; i++) {
FileInfo *fi = &arr[i];
if (!fi->isDirectory()) {
addItem(index++, fi);
}
}
}
示例15: finalizeRecursive
void CacheReader::finalizeRecursive( DirInfo * dir )
{
if ( dir->readState() != DirOnRequestOnly )
{
dir->setReadState( DirCached );
_tree->sendFinalizeLocal( dir );
dir->finalizeLocal();
_tree->sendReadJobFinished( dir );
}
FileInfo * child = dir->firstChild();
while ( child )
{
if ( child->isDirInfo() )
finalizeRecursive( child->toDirInfo() );
child = child->next();
}
}