当前位置: 首页>>代码示例>>C++>>正文


C++ CFileInfo类代码示例

本文整理汇总了C++中CFileInfo的典型用法代码示例。如果您正苦于以下问题:C++ CFileInfo类的具体用法?C++ CFileInfo怎么用?C++ CFileInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CFileInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConvertUnicodeToUTF8

bool CFSFolder::SaveComments()
{
  AString utf;
  {
    UString unicode;
    _comments.SaveToString(unicode);
    ConvertUnicodeToUTF8(unicode, utf);
  }
  if (!utf.IsAscii())
    utf.Insert(0, "\xEF\xBB\xBF" "\r\n");

  FString path = _path + kDescriptionFileName;
  // We must set same attrib. COutFile::CreateAlways can fail, if file has another attrib.
  DWORD attrib = FILE_ATTRIBUTE_NORMAL;
  {
    CFileInfo fi;
    if (fi.Find(path))
      attrib = fi.Attrib;
  }
  NIO::COutFile file;
  if (!file.CreateAlways(path, attrib))
    return false;
  UInt32 processed;
  file.Write(utf, utf.Len(), processed);
  _commentsAreLoaded = false;
  return true;
}
开发者ID:cube-soft,项目名称:7z,代码行数:27,代码来源:FSFolder.cpp

示例2: RemoveFile

void CFileEvent::RemoveFile (LPCTSTR pszPathName)
  {
    CFileInfo *pFileInfo;
    if (!m_mapFileInfo.Lookup (pszPathName, pFileInfo))
      return;
    ASSERT (pFileInfo);
    POSITION pos = m_lstFilePath.GetHeadPosition (), posOld;
    CFilePath *pFilePath;
    while (pos)
      {
        posOld = pos;
        pFilePath = m_lstFilePath.GetNext (pos);
        ASSERT (pFilePath);
        if (!_tcscmp (pFilePath->GetPath (), pFileInfo->GetPath ()))
          {
            if (pFilePath->GetCount () == 1)
              {
                delete pFilePath;
                delete pFileInfo;
                m_lstFilePath.RemoveAt (posOld);
                m_mapFileInfo.RemoveKey (pszPathName);
              }
            else
              pFilePath->Dec ();
            return;
          }
      }
  }
开发者ID:GFFavourite,项目名称:Script.NET,代码行数:28,代码来源:FileEvent.cpp

示例3: CFileInfo

void CFileEvent::AddFile (LPCTSTR pszPathName)
  {
    CFileInfo *pFileInfo;
    if (m_mapFileInfo.Lookup (pszPathName, pFileInfo))
      return;
    pFileInfo = new CFileInfo (pszPathName);
    m_mapFileInfo.SetAt (pszPathName, pFileInfo);
    POSITION pos = m_lstFilePath.GetHeadPosition ();
    CFilePath *pFilePath;
    while (pos)
      {
        pFilePath = m_lstFilePath.GetNext (pos);
        ASSERT (pFilePath);
        if (!_tcscmp (pFilePath->GetPath (), pFileInfo->GetPath ()))
          {
            pFilePath->Inc ();
            return;
          }
      }
    m_lstFilePath.AddTail (new CFilePath (pFileInfo->GetPath ()));
    if (m_bEvent)
      {
        StopWatching ();
        StartWatching ();
      }
  }
开发者ID:GFFavourite,项目名称:Script.NET,代码行数:26,代码来源:FileEvent.cpp

示例4: RINOK

HRESULT CFsFolderStat::Enumerate()
{
  if (Progress)
  {
    RINOK(Progress->SetCompleted(NULL));
  }
  Path.Add_PathSepar();
  const unsigned len = Path.Len();
  CEnumerator enumerator;
  enumerator.SetDirPrefix(Path);
  CFileInfo fi;
  while (enumerator.Next(fi))
  {
    if (fi.IsDir())
    {
      Path.DeleteFrom(len);
      Path += fi.Name;
      RINOK(Enumerate());
      NumFolders++;
    }
    else
    {
      NumFiles++;
      Size += fi.Size;
    }
  }
  return S_OK;
}
开发者ID:cube-soft,项目名称:7z,代码行数:28,代码来源:FSFolder.cpp

示例5: UNUSED

// Return current size of file.
//
// size = getFileSize(filename);
//   filename: VFS filename (may include path)
unsigned int JSI_VFS::GetFileSize(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), std::wstring filename)
{
	CFileInfo fileInfo;
	Status err = g_VFS->GetFileInfo(filename, &fileInfo);
	JS_CHECK_FILE_ERR(err);

	return (unsigned int)fileInfo.Size();
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例6: dc

int CFileBrowserListCtrl::CalcMinColumnWidth(int Col)
{
	enum {
		BORDER = 6,	// minimal spacing; less causes abbreviated text
		SLACK = 3	// prevents widest item from touching right edge
	};
	CWaitCursor	wc;	// iterating all items can be slow, especially for file type
	CClientDC	dc(this);
	HGDIOBJ	PrevFont = dc.SelectObject(GetFont());	// must use list control's font
	int	width = 0;
	CSize	sz;
	CFileInfo	FileInfo;
	CString	str;
	int	items = m_DirList.GetCount();
	for (int i = 0; i < items; i++) {
		const CDirItem&	item = m_DirList.GetItem(i);
		switch (Col) {
		case COL_NAME:
			str = item.GetName();
			break;
		case COL_SIZE:
			if (item.IsDir())
				continue;
			FormatSize(item.GetLength(), str);
			break;
		case COL_TYPE:	// slow if we have many unique file types that aren't cached
			m_FileInfoCache.GetFileInfo(GetFolder(), item, FileInfo);
			str = FileInfo.GetTypeName();
			break;
		case COL_MODIFIED:
			if (item.GetLastWrite() == 0)
				continue;
			FormatTime(item.GetLastWrite(), str);
			break;
		default:
			ASSERT(0);
		}
		GetTextExtentPoint32(dc.m_hDC, str, str.GetLength(), &sz);
		if (sz.cx > width)
			width = sz.cx;
	}
	dc.SelectObject(PrevFont);	// restore DC's previous font
	// 25feb09: GetItemRect can fail e.g. if list is empty, in which case we
	// must avoid adding garbage to column width
	CRect	IconRect;
	if (GetItemRect(0, IconRect, LVIR_ICON))
		width += IconRect.Width();
	else	// can't get item rect, fall back to system metrics
		width += GetSystemMetrics(m_ViewType == VTP_ICON ? SM_CXICON : SM_CXSMICON);
	width += BORDER + SLACK;
	return(width);
}
开发者ID:victimofleisure,项目名称:Fractice,代码行数:52,代码来源:FileBrowserListCtrl.cpp

示例7: PrepareCacheKey

	/**
	 * Creates MD5 hash key from skeletons.xml info and COLLADA converter version,
	 * used to invalidate cached .pmd/psas
	 *
	 * @param[out] hash resulting MD5 hash
	 * @param[out] version version passed to CCacheLoader, used if code change should force
	 *		  cache invalidation
	 */
	void PrepareCacheKey(MD5& hash, u32& version)
	{
		// Add converter version to the hash
		version = COLLADA_CONVERTER_VERSION;

		// Cache the skeleton files hash data
		if (m_skeletonHashInvalidated)
		{
			VfsPaths paths;
			if (vfs::GetPathnames(m_VFS, L"art/skeletons/", L"*.xml", paths) != INFO::OK)
			{
				LOGWARNING("Failed to load skeleton definitions");
				return;
			}

			// Sort the paths to not invalidate the cache if mods are mounted in different order
			// (No need to stable_sort as the VFS gurantees that we have no duplicates)
			std::sort(paths.begin(), paths.end());

			// We need two u64s per file
			m_skeletonHashes.clear();
			m_skeletonHashes.reserve(paths.size()*2);

			CFileInfo fileInfo;
			for (const VfsPath& path : paths)
			{
				// This will cause an assertion failure if *it doesn't exist,
				//	because fileinfo is not a NULL pointer, which is annoying but that
				//	should never happen, unless there really is a problem
				if (m_VFS->GetFileInfo(path, &fileInfo) != INFO::OK)
				{
					LOGERROR("Failed to stat '%s' for DAE caching", path.string8());
				}
				else
				{
					m_skeletonHashes.push_back((u64)fileInfo.MTime() & ~1); //skip lowest bit, since zip and FAT don't preserve it
					m_skeletonHashes.push_back((u64)fileInfo.Size());
				}
			}

			// Check if we were able to load any skeleton files
			if (m_skeletonHashes.empty())
				LOGERROR("Failed to stat any skeleton definitions for DAE caching");
				// We can continue, something else will break if we try loading a skeletal model

			m_skeletonHashInvalidated = false;
		}

		for (const u64& h : m_skeletonHashes)
			hash.Update((const u8*)&h, sizeof(h));
	}
开发者ID:2asoft,项目名称:0ad,代码行数:59,代码来源:ColladaManager.cpp

示例8: _T

void CFileManager::FindAllFile(const wstring& strPath,  vector<CFileInfo>& vecFiles)  
{   
    if(strPath.length() < 1)
        return;

	CString cstrFind = strPath.c_str();
		cstrFind +=  _T("\\*.*");

	WIN32_FIND_DATA wfd;  
	HANDLE hFind = ::FindFirstFile(cstrFind, &wfd);  
	if(hFind==INVALID_HANDLE_VALUE)  
		return ;

	string str;
	TCHAR tcharFile[MAX_PATH]; 
	CFileInfo entry;
	bool ifok = false;	
	const wstring wstrRoot = CConfig::GetInstance().GetRootPath();
    
	do  
	{  
        if(m_fHasNewSearch)
            goto End;
		//如果你所在的不是根目录,你将会看到“.”与“..”这两个目录——这是在资源管理器中看不到的。  
		//dos下一个点代表的是当前目录,两个点代表的是上一级目录。若查找的到的是当前文件夹和上一级文件夹,则忽略。  
		if(wfd.cFileName[0]=='.')  
			continue;  
		if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)  
		{  
			//dir  
			wsprintf(tcharFile,_T("%s\\%s"), strPath.c_str(), wfd.cFileName);  
			FindAllFile(tcharFile, vecFiles);   //recursive call
		}  
		else   
		{  
			//file 
			wsprintf(tcharFile,_T("%s\\%s"), strPath.c_str() , wfd.cFileName); 
			
			entry.Clear();
			entry.m_strFullPathName = tcharFile;
			ifok = entry.ReadAllInfo(wstrRoot);

			vecFiles.push_back(entry);
			//m_vecFileData.push_back("");
             
		}  
	}while(::FindNextFile(hFind,&wfd));  

End:
	::FindClose(hFind);  
}  
开发者ID:yellowbigbird,项目名称:bird-self-lib,代码行数:51,代码来源:FileManager.cpp

示例9: LoadFullPath

void CPanel::LoadFullPathAndShow()
{
  LoadFullPath();
  _appState->FolderHistory.AddString(_currentFolderPrefix);

  _headerComboBox.SetText(_currentFolderPrefix);

  #ifndef UNDER_CE

  COMBOBOXEXITEM item;
  item.mask = 0;

  UString path = _currentFolderPrefix;
  if (path.Len() >
      #ifdef _WIN32
      3
      #else
      1
      #endif
      && path.Back() == WCHAR_PATH_SEPARATOR)
    path.DeleteBack();

  DWORD attrib = FILE_ATTRIBUTE_DIRECTORY;

  // GetRealIconIndex is slow for direct DVD/UDF path. So we use dummy path
  if (path.IsPrefixedBy(L"\\\\.\\"))
    path = L"_TestFolder_";
  else
  {
    CFileInfo fi;
    if (fi.Find(us2fs(path)))
      attrib = fi.Attrib;
  }
  item.iImage = GetRealIconIndex(us2fs(path), attrib);

  if (item.iImage >= 0)
  {
    item.iSelectedImage = item.iImage;
    item.mask |= (CBEIF_IMAGE | CBEIF_SELECTEDIMAGE);
  }
  item.iItem = -1;
  _headerComboBox.SetItem(&item);
  
  #endif

  RefreshTitle();
}
开发者ID:670232921,项目名称:pfm_archive,代码行数:47,代码来源:PanelFolderChange.cpp

示例10: Next

bool CEnumerator::Next(CFileInfo &fi)
{
  for (;;)
  {
    if (!NextAny(fi))
      return false;
    if (!fi.IsDots())
      return true;
  }
}
开发者ID:ming-hai,项目名称:soui,代码行数:10,代码来源:FileFind.cpp

示例11: Next

			bool CEnumerator::Next(CFileInfo &fileInfo)
			{
				while(true)
				{
					if(!NextAny(fileInfo))
      return false;
					if(!fileInfo.IsDots())
      return true;
				}
			}
开发者ID:RobinChao,项目名称:LzmaSDKObjC,代码行数:10,代码来源:FileFind.cpp

示例12: BOOST_LOG_FUNCTION

int CDirectoryInfo::_SortAllFileInPathByTime(LstFileSystemItemsInPathT& lstFileSystemItemsInPath, MapTimeFileSystemItemT& mapTimeFileSystemItem)
{
	BOOST_LOG_FUNCTION();
	int nFunRes = 0;
	LstFileSystemItemsInPathIterT   iterLst;
	CFileInfo* pFileSystemItem = NULL;
	time_t nFileNameTImeValue = 0;

	iterLst = lstFileSystemItemsInPath.begin();
	while (iterLst != lstFileSystemItemsInPath.end())
	{
		pFileSystemItem = (*iterLst);
		nFileNameTImeValue = pFileSystemItem->getFileNameTime();

		mapTimeFileSystemItem.insert(MapTimeFileSystemItemValueTypeT(nFileNameTImeValue, pFileSystemItem));//auto sort

		iterLst++;
	}//while
	lstFileSystemItemsInPath.clear();

	return nFunRes;
}
开发者ID:lslProjectOrg,项目名称:Projects,代码行数:22,代码来源:DirectoryInfo.cpp

示例13: LooseCachePath

VfsPath CCacheLoader::LooseCachePath(const VfsPath& sourcePath, const MD5& initialHash, u32 version)
{
	CFileInfo fileInfo;
	if (m_VFS->GetFileInfo(sourcePath, &fileInfo) < 0)
	{
		debug_warn(L"source file disappeared"); // this should never happen
		return VfsPath();
	}

	u64 mtime = (u64)fileInfo.MTime() & ~1; // skip lowest bit, since zip and FAT don't preserve it
	u64 size = (u64)fileInfo.Size();

	// Construct a hash of the file data and settings.

	MD5 hash = initialHash;
	hash.Update((const u8*)&mtime, sizeof(mtime));
	hash.Update((const u8*)&size, sizeof(size));
	hash.Update((const u8*)&version, sizeof(version));
	// these are local cached files, so we don't care about endianness etc

	// Use a short prefix of the full hash (we don't need high collision-resistance),
	// converted to hex
	u8 digest[MD5::DIGESTSIZE];
	hash.Final(digest);
	std::wstringstream digestPrefix;
	digestPrefix << std::hex;
	for (size_t i = 0; i < 8; ++i)
		digestPrefix << std::setfill(L'0') << std::setw(2) << (int)digest[i];

	// Get the mod path
	OsPath path;
	m_VFS->GetRealPath(sourcePath, path);

	// Construct the final path
	return VfsPath("cache") / path_name_only(path.BeforeCommon(sourcePath).Parent().string().c_str()) / sourcePath.ChangeExtension(sourcePath.Extension().string() + L"." + digestPrefix.str() + m_FileExtension);
}
开发者ID:Valvador,项目名称:PyroSpaceFork,代码行数:36,代码来源:CacheLoader.cpp

示例14: UpdateFile

static HRESULT UpdateFile(NFsFolder::CCopyStateIO &state, CFSTR inPath, CFSTR outPath, IFolderArchiveUpdateCallback *callback)
{
  if (NFind::DoesFileOrDirExist(outPath))
  {
    RINOK(SendMessageError(callback, NError::MyFormatMessage(ERROR_ALREADY_EXISTS), outPath));
    CFileInfo fi;
    if (fi.Find(inPath))
    {
      if (state.TotalSize >= fi.Size)
        state.TotalSize -= fi.Size;
    }
    return S_OK;
  }

  {
    if (callback)
      RINOK(callback->CompressOperation(fs2us(inPath)));
    RINOK(state.MyCopyFile(inPath, outPath));
    if (state.ErrorFileIndex >= 0)
    {
      if (state.ErrorMessage.IsEmpty())
        state.ErrorMessage = GetLastErrorMessage();
      FString errorName;
      if (state.ErrorFileIndex == 0)
        errorName = inPath;
      else
        errorName = outPath;
      if (callback)
        RINOK(SendMessageError(callback, state.ErrorMessage, errorName));
    }
    if (callback)
      RINOK(callback->OperationResult(0));
  }

  return S_OK;
}
开发者ID:SaketaChalamchala,项目名称:DisassemblyAccuracy,代码行数:36,代码来源:AltStreamsFolder.cpp

示例15: ForEachFile

Status ForEachFile(const PIVFS& fs, const VfsPath& startPath, FileCallback cb, uintptr_t cbData, const wchar_t* pattern, size_t flags)
{
	// (declare here to avoid reallocations)
	CFileInfos files;
	DirectoryNames subdirectoryNames;

	// (a FIFO queue is more efficient than recursion because it uses less
	// stack space and avoids seeks due to breadth-first traversal.)
	std::queue<VfsPath> pendingDirectories;
	pendingDirectories.push(startPath/"");
	while(!pendingDirectories.empty())
	{
		const VfsPath& path = pendingDirectories.front();

		RETURN_STATUS_IF_ERR(fs->GetDirectoryEntries(path, &files, &subdirectoryNames));

		for(size_t i = 0; i < files.size(); i++)
		{
			const CFileInfo fileInfo = files[i];
			if(!match_wildcard(fileInfo.Name().string().c_str(), pattern))
				continue;

			const VfsPath pathname(path / fileInfo.Name());	// (CFileInfo only stores the name)
			RETURN_STATUS_IF_ERR(cb(pathname, fileInfo, cbData));
		}

		if(!(flags & DIR_RECURSIVE))
			break;

		for(size_t i = 0; i < subdirectoryNames.size(); i++)
			pendingDirectories.push(path / subdirectoryNames[i]/"");
		pendingDirectories.pop();
	}

	return INFO::OK;
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:36,代码来源:vfs_util.cpp


注:本文中的CFileInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。