Пример #1
0
void Skein::Import(const char* path)
{
  Node* node = m_inst.root;
  bool added = false;

  CStdioFile recFile;
  if (recFile.Open(path,CFile::modeRead|CFile::typeText))
  {
    CString recLine;
    while (recFile.ReadString(recLine))
    {
      recLine.Trim();
      if (recLine.GetLength() > 0)
      {
        CStringW recLineW = EscapeLine(CStringW(recLine),UsePrintable);
        Node* newNode = node->Find(recLineW);
        if (newNode == NULL)
        {
          newNode = new Node(recLineW,L"",L"",L"",false);
          node->Add(newNode);
          added = true;
        }
        node = newNode;
      }
    }

    if (added)
    {
      m_layout = false;
      NotifyChange(TreeChanged);
      NotifyEdit(true);
    }
  }
}
Пример #2
0
bool nglZipFS::BuildIndex()
{
  int res;
  unzFile Zip = mpPrivate->mZip;
  unz_global_info global_info;

  if (UNZ_OK != unzGetGlobalInfo(Zip, &global_info))
    return false;

  if (UNZ_OK != unzGoToFirstFile(Zip))
    return false;

  do 
  {
    unz_file_info file_info;
    unz_file_pos file_pos;
    char filename[4096];

    if (UNZ_OK != unzGetCurrentFileInfo(Zip, &file_info, filename, 4096, NULL, 0, NULL, 0))
      return false;

    if (UNZ_OK != unzGetFilePos(Zip, &file_pos))
      return false;

    uint len = strlen(filename);
    bool IsDir = (filename[len-1] == '\\') || (filename[len-1] == '/');
    std::list<nglPath> List;

    nglZipPath::Decompose(filename, List);

    std::list<nglPath>::iterator it;
    std::list<nglPath>::iterator end = List.end();

    Node* pPath = &mRoot;

    int i = List.size();
    for (it = List.begin(); it != end; ++it)
    {
      nglString name = (*it).GetPathName();
      Node* pChild = pPath->Find(name);
      if (!pChild)
      {
        //printf("zipfile: %s\n", name.GetChars());
        pChild = new Node(name, file_info.uncompressed_size, file_pos.pos_in_zip_directory, file_pos.num_of_file, i == 1 && !IsDir);
        pPath->AddChild(pChild);
      }
      pPath = pChild;
      i--;
    }
  }
  while (UNZ_OK == (res = unzGoToNextFile(Zip)));

  if (res == UNZ_END_OF_LIST_OF_FILE)
    return true;
  return false;
}