Пример #1
0
 bool FileHandler::GenerateMoveCommands(std::string path, std::list<std::string>& moveCmds)
 {
     
     DIR *dir;
     struct dirent *entry;
     
     if (!(dir = opendir(path.data())))
         return false;
     
     if (!(entry = readdir(dir)))
         return false;
     do
     {
         std::string filename = path + "/" + entry->d_name;
         if (entry->d_type == DT_DIR)
         {
             
             if (filename[filename.size()-1] == '.')
             {
                 continue;
             }
             
             auto newFilename = TransformString(filename);
             
             if (newFilename != filename)
             {
                 std::string moveCmd;
                 moveCmd+="mv \"";
                 moveCmd+= filename;
                 moveCmd+= "\" ";
                 moveCmd+= newFilename;
                 moveCmds.push_back(moveCmd);
             }
             GenerateMoveCommands(filename, moveCmds);
         }
         else
         {
             std::string filename = path + "/" + entry->d_name;
             auto newFilename = TransformString(filename);
             if (newFilename != filename)
             {
                 std::string moveCmd;
                 moveCmd+="mv \"";
                 moveCmd+= filename;
                 moveCmd+= "\" ";
                 moveCmd+= newFilename;
                 moveCmds.push_back(moveCmd);
             }
             
         }
     }
     while ((entry = readdir(dir)));
     
     closedir(dir);
     
     return true;
     
 }
void
nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
    gfxContext* aRefContext)
{
  nsAutoString convertedString;
  nsAutoTArray<bool,50> charsToMergeArray;
  nsAutoTArray<bool,50> deletedCharsArray;
  nsAutoTArray<uint8_t,50> canBreakBeforeArray;
  nsAutoTArray<nsStyleContext*,50> styleArray;

  bool mergeNeeded = TransformString(aTextRun->mString,
                                     convertedString,
                                     mAllUppercase,
                                     nullptr,
                                     charsToMergeArray,
                                     deletedCharsArray,
                                     aTextRun,
                                     &canBreakBeforeArray,
                                     &styleArray);

  uint32_t flags;
  gfxTextRunFactory::Parameters innerParams =
      GetParametersForInner(aTextRun, &flags, aRefContext);
  gfxFontGroup* fontGroup = aTextRun->GetFontGroup();

  nsAutoPtr<nsTransformedTextRun> transformedChild;
  nsAutoPtr<gfxTextRun> cachedChild;
  gfxTextRun* child;

  if (mInnerTransformingTextRunFactory) {
    transformedChild = mInnerTransformingTextRunFactory->MakeTextRun(
        convertedString.BeginReading(), convertedString.Length(),
        &innerParams, fontGroup, flags, styleArray.Elements(), false);
    child = transformedChild.get();
  } else {
    cachedChild = fontGroup->MakeTextRun(
        convertedString.BeginReading(), convertedString.Length(),
        &innerParams, flags);
    child = cachedChild.get();
  }
  if (!child)
    return;
  // Copy potential linebreaks into child so they're preserved
  // (and also child will be shaped appropriately)
  NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
               "Dropped characters or break-before values somewhere!");
  child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
      canBreakBeforeArray.Elements(), aRefContext);
  if (transformedChild) {
    transformedChild->FinishSettingProperties(aRefContext);
  }

  if (mergeNeeded) {
    // Now merge multiple characters into one multi-glyph character as required
    // and deal with skipping deleted accent chars
    NS_ASSERTION(charsToMergeArray.Length() == child->GetLength(),
                 "source length mismatch");
    NS_ASSERTION(deletedCharsArray.Length() == aTextRun->GetLength(),
                 "destination length mismatch");
    MergeCharactersInTextRun(aTextRun, child, charsToMergeArray.Elements(),
                             deletedCharsArray.Elements());
  } else {
    // No merging to do, so just copy; this produces a more optimized textrun.
    // We can't steal the data because the child may be cached and stealing
    // the data would break the cache.
    aTextRun->ResetGlyphRuns();
    aTextRun->CopyGlyphDataFrom(child, 0, child->GetLength(), 0);
  }
}