chromium/third_party/unrar/src/find.cpp

#include "rar.hpp"

FindFile::FindFile()
{}


FindFile::~FindFile()
{}


void FindFile::SetMask(const std::wstring &Mask)
{}


bool FindFile::Next(FindData *fd,bool GetSymLink)
{}


bool FindFile::FastFind(const std::wstring &FindMask,FindData *fd,bool GetSymLink)
{}


#ifdef _WIN_ALL
HANDLE FindFile::Win32Find(HANDLE hFind,const std::wstring &Mask,FindData *fd)
{
  WIN32_FIND_DATA FindData;
  if (hFind==INVALID_HANDLE_VALUE)
  {
    hFind=FindFirstFile(Mask.c_str(),&FindData);
    if (hFind==INVALID_HANDLE_VALUE)
    {
      std::wstring LongMask;
      if (GetWinLongPath(Mask,LongMask))
        hFind=FindFirstFile(LongMask.c_str(),&FindData);
    }
    if (hFind==INVALID_HANDLE_VALUE)
    {
      int SysErr=GetLastError();
      // We must not issue an error for "file not found" and "path not found",
      // because it is normal to not find anything for wildcard mask when
      // archiving. Also searching for non-existent file is normal in some
      // other modules, like WinRAR scanning for winrar_theme_description.txt
      // to check if any themes are available.
      fd->Error=SysErr!=ERROR_FILE_NOT_FOUND && 
                SysErr!=ERROR_PATH_NOT_FOUND &&
                SysErr!=ERROR_NO_MORE_FILES;
    }
  }
  else
    if (!FindNextFile(hFind,&FindData))
    {
      hFind=INVALID_HANDLE_VALUE;
      fd->Error=GetLastError()!=ERROR_NO_MORE_FILES;
    }

  if (hFind!=INVALID_HANDLE_VALUE)
  {
    fd->Name=Mask;
    SetName(fd->Name,FindData.cFileName);
    fd->Size=INT32TO64(FindData.nFileSizeHigh,FindData.nFileSizeLow);
    fd->FileAttr=FindData.dwFileAttributes;
    fd->ftCreationTime=FindData.ftCreationTime;
    fd->ftLastAccessTime=FindData.ftLastAccessTime;
    fd->ftLastWriteTime=FindData.ftLastWriteTime;
    fd->mtime.SetWinFT(&FindData.ftLastWriteTime);
    fd->ctime.SetWinFT(&FindData.ftCreationTime);
    fd->atime.SetWinFT(&FindData.ftLastAccessTime);


  }
  fd->Flags=0;
  return hFind;
}
#endif