コード例 #1
0
ファイル: vmerge.cpp プロジェクト: AltimorTASDK/TribesRebirth
int
main(int argc, char* argv[])
{
   if (argc != 3) {
      usage();
      return EXIT_FAILURE;
   }

   VolumeRStream  inputVol;
   VolumeRWStream outputVol;

   bool test = inputVol.openVolume(argv[2]);
   AssertISV(test != false, avar("Could not open input volume: %s", argv[2]));
   
   test = outputVol.openVolume(argv[1]);
   AssertISV(test != false, avar("Could not open output volume: %s", argv[1]));

   FindMatch fileMatches("*", 1024);
   inputVol.findMatches(&fileMatches);
   AssertWarn(fileMatches.isFull() == false,
              "Exceeded max merge size (1024) files have been left out");

   for (int i = 0; i < fileMatches.numMatches(); i++) {
      const char* pFileName = fileMatches.matchList[i];
      
      // Open the stream from the input volume
      //
      bool testOpen = inputVol.open(pFileName);
      AssertFatal(testOpen == true, "Something is horribly wrong...");
      
      outputVol.open(pFileName, STRM_COMPRESS_NONE, inputVol.getSize());
      
      copyStreams(outputVol, inputVol);
      outputVol.close();
      inputVol.close();
   }

   outputVol.closeVolume();
   inputVol.closeVolume();

   return EXIT_SUCCESS;
}
コード例 #2
0
/**
  Check whether filter matches a file path - regardless whether the file already exists or not.

  @param filePath: absolute file path
  */
bool FileFilterBaseItem::matchesFile(const QString &filePath) const
{
    foreach (const QString &explicitFile, m_explicitFiles) {
        if (absolutePath(explicitFile) == filePath)
            return true;
    }

    const QString &fileName = QFileInfo(filePath).fileName();

    if (!fileMatches(fileName))
        return false;

    const QDir fileDir = QFileInfo(filePath).absoluteDir();
    foreach (const QString &watchedDirectory, m_dirWatcher.directories()) {
        if (QDir(watchedDirectory) == fileDir)
            return true;
    }

    return false;
}
コード例 #3
0
bool DirectoryIterator::next (bool* const isDirResult, bool* const isHiddenResult, int64* const fileSize,
                              Time* const modTime, Time* const creationTime, bool* const isReadOnly)
{
    for (;;)
    {
        hasBeenAdvanced = true;

        if (subIterator != nullptr)
        {
            if (subIterator->next (isDirResult, isHiddenResult, fileSize, modTime, creationTime, isReadOnly))
                return true;

            subIterator = nullptr;
        }

        String filename;
        bool isDirectory, isHidden = false, shouldContinue = false;

        while (fileFinder.next (filename, &isDirectory,
                                (isHiddenResult != nullptr || (whatToLookFor & File::ignoreHiddenFiles) != 0) ? &isHidden : nullptr,
                                fileSize, modTime, creationTime, isReadOnly))
        {
            ++index;

            if (! filename.containsOnly ("."))
            {
                bool matches = false;

                if (isDirectory)
                {
                    if (isRecursive && ((whatToLookFor & File::ignoreHiddenFiles) == 0 || ! isHidden))
                        subIterator = new DirectoryIterator (File::createFileWithoutCheckingPath (path + filename),
                                                             true, wildCard, whatToLookFor);

                    matches = (whatToLookFor & File::findDirectories) != 0;
                }
                else
                {
                    matches = (whatToLookFor & File::findFiles) != 0;
                }

                // if we're not relying on the OS iterator to do the wildcard match, do it now..
                if (matches && (isRecursive || wildCards.size() > 1))
                    matches = fileMatches (wildCards, filename);

                if (matches && (whatToLookFor & File::ignoreHiddenFiles) != 0)
                    matches = ! isHidden;

                if (matches)
                {
                    currentFile = File::createFileWithoutCheckingPath (path + filename);
                    if (isHiddenResult != nullptr)     *isHiddenResult = isHidden;
                    if (isDirResult != nullptr)        *isDirResult = isDirectory;

                    return true;
                }

                if (subIterator != nullptr)
                {
                    shouldContinue = true;
                    break;
                }
            }
        }

        if (! shouldContinue)
            return false;
    }
}