Esempio n. 1
0
void build(DataArchive& a, const char* sBasePath)
{
    char  sPath[256];
    char  sFind[256];

    if (sBasePath && *sBasePath) {
        strcpy(sPath, sBasePath);
        sprintf(sFind, "%s\\*.*", sPath);
    } else {
        sPath[0] = 0;
        strcpy(sFind, "*.*");
    }

    WIN32_FIND_DATA   find;
    std::wstring sTemp;
    std::string sStd = sFind;
    sTemp = ToWideString(sStd);
    HANDLE h = FindFirstFile(sTemp.c_str(), &find);
    if (h != INVALID_HANDLE_VALUE) {
        do buildFile(a, sPath, find);
        while (FindNextFile(h, &find));

    FindClose(h);
    }
}
Esempio n. 2
0
void DataArchive::Extract(const char* name)
{
   int index = FindEntry(name);

   if (index < 0) {
      printf("Could not extract '%s', not found\n", name);
      return;
   }

   BYTE* buf;
   ExpandEntry(index, buf);
   
   std::string dirname = directory[index].name;
   bool create_subdir = (dirname.find_first_of('/', 0) != std::string::npos);
   std::wstring wdirname = ToWideString(dirname.substr(0, dirname.find_first_of('/')));
   if (create_subdir)
      CreateDirectory(wdirname.c_str(), NULL);
   size_t offset = wdirname.length();
   while (dirname.find_first_of('/', offset + 1) != std::string::npos) {
       wdirname.push_back('/');
       wdirname += ToWideString(dirname.substr(offset + 1, dirname.find_first_of('/', offset + 1) - offset - 1));
       CreateDirectory(wdirname.c_str(), NULL);
       offset = wdirname.length();
   }

   FILE* f = fopen(directory[index].name, "w+b");
   if (f) {
      fwrite(buf, directory[index].size_orig, 1, f);
      fclose(f);
   }
   else
      printf("Could not extract '%s', could not open file for writing\n", name);

   delete [] buf;

   if (verbose) printf("   Extracted: %s\n", name);
}
Esempio n. 3
0
std::vector<WideString> CFX_V8::GetObjectPropertyNames(
    v8::Local<v8::Object> pObj) {
  if (pObj.IsEmpty())
    return std::vector<WideString>();

  v8::Local<v8::Array> val;
  v8::Local<v8::Context> context = m_pIsolate->GetCurrentContext();
  if (!pObj->GetPropertyNames(context).ToLocal(&val))
    return std::vector<WideString>();

  std::vector<WideString> result;
  for (uint32_t i = 0; i < val->Length(); ++i) {
    result.push_back(ToWideString(val->Get(context, i).ToLocalChecked()));
  }

  return result;
}
Esempio n. 4
0
	std::wstring ToWideString(ScanInfo const& info) 
	{
		static std::wstring const messageFormat(
			L"****************Info for handle:[%1%]****************\n"
			L"\tPath:[%2%]\n"
			L"\tAdditional info: %3%exists\n"
			L"%4%\n\n"
			);

		std::wstring result =
			boost::str(boost::wformat(messageFormat)
			% info.handle
			% Details::Handle2Path(info.handle)
			% (info.data ? L"" : L"not ")
			% (info.data ? ToWideString(info.data.get()) : L"")
			);

		return result;
	}
Esempio n. 5
0
 std::wstring ToWideString(const std::string& str) {
   return ToWideString(str.c_str(), -1);
 }
Esempio n. 6
0
void ThStringUtilities::ToWideString(ThU32 val, ThWchar* result, ThSize bufSize)
{
	ToWideString((ThU64)val, result, bufSize);
}