Esempio n. 1
0
bool CLangPage::OnInit()
{
  LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));

  _langCombo.Attach(GetItem(IDC_LANG_LANG));

  UString temp = MyLoadString(IDS_LANG_ENGLISH);
  NativeLangString(temp, MyLoadString(IDS_LANG_NATIVE));
  int index = (int)_langCombo.AddString(temp);
  _langCombo.SetItemData(index, _paths.Size());
  _paths.Add(L"-");
  _langCombo.SetCurSel(0);

  const FString dirPrefix = GetLangDirPrefix();
  NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt"));
  NFile::NFind::CFileInfo fi;
  CLang lang;
  UString error;
  
  while (enumerator.Next(fi))
  {
    if (fi.IsDir())
      continue;
    const int kExtSize = 4;
    if (fi.Name.Len() < kExtSize)
      continue;
    unsigned pos = fi.Name.Len() - kExtSize;
    if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt"))
      continue;

    if (!LangOpen(lang, dirPrefix + fi.Name))
    {
      if (!error.IsEmpty())
        error += L' ';
      error += fs2us(fi.Name);
      continue;
    }
    
    const UString shortName = fs2us(fi.Name.Left(pos));
    UString s = shortName;
    const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH);
    if (eng)
      s = eng;
    const wchar_t *native = lang.Get(IDS_LANG_NATIVE);
    if (native)
      NativeLangString(s, native);
    index = (int)_langCombo.AddString(s);
    _langCombo.SetItemData(index, _paths.Size());
    _paths.Add(shortName);
    if (g_LangID.IsEqualToNoCase(shortName))
      _langCombo.SetCurSel(index);
  }
  
  if (!error.IsEmpty())
    MessageBoxW(0, error, L"Error in Lang file", MB_OK | MB_ICONSTOP);
  return CPropertyPage::OnInit();
}
Esempio n. 2
0
HRESULT CCodecs::LoadDllsFromFolder(const CSysString &folderPrefix)
{
  NFile::NFind::CEnumerator enumerator(folderPrefix + CSysString(TEXT("*")));
  NFile::NFind::CFileInfo fi;
  while (enumerator.Next(fi))
  {
    if (fi.IsDir())
      continue;
    RINOK(LoadDll(folderPrefix + fi.Name, true));
  }
  return S_OK;
}
Esempio n. 3
0
// If there is Reprase data already, it still writes new Reparse data
bool SetReparseData(CFSTR path, bool isDir, const void *data, DWORD size)
{
  NFile::NFind::CFileInfo fi;
  if (fi.Find(path))
  {
    if (fi.IsDir() != isDir)
    {
      ::SetLastError(ERROR_DIRECTORY);
      return false;
    }
  }
  else
  {
    if (isDir)
    {
      if (!NDir::CreateComplexDir(path))
        return false;
    }
    else
    {
      CreatePrefixDirOfFile(path);
      COutFile file;
      if (!file.Create(path, CREATE_NEW))
        return false;
    }
  }

  COutFile file;
  if (!file.Open(path,
      FILE_SHARE_WRITE,
      OPEN_EXISTING,
      FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS))
    return false;

  DWORD returnedSize;
  if (!file.DeviceIoControl(my_FSCTL_SET_REPARSE_POINT, (void *)data, size, NULL, 0, &returnedSize))
    return false;
  return true;
}