コード例 #1
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemSystemPath ( void )
{
    wchar_t szResult[MAX_PATH] = L"";
    SHGetFolderPathW( NULL, CSIDL_SYSTEM, NULL, 0, szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
コード例 #2
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemCommonAppDataPath ( void )
{
    wchar_t szResult[MAX_PATH] = L"";
    SHGetFolderPathW( NULL, CSIDL_COMMON_APPDATA, NULL, 0, szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
コード例 #3
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemDllDirectory ( void )
{
    wchar_t szResult [ 1024 ] = L"";
    GetDllDirectoryW ( NUMELMS ( szResult ), szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
コード例 #4
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemTempPath ( void )
{
    wchar_t szResult[4030] = L"";
    GetTempPathW( 4000, szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
}
コード例 #5
0
ファイル: mfc_dlg.cpp プロジェクト: RavenX8/mysqlpp
void
CExampleDlg::OnBnClickedConnectButton()
{
	WCHAR awcTempBuf[100];
	const int kTempBufSize = sizeof(awcTempBuf) / sizeof(awcTempBuf[0]);

	// Pull user input into our member variables
	UpdateData(TRUE);

	// Clear out the results list, in case this isn't the first time
	// we've come in here.
	ResultsList.ResetContent();

	// Translate the Unicode text we get from the UI into the UTF-8 form
	// that MySQL wants.
	const int kInputBufSize = 100;
	char acServerAddress[kInputBufSize];
	char acUserName[kInputBufSize];
	char acPassword[kInputBufSize];
	ToUTF8(acServerAddress, kInputBufSize, sServerAddress);
	ToUTF8(acUserName, kInputBufSize, sUserName);
	ToUTF8(acPassword, kInputBufSize, sPassword);

	// Connect to the sample database.
	mysqlpp::Connection con(false);
	if (!con.connect("mysql_cpp_data", acServerAddress, acUserName,
			acPassword)) {
		AddMessage(_T("Failed to connect to server:"));
		if (ToUCS2(awcTempBuf, kTempBufSize, con.error())) {
			AddMessage(awcTempBuf);
		}
		return;
	}

	// Retrieve a subset of the sample stock table set up by resetdb
	mysqlpp::Query query = con.query();
	query << "select item from stock";
	mysqlpp::StoreQueryResult res = query.store();

	if (res) {
		// Display the result set
		for (size_t i = 0; i < res.num_rows(); ++i) {
			if (ToUCS2(awcTempBuf, kTempBufSize, res[i][0])) {
				AddMessage(awcTempBuf);
			}
		}

		// Retreive was successful, so save user inputs now
		SaveInputs();
	}
	else {
		// Retreive failed
		AddMessage(_T("Failed to get item list:"));
		if (ToUCS2(awcTempBuf, kTempBufSize, query.error())) {
			AddMessage(awcTempBuf);
		}
	}
}
コード例 #6
0
EPUB3_BEGIN_NAMESPACE

static string GetTempFilePath(const string& ext)
{
#if EPUB_PLATFORM(WIN)
    TCHAR tmpPath[MAX_PATH];
    TCHAR tmpFile[MAX_PATH];

    DWORD pathLen = ::GetTempPath(MAX_PATH, tmpPath);
    if ( pathLen == 0 || pathLen > MAX_PATH )
        throw std::system_error(static_cast<int>(::GetLastError()), std::system_category());

    UINT fileLen = ::GetTempFileName(tmpPath, TEXT("ZIP"), 0, tmpFile);
    if ( fileLen == 0 )
        throw std::system_error(static_cast<int>(::GetLastError()), std::system_category());

    string r(tmpFile);
    return r;
#elif EPUB_PLATFORM(WINRT)
	using ToUTF8 = std::wstring_convert<std::codecvt_utf8<wchar_t>>;

	auto tempFolder = ::Windows::Storage::ApplicationData::Current->TemporaryFolder;
	std::wstring tempFolderPath(tempFolder->Path->Data(), tempFolder->Path->Length());
	std::wstringstream ss;

	ss << tempFolderPath;
	ss << TEXT("\\epub3.");
	ss << Windows::Security::Cryptography::CryptographicBuffer::GenerateRandomNumber();
	ss << TEXT(".");
	ss << ToUTF8().from_bytes(ext.stl_str());
	
	return ToUTF8().to_bytes(ss.str());
#else
    std::stringstream ss;
#if EPUB_OS(ANDROID)
    ss << gAndroidCacheDir << "epub3.XXXXXX";
#else
    ss << "/tmp/epub3.XXXXXX." << ext;
#endif
    string path(ss.str());
    
    char *buf = new char[path.length()];
    std::char_traits<char>::copy(buf, ss.str().c_str(), sizeof(buf));

#if EPUB_OS(ANDROID)
    int fd = ::mkstemp(buf);
#else
    int fd = ::mkstemps(buf, static_cast<int>(ext.size()+1));
#endif
    if ( fd == -1 )
        throw std::runtime_error(std::string("mkstemp() failed: ") + strerror(errno));
    
    ::close(fd);
    return string(buf);
#endif
}
コード例 #7
0
ファイル: libfinaltvmm.cpp プロジェクト: pilkch/library
  RESULT cConnection::PostRequest(const std::string& sRelativeURI, const string_t& sUserName, const string_t& sPassword, const std::map<std::string, std::string>& _mValues)
  {
    std::map<std::string, std::string> mValues(_mValues);

    mValues["version"] = "1";

    mValues["user"] = ToUTF8(sUserName);
    mValues["pass"] = ToUTF8(sPassword);

    return _PostRequest(sRelativeURI, mValues);
  }
コード例 #8
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
// C:\Program Files\gta_sa.exe
SString SharedUtil::GetLaunchPathFilename( void )
{
    static SString strLaunchPathFilename;
    if ( strLaunchPathFilename.empty() )
    {
        wchar_t szBuffer[2048];
        GetModuleFileNameW( NULL, szBuffer, NUMELMS(szBuffer) - 1 );
        if ( IsShortPathName( szBuffer ) )
            return GetSystemLongPathName( ToUTF8( szBuffer ) );
        strLaunchPathFilename = ToUTF8( szBuffer );
    }
    return strLaunchPathFilename;
}
コード例 #9
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemCurrentDirectory ( void )
{
#ifdef WIN32
    wchar_t szResult [ 1024 ] = L"";
    GetCurrentDirectoryW ( NUMELMS ( szResult ), szResult );
    if ( IsShortPathName( szResult ) )
        return GetSystemLongPathName( ToUTF8( szResult ) );
    return ToUTF8( szResult );
#else
    char szBuffer[ MAX_PATH ];
    getcwd ( szBuffer, MAX_PATH - 1 );
    return szBuffer;
#endif
}
コード例 #10
0
ファイル: libfinaltvmm.cpp プロジェクト: pilkch/library
  RESULT cConnection::WatchingMovie(const string_t& sTitle, const cDuration& durationThroughMovie, const cDuration& durationOfMovie)
  {
    assert(IsOpen());

    std::map<std::string, std::string> mValues;

    mValues["action"] = "watching";
    mValues["title"] = ToUTF8(sTitle);
    mValues["position_seconds"] = ToUTF8(durationThroughMovie);
    mValues["length_seconds"] = ToUTF8(durationOfMovie);

    RESULT result = PostRequest("submit.php", sUserName, sPassword, mValues);

    return result;
  }
コード例 #11
0
NS_IMETHODIMP  
nsUTF8ConverterService::ConvertURISpecToUTF8(const nsACString &aSpec, 
                                             const char *aCharset, 
                                             nsACString &aUTF8Spec)
{
  // assume UTF-8 if the spec contains unescaped non-ASCII characters.
  // No valid spec in Mozilla would break this assumption.
  if (!IsASCII(aSpec)) {
    aUTF8Spec = aSpec;
    return NS_OK;
  }

  aUTF8Spec.Truncate();

  nsAutoCString unescapedSpec; 
  // NS_UnescapeURL does not fill up unescapedSpec unless there's at least 
  // one character to unescape.
  bool written = NS_UnescapeURL(PromiseFlatCString(aSpec).get(), aSpec.Length(), 
                                  esc_OnlyNonASCII, unescapedSpec);

  if (!written) {
    aUTF8Spec = aSpec;
    return NS_OK;
  }
  // return if ASCII only or escaped UTF-8
  if (IsASCII(unescapedSpec) || IsUTF8(unescapedSpec)) {
    aUTF8Spec = unescapedSpec;
    return NS_OK;
  }

  return ToUTF8(unescapedSpec, aCharset, true, aUTF8Spec);
}
コード例 #12
0
ファイル: mediaplayers.cpp プロジェクト: Greathood/taiga
wstring MediaPlayers::GetTitleFromWinampAPI(HWND hwnd, bool use_unicode) {
    if (IsWindow(hwnd)) {
        if (SendMessage(hwnd, WM_USER, 0, IPC_ISPLAYING)) {
            int list_index = SendMessage(hwnd, WM_USER, 0, IPC_GETLISTPOS);
            int base_address = SendMessage(hwnd, WM_USER, list_index,
                                           use_unicode ? IPC_GETPLAYLISTFILEW : IPC_GETPLAYLISTFILE);
            if (base_address) {
                DWORD process_id;
                GetWindowThreadProcessId(hwnd, &process_id);
                HANDLE hwnd_winamp = OpenProcess(PROCESS_VM_READ, FALSE, process_id);
                if (hwnd_winamp) {
                    if (use_unicode) {
                        wchar_t file_name[MAX_PATH];
                        ReadProcessMemory(hwnd_winamp, reinterpret_cast<LPCVOID>(base_address),
                                          file_name, MAX_PATH, NULL);
                        CloseHandle(hwnd_winamp);
                        return file_name;
                    } else {
                        char file_name[MAX_PATH];
                        ReadProcessMemory(hwnd_winamp, reinterpret_cast<LPCVOID>(base_address),
                                          file_name, MAX_PATH, NULL);
                        CloseHandle(hwnd_winamp);
                        return ToUTF8(file_name);
                    }
                }
            }
        }
    }
    return L"";
}
コード例 #13
0
ファイル: LocalizeStrings.cpp プロジェクト: Ayu222/android
bool CLocalizeStrings::LoadXML(const CStdString &filename, CStdString &encoding, uint32_t offset /* = 0 */)
{
  TiXmlDocument xmlDoc;
  if (!xmlDoc.LoadFile(CSpecialProtocol::TranslatePathConvertCase(filename)))
  {
    CLog::Log(LOGDEBUG, "unable to load %s: %s at line %d", filename.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
    return false;
  }

  XMLUtils::GetEncoding(&xmlDoc, encoding);

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement || pRootElement->NoChildren() ||
       pRootElement->ValueStr()!=CStdString("strings"))
  {
    CLog::Log(LOGERROR, "%s Doesn't contain <strings>", filename.c_str());
    return false;
  }

  const TiXmlElement *pChild = pRootElement->FirstChildElement("string");
  while (pChild)
  {
    // Load new style language file with id as attribute
    const char* attrId=pChild->Attribute("id");
    if (attrId && !pChild->NoChildren())
    {
      int id = atoi(attrId) + offset;
      if (m_strings.find(id) == m_strings.end())
        m_strings[id] = ToUTF8(encoding, pChild->FirstChild()->Value());
    }
    pChild = pChild->NextSiblingElement("string");
  }
  return true;
}
コード例 #14
0
ファイル: sqlbook.cpp プロジェクト: 4silvertooth/wxSqlitePlus
/*---------------------------------------------------------------------------*/
wxString wxSQLBook::GetSQLStatementAt(long start, long& end)
{
    wxString Str, temp;
    bool first = true;
    long count = m_SQLEdit->GetLineCount();

    end = -1;

    for (long i = start; i < count; i++)
    {
        if (!first)
            Str += ("\n");
        else
            first = false;

        temp = m_SQLEdit->GetLine(i).Trim();
        if ((temp.Last() == (';')) && !m_SQLEdit->EndLineIsComment(i)) // Arrêt au point virgule de fin de commande
            // if (temp.IsEmpty())  // Arrêt à la première ligne vide
        {
            end = i;
            Str += temp;
            break;
        }
        Str += temp;
    }
    return ToUTF8(Str);
}
コード例 #15
0
ファイル: xbmc-xml2po.cpp プロジェクト: KB3NZQ/xbmc-xml2po
// we write str lines into the file
void WriteStrLine(std::string prefix, std::string linkedString, std::string encoding)
{
  linkedString = ToUTF8(encoding, linkedString);
  fprintf (pPOTFile, "%s", prefix.c_str());
  fprintf (pPOTFile, "\"%s\"\n", linkedString.c_str());
  return;
}
コード例 #16
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
SString SharedUtil::GetSystemLongPathName( const SString& strPath )
{
    wchar_t szBuffer[32000];
    szBuffer[0] = 0;
    GetLongPathNameW( FromUTF8( strPath ), szBuffer, NUMELMS( szBuffer ) - 1 );
    return ToUTF8( szBuffer );
}
コード例 #17
0
/*---------------------------------------------------------------------------*/
void wxBackupRestoreDbDlg::SetDatabase(wxSQLite3Database* db, const wxString& base)
{
   wxSQLite3ResultSet dbQRY;
   wxString alias;

   m_Db = db;
   if (!m_Db||!m_Db->IsOpen())
      m_Db = NULL;
   else
   {
      try
      {
         dbQRY = m_Db->ExecuteQuery(ToUTF8(("PRAGMA database_list;")));
         while (dbQRY.NextRow())
         {
            alias = dbQRY.GetString(1);
            m_Database->Append(alias);
         }
         m_Database->SetStringSelection(base);
      }
      catch(wxSQLite3Exception& ex)
      {
         wxGetApp().ShowError(("SetDatabase"), ex);
      }
      dbQRY.Finalize();
   }
}
コード例 #18
0
ファイル: createtrigger.cpp プロジェクト: eriser/wxsqlite3
/*---------------------------------------------------------------------------*/
void wxCreateTriggerDialog::PopulateColumns()
{
   wxString tablename, sql, basename;
   wxSQLite3ResultSet clmnQRY;

   if (m_Db == NULL)
      return;

   tablename = m_ObjName->GetStringSelection();
   if (m_Base != wxEmptyString)
      basename = m_Base;
   else
      basename = _T("main");
   sql = wxString::Format(_T("PRAGMA %s.table_info(\"%s\");"),
                          basename.c_str(), tablename.c_str());

   m_AvailableColumns->Clear();
   m_SelectedColumns->Clear();

   try
   {
      clmnQRY = m_Db->ExecuteQuery(ToUTF8(sql));
      while (clmnQRY.NextRow())
         m_AvailableColumns->Append(clmnQRY.GetString(1));
   }
   catch(wxSQLite3Exception& ex)
   {
      wxGetApp().ShowError(_T("PopulateColumns"), ex);
   }
   clmnQRY.Finalize();
}
コード例 #19
0
NS_IMETHODIMP  
nsUTF8ConverterService::ConvertStringToUTF8(const nsACString &aString, 
                                            const char *aCharset, 
                                            bool aSkipCheck, 
                                            bool aAllowSubstitution,
                                            uint8_t aOptionalArgc,
                                            nsACString &aUTF8String)
{
  bool allowSubstitution = (aOptionalArgc == 1) ? aAllowSubstitution : true;

  // return if ASCII only or valid UTF-8 providing that the ASCII/UTF-8
  // check is requested. It may not be asked for if a caller suspects
  // that the input is in non-ASCII 7bit charset (ISO-2022-xx, HZ) or 
  // it's in a charset other than UTF-8 that can be mistaken for UTF-8.
  if (!aSkipCheck && (IsASCII(aString) || IsUTF8(aString))) {
    aUTF8String = aString;
    return NS_OK;
  }

  aUTF8String.Truncate();

  nsresult rv = ToUTF8(aString, aCharset, allowSubstitution, aUTF8String);

  // additional protection for cases where check is skipped and  the input
  // is actually in UTF-8 as opposed to aCharset. (i.e. caller's hunch
  // was wrong.) We don't check ASCIIness assuming there's no charset
  // incompatible with ASCII (we don't support EBCDIC).
  if (aSkipCheck && NS_FAILED(rv) && IsUTF8(aString)) {
    aUTF8String = aString;
    return NS_OK;
  }

  return rv;
}
コード例 #20
0
ファイル: mediaplayers.cpp プロジェクト: Greathood/taiga
wstring MediaPlayers::GetTitleFromSpecialMessage(HWND hwnd, const wstring& class_name) {
    // BS.Player
    if (class_name == BSP_CLASS) {
        if (IsWindow(hwnd)) {
            COPYDATASTRUCT cds;
            char file_name[MAX_PATH];
            void* data = &file_name;
            cds.dwData = BSP_GETFILENAME;
            cds.lpData = &data;
            cds.cbData = 4;
            SendMessage(hwnd, WM_COPYDATA, reinterpret_cast<WPARAM>(g_hMain),
                        reinterpret_cast<LPARAM>(&cds));
            return ToUTF8(file_name);
        }

        // JetAudio
    } else if (class_name == JETAUDIO_MAINCLASS) {
        HWND hwnd_remote = FindWindow(JETAUDIO_REMOTECLASS, JETAUDIO_WINDOW);
        if (IsWindow(hwnd_remote))  {
            if (SendMessage(hwnd_remote, WM_REMOCON_GETSTATUS, 0, GET_STATUS_STATUS) != MCI_MODE_STOP) {
                if (SendMessage(hwnd_remote, WM_REMOCON_GETSTATUS,
                                reinterpret_cast<WPARAM>(g_hMain), GET_STATUS_TRACK_FILENAME)) {
                    return new_title;
                }
            }
        }
    }

    return L"";
}
コード例 #21
0
SString SharedUtil::GetSystemShortPathName(const SString& strPath)
{
    wchar_t szBuffer[32000];
    szBuffer[0] = 0;
    if (!GetShortPathNameW(FromUTF8(strPath), szBuffer, NUMELMS(szBuffer) - 1))
        return strPath;
    return ToUTF8(szBuffer);
}
コード例 #22
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
// Get drive root from path
SString SharedUtil::GetPathDriveName( const SString& strPath )
{
    wchar_t szDrive[4] = L"";
    int iDriveNumber = PathGetDriveNumberW( FromUTF8( strPath ) );
    if ( iDriveNumber > -1 )
        PathBuildRootW( szDrive, iDriveNumber );
    return ToUTF8( szDrive );
}
コード例 #23
0
ファイル: announce.cpp プロジェクト: Greathood/taiga
LRESULT Skype::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) {
  if (uMsg == WM_COPYDATA) {
    if (hwnd_skype == nullptr ||
        hwnd_skype != reinterpret_cast<HWND>(wParam))
      return FALSE;
    
    auto pCDS = reinterpret_cast<PCOPYDATASTRUCT>(lParam);
    wstring command = ToUTF8(reinterpret_cast<LPCSTR>(pCDS->lpData));
    LOG(LevelDebug, L"Received WM_COPYDATA: " + command);

    wstring profile_command = L"PROFILE RICH_MOOD_TEXT ";
    if (StartsWith(command, profile_command)) {
      wstring mood = command.substr(profile_command.length());
      if (mood != current_mood && mood != previous_mood) {
        LOG(LevelDebug, L"Saved previous mood message: " + mood);
        previous_mood = mood;
      }
    }

    return TRUE;

  } else if (uMsg == wm_attach) {
    hwnd_skype = nullptr;
    
    switch (lParam) {
      case SKYPECONTROLAPI_ATTACH_SUCCESS:
        LOG(LevelDebug, L"Attach succeeded.");
        hwnd_skype = reinterpret_cast<HWND>(wParam);
        GetMoodText();
        if (!current_mood.empty())
          SetMoodText(current_mood);
        break;
      case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
        LOG(LevelDebug, L"Waiting for user confirmation...");
        break;
      case SKYPECONTROLAPI_ATTACH_REFUSED:
        LOG(LevelError, L"User denied access to client.");
        break;
      case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
        LOG(LevelError, L"API is not available.");
        break;
      case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
        LOG(LevelDebug, L"API is now available.");
        Discover();
        break;
      default:
        LOG(LevelDebug, L"Received unknown message.");
        break;
    }

    return TRUE;

  } else if (uMsg == wm_discover) {
    LOG(LevelDebug, L"Received SkypeControlAPIDiscover message.");
  }

  return FALSE;
}
コード例 #24
0
ファイル: libfinaltvmm.cpp プロジェクト: pilkch/library
  RESULT cConnection::WatchedMovie(const string_t& sTitle)
  {
    assert(IsOpen());

    std::map<std::string, std::string> mValues;

    mValues["action"] = "watched";
    mValues["title"] = ToUTF8(sTitle);

    RESULT result = PostRequest("submit.php", sUserName, sPassword, mValues);

    return result;
  }
コード例 #25
0
ファイル: SharedUtil.File.hpp プロジェクト: Cazomino05/Test1
///////////////////////////////////////////////////////////////
//
// FindFiles
//
// Find all files or directories at a path
// If sorted by date, returns last modified last
//
///////////////////////////////////////////////////////////////
std::vector < SString > SharedUtil::FindFiles ( const SString& strInMatch, bool bFiles, bool bDirectories, bool bSortByDate )
{
    std::vector < SString > strResult;
    std::multimap < uint64, SString > sortMap;

    SString strMatch = PathConform ( strInMatch );
    if ( strMatch.Right ( 1 ) == PATH_SEPERATOR )
        strMatch += "*";

    WIN32_FIND_DATAW findData;
    HANDLE hFind = FindFirstFileW ( FromUTF8( strMatch ), &findData );
    if( hFind != INVALID_HANDLE_VALUE )
    {
        do
        {
            if ( ( findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ? bDirectories : bFiles )
                if ( wcscmp ( findData.cFileName, L"." ) && wcscmp ( findData.cFileName, L".." ) )
                {
                    if ( bSortByDate )
                        MapInsert( sortMap, (uint64&)findData.ftLastWriteTime, ToUTF8( findData.cFileName ) );
                    else
                        strResult.push_back ( ToUTF8( findData.cFileName ) );
                }
        }
        while( FindNextFileW( hFind, &findData ) );
        FindClose( hFind );
    }

    // Resolve sorted map if required
    if ( !sortMap.empty() )
    {
        for ( std::multimap < uint64, SString >::iterator iter = sortMap.begin() ; iter != sortMap.end() ; ++iter )
            strResult.push_back ( iter->second );
    }

    return strResult;
}
コード例 #26
0
// C:\Program Files\gta_sa.exe
SString SharedUtil::GetLaunchPathFilename(void)
{
    static SString strLaunchPathFilename;
    if (strLaunchPathFilename.empty())
    {
        wchar_t szBuffer[2048];
        GetModuleFileNameW(NULL, szBuffer, NUMELMS(szBuffer) - 1);

        wchar_t fullPath[MAX_PATH];
        GetFullPathNameW(szBuffer, MAX_PATH, fullPath, nullptr);

        strLaunchPathFilename = ToUTF8(fullPath);
    }
    return strLaunchPathFilename;
}
コード例 #27
0
ファイル: Install.cpp プロジェクト: AdiBoy/mtasa-blue
bool TerminateProcessFromPathFilename ( const SString& strPathFilename )
{
    DWORD dwProcessIDs[250];
    DWORD pBytesReturned = 0;
    if ( EnumProcesses ( dwProcessIDs, 250 * sizeof(DWORD), &pBytesReturned ) )
    {
        DWORD id1 = GetCurrentProcessId();
        for ( unsigned int i = 0; i < pBytesReturned / sizeof ( DWORD ); i++ )
        {
            DWORD id2 = dwProcessIDs[i];
            if ( id2 == id1 )
                continue;
            // Skip 64 bit processes to avoid errors
            if ( !Is32bitProcess ( dwProcessIDs[i] ) )
                continue;
            // Open the process
            HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, dwProcessIDs[i]);
            if ( hProcess )
            {
                HMODULE pModule;
                DWORD cbNeeded;
                if ( EnumProcessModules ( hProcess, &pModule, sizeof ( HMODULE ), &cbNeeded ) )
                {
                    WCHAR szModuleName[MAX_PATH*2] = L"";
                    if ( GetModuleFileNameExW( hProcess, pModule, szModuleName, NUMELMS(szModuleName) ) )
                    {
                        SString strModuleName = ToUTF8( szModuleName );
                        if ( stricmp ( strModuleName, strPathFilename ) == 0 )
                        {
                            TerminateProcess ( hProcess, 0 );
                            CloseHandle ( hProcess );
                            return true;
                        } 
                    }
                }

                // Close the process
                CloseHandle ( hProcess );
            }
        }
    }

    return false;
}
コード例 #28
0
ファイル: TIFF_Support.cpp プロジェクト: JanX2/exempi
static void UTF16_to_UTF8 ( const UTF16Unit * utf16Ptr, size_t utf16Len, bool bigEndian, std::string * outStr )
{
	UTF16_to_UTF8_Proc ToUTF8 = 0;
	if ( bigEndian ) {
		ToUTF8 = UTF16BE_to_UTF8;
	} else {
		ToUTF8 = UTF16LE_to_UTF8;
	}

	UTF8Unit buffer [1000];
	size_t inCount, outCount;
	
	outStr->erase();
	outStr->reserve ( utf16Len * 2 );	// As good a guess as any.
	
	while ( utf16Len > 0 ) {
		ToUTF8 ( utf16Ptr, utf16Len, buffer, sizeof(buffer), &inCount, &outCount );
		outStr->append ( (XMP_StringPtr)buffer, outCount );
		utf16Ptr += inCount;
		utf16Len -= inCount;
	}
	
}	// UTF16_to_UTF8
コード例 #29
0
ファイル: idl_parser.cpp プロジェクト: BlueBrain/flatbuffers
void Parser::Next() {
  doc_comment_.clear();
  bool seen_newline = false;
  for (;;) {
    char c = *cursor_++;
    token_ = c;
    switch (c) {
      case '\0': cursor_--; token_ = kTokenEof; return;
      case ' ': case '\r': case '\t': break;
      case '\n': line_++; seen_newline = true; break;
      case '{': case '}': case '(': case ')': case '[': case ']': return;
      case ',': case ':': case ';': case '=': return;
      case '.':
        if(!isdigit(*cursor_)) return;
        Error("floating point constant can\'t start with \".\"");
        break;
      case '\"':
        attribute_ = "";
        while (*cursor_ != '\"') {

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wtype-limits"
          if (*cursor_ < ' ' && *cursor_ >= 0)
            Error("illegal character in string constant");
#pragma GCC diagnostic pop

          if (*cursor_ == '\\') {
            cursor_++;
            switch (*cursor_) {
              case 'n':  attribute_ += '\n'; cursor_++; break;
              case 't':  attribute_ += '\t'; cursor_++; break;
              case 'r':  attribute_ += '\r'; cursor_++; break;
              case 'b':  attribute_ += '\b'; cursor_++; break;
              case 'f':  attribute_ += '\f'; cursor_++; break;
              case '\"': attribute_ += '\"'; cursor_++; break;
              case '\\': attribute_ += '\\'; cursor_++; break;
              case '/':  attribute_ += '/';  cursor_++; break;
              case 'x': {  // Not in the JSON standard
                cursor_++;
                attribute_ += static_cast<char>(ParseHexNum(2));
                break;
              }
              case 'u': {
                cursor_++;
                ToUTF8(static_cast<int>(ParseHexNum(4)), &attribute_);
                break;
              }
              default: Error("unknown escape code in string constant"); break;
            }
          } else { // printable chars + UTF-8 bytes
            attribute_ += *cursor_++;
          }
        }
        cursor_++;
        token_ = kTokenStringConstant;
        return;
      case '/':
        if (*cursor_ == '/') {
          const char *start = ++cursor_;
          while (*cursor_ && *cursor_ != '\n') cursor_++;
          if (*start == '/') {  // documentation comment
            if (cursor_ != source_ && !seen_newline)
              Error("a documentation comment should be on a line on its own");
            doc_comment_.push_back(std::string(start + 1, cursor_));
          }
          break;
        }
        // fall thru
      default:
        if (isalpha(static_cast<unsigned char>(c))) {
          // Collect all chars of an identifier:
          const char *start = cursor_ - 1;
          while (isalnum(static_cast<unsigned char>(*cursor_)) ||
                 *cursor_ == '_')
            cursor_++;
          attribute_.clear();
          attribute_.append(start, cursor_);
          // First, see if it is a type keyword from the table of types:
          #define FLATBUFFERS_TD(ENUM, IDLTYPE, CTYPE, JTYPE, GTYPE, NTYPE) \
            if (attribute_ == IDLTYPE) { \
              token_ = kToken ## ENUM; \
              return; \
            }
            FLATBUFFERS_GEN_TYPES(FLATBUFFERS_TD)
          #undef FLATBUFFERS_TD
          // If it's a boolean constant keyword, turn those into integers,
          // which simplifies our logic downstream.
          if (attribute_ == "true" || attribute_ == "false") {
            attribute_ = NumToString(attribute_ == "true");
            token_ = kTokenIntegerConstant;
            return;
          }
          // Check for declaration keywords:
          if (attribute_ == "table")     { token_ = kTokenTable;     return; }
          if (attribute_ == "struct")    { token_ = kTokenStruct;    return; }
          if (attribute_ == "enum")      { token_ = kTokenEnum;      return; }
          if (attribute_ == "union")     { token_ = kTokenUnion;     return; }
          if (attribute_ == "namespace") { token_ = kTokenNameSpace; return; }
          if (attribute_ == "root_type") { token_ = kTokenRootType;  return; }
          if (attribute_ == "include")   { token_ = kTokenInclude;   return; }
          if (attribute_ == "attribute") { token_ = kTokenAttribute; return; }
          if (attribute_ == "file_identifier") {
            token_ = kTokenFileIdentifier;
            return;
          }
          if (attribute_ == "file_extension") {
            token_ = kTokenFileExtension;
            return;
          }
          // If not, it is a user-defined identifier:
          token_ = kTokenIdentifier;
          return;
        } else if (isdigit(static_cast<unsigned char>(c)) || c == '-') {
          const char *start = cursor_ - 1;
          while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++;
          if (*cursor_ == '.') {
            cursor_++;
            while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++;
            // See if this float has a scientific notation suffix. Both JSON
            // and C++ (through strtod() we use) have the same format:
            if (*cursor_ == 'e' || *cursor_ == 'E') {
              cursor_++;
              if (*cursor_ == '+' || *cursor_ == '-') cursor_++;
              while (isdigit(static_cast<unsigned char>(*cursor_))) cursor_++;
            }
            token_ = kTokenFloatConstant;
          } else {
            token_ = kTokenIntegerConstant;
          }
          attribute_.clear();
          attribute_.append(start, cursor_);
          return;
        }
        std::string ch;
        ch = c;
        if (c < ' ' || c > '~') ch = "code: " + NumToString(c);
        Error("illegal character: " + ch);
        break;
    }
  }
コード例 #30
0
ファイル: StringOp.cpp プロジェクト: fixopen/RestData
 double const ToDouble(std::wstring const &content) {
     return ToDouble(ToUTF8(content));
 }