1
0
Fork 0
mirror of https://github.com/eliboa/TegraRcmGUI.git synced 2024-09-19 13:33:39 +01:00

Fixed : non utf-8 in directory path & filenames

This commit is contained in:
eliboa 2018-06-29 21:49:00 +02:00
parent 8ef97f20db
commit 20b22c90f0

View file

@ -303,10 +303,10 @@ LRESULT TegraRcm::OnTrayIconEvent(UINT wParam, LPARAM lParam)
string TegraRcm::GetPreset(string param) string TegraRcm::GetPreset(string param)
{ {
TCHAR *rfile = GetAbsolutePath(TEXT("presets.conf"), CSIDL_APPDATA); TCHAR *rfile = GetAbsolutePath(TEXT("presets.conf"), CSIDL_APPDATA);
CT2A rfile_c(rfile, CP_UTF8); //CT2A rfile_c(rfile, CP_UTF8);
TRACE(_T("UTF8: %S\n"), rfile_c.m_psz); //TRACE(_T("UTF8: %S\n"), rfile_c.m_psz);
ifstream readFile(rfile_c); ifstream readFile(rfile);
string readout; string readout;
string search = param + "="; string search = param + "=";
std::string value = ""; std::string value = "";
@ -326,14 +326,9 @@ void TegraRcm::SetPreset(string param, string value)
{ {
TCHAR *rfile = GetAbsolutePath(TEXT("presets.conf"), CSIDL_APPDATA); TCHAR *rfile = GetAbsolutePath(TEXT("presets.conf"), CSIDL_APPDATA);
TCHAR *wfile = GetAbsolutePath(TEXT("presets.conf.tmp"), CSIDL_APPDATA); TCHAR *wfile = GetAbsolutePath(TEXT("presets.conf.tmp"), CSIDL_APPDATA);
CT2A rfile_c(rfile, CP_UTF8);
TRACE(_T("UTF8: %S\n"), rfile_c.m_psz);
CT2A wfile_c(wfile, CP_UTF8);
TRACE(_T("UTF8: %S\n"), wfile_c.m_psz);
// Replace or create preset in file // Replace or create preset in file
ofstream outFile(wfile_c); ofstream outFile(wfile);
ifstream readFile(rfile_c); ifstream readFile(rfile);
string readout; string readout;
string search = param + "="; string search = param + "=";
string replace = search + value + "\n"; string replace = search + value + "\n";
@ -352,23 +347,21 @@ void TegraRcm::SetPreset(string param, string value)
} }
outFile.close(); outFile.close();
readFile.close(); readFile.close();
remove(rfile_c); remove(CT2A(rfile));
rename(wfile_c, rfile_c); rename(CT2A(wfile), CT2A(rfile));
} }
void TegraRcm::GetFavorites() void TegraRcm::GetFavorites()
{ {
Favorites.RemoveAll(); Favorites.RemoveAll();
TCHAR *rfile = GetAbsolutePath(TEXT("favorites.conf"), CSIDL_APPDATA); TCHAR *rfile = GetAbsolutePath(TEXT("favorites.conf"), CSIDL_APPDATA);
CT2A rfile_c(rfile, CP_UTF8);
TRACE(_T("UTF8: %S\n"), rfile_c.m_psz);
string readout; string readout;
AppendLog("Reading favorites.conf"); AppendLog("Reading favorites.conf");
wstring wfilename(rfile); wstring wfilename(rfile);
string filename(wfilename.begin(), wfilename.end()); string filename(wfilename.begin(), wfilename.end());
AppendLog(filename); AppendLog(filename);
ifstream readFile(rfile_c); ifstream readFile(rfile);
if (readFile.is_open()) { if (readFile.is_open()) {
AppendLog("Reading values from favorites.conf"); AppendLog("Reading values from favorites.conf");
while (getline(readFile, readout)) { while (getline(readFile, readout)) {
@ -397,9 +390,7 @@ void TegraRcm::AddFavorite(CString value)
void TegraRcm::SaveFavorites() void TegraRcm::SaveFavorites()
{ {
TCHAR *rfile = GetAbsolutePath(TEXT("favorites.conf"), CSIDL_APPDATA); TCHAR *rfile = GetAbsolutePath(TEXT("favorites.conf"), CSIDL_APPDATA);
CT2A rfile_c(rfile, CP_UTF8); remove(CT2A(rfile));
TRACE(_T("UTF8: %S\n"), rfile_c.m_psz);
remove(rfile_c);
for (int i = 0; i < Favorites.GetCount(); i++) for (int i = 0; i < Favorites.GetCount(); i++)
{ {
AddFavorite(Favorites[i]); AddFavorite(Favorites[i]);
@ -730,6 +721,10 @@ int TegraRcm::Smasher(TCHAR args[])
{ {
rc = exit_code; rc = exit_code;
} }
else
{
rc = -52;
}
} }
else else
{ {
@ -768,7 +763,7 @@ ULONGLONG TegraRcm::GetDllVersion(LPCTSTR lpszDllName)
} }
TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags) TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
{ {
/*
// Get current directory // Get current directory
CString csPath; CString csPath;
TCHAR szPath[_MAX_PATH]; TCHAR szPath[_MAX_PATH];
@ -782,8 +777,8 @@ TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
csPath2 += TEXT("\\"); csPath2 += TEXT("\\");
csPath2 += relative_path; csPath2 += relative_path;
return _tcsdup(csPath2); return _tcsdup(csPath2);
*/
/*
// USE THIS INSTEAD TO BUILD FOR MSI PACKAGER // USE THIS INSTEAD TO BUILD FOR MSI PACKAGER
TCHAR szPath[MAX_PATH]; TCHAR szPath[MAX_PATH];
@ -795,4 +790,5 @@ TCHAR* TegraRcm::GetAbsolutePath(TCHAR* relative_path, DWORD dwFlags)
return _tcsdup(szPath); return _tcsdup(szPath);
} }
return _T(""); return _T("");
*/
} }