Line 20... |
Line 20... |
20 |
|
20 |
|
21 |
namespace PluginManager {
|
21 |
namespace PluginManager {
|
22 |
|
22 |
|
23 |
void MainGui::CheckProtectedDir()
|
23 |
void MainGui::CheckProtectedDir()
|
24 |
{
|
24 |
{
|
25 |
CyString dir;
|
25 |
Utils::String dir;
|
26 |
if ( m_pDirList->Head() ) {
|
26 |
if ( m_pDirList->Head() ) {
|
27 |
m_bDirLocked = false;
|
27 |
m_bDirLocked = false;
|
28 |
dir = m_pDirList->Head()->str;
|
28 |
dir = m_pDirList->Head()->str.ToString();
|
29 |
|
29 |
|
30 |
// write a file in the directory
|
30 |
// write a file in the directory
|
31 |
String ^sDir = SystemStringFromCyString(dir.findreplace("/", "\\"));
|
31 |
String ^sDir = _US(dir.findReplace("/", "\\"));
|
32 |
bool written = true;
|
32 |
bool written = true;
|
33 |
StreamWriter ^sw = nullptr;
|
33 |
StreamWriter ^sw = nullptr;
|
34 |
try {
|
34 |
try {
|
35 |
sw = System::IO::File::CreateText(sDir + "\\checklock.xpmtest");
|
35 |
sw = System::IO::File::CreateText(sDir + "\\checklock.xpmtest");
|
36 |
sw->WriteLine("can write");
|
36 |
sw->WriteLine("can write");
|
Line 70... |
Line 70... |
70 |
written = false;
|
70 |
written = false;
|
71 |
}
|
71 |
}
|
72 |
}
|
72 |
}
|
73 |
|
73 |
|
74 |
if ( !written ) {
|
74 |
if ( !written ) {
|
75 |
MessageBox::Show(this, "ERROR: The game directory:\n" + SystemStringFromCyString(dir) + "\n\nIs locked and unable to add/remove any plugins", "Directory Locked", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
75 |
MessageBox::Show(this, _US(Utils::String::Format(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_LOCKEDDIR), (char *)dir)), _US(CLanguages::Instance()->findText(LS_STARTUP, LANGSTARTUP_LOCKEDDIR_TITLE)), MessageBoxButtons::OK, MessageBoxIcon::Error);
|
76 |
m_bDirLocked = true;
|
76 |
m_bDirLocked = true;
|
77 |
}
|
77 |
}
|
78 |
else {
|
78 |
else {
|
79 |
dir = dir.findreplace("/", "\\");
|
79 |
dir = dir.findReplace("/", "\\");
|
80 |
bool found = false;
|
80 |
bool found = false;
|
81 |
|
81 |
|
82 |
String ^folder = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles);
|
82 |
String ^folder = Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles);
|
83 |
if ( dir.IsIn(CyStringFromSystemString(folder)) )
|
83 |
if ( dir.isin(_S(folder)) )
|
84 |
found = true;
|
84 |
found = true;
|
85 |
else {
|
85 |
else {
|
86 |
folder = Environment::GetEnvironmentVariable("ProgramFiles(x86)");
|
86 |
folder = Environment::GetEnvironmentVariable("ProgramFiles(x86)");
|
87 |
if ( dir.IsIn(CyStringFromSystemString(folder)) )
|
87 |
if ( dir.isin(_S(folder)) )
|
88 |
found = true;
|
88 |
found = true;
|
89 |
}
|
89 |
}
|
90 |
if ( !found ) {
|
90 |
if ( !found ) {
|
91 |
folder = Environment::GetEnvironmentVariable("ProgramFiles");
|
91 |
folder = Environment::GetEnvironmentVariable("ProgramFiles");
|
92 |
if ( dir.IsIn(CyStringFromSystemString(folder)) )
|
92 |
if ( dir.isin(_S(folder)) )
|
93 |
found = true;
|
93 |
found = true;
|
94 |
}
|
94 |
}
|
95 |
|
95 |
|
96 |
if ( found ) {
|
96 |
if ( found ) {
|
97 |
if ( !m_pPackages->IsSupressProtectedWarning() ) {
|
97 |
if ( !m_pPackages->IsSupressProtectedWarning() ) {
|
98 |
if ( MessageBox::Show(this, "WARNING: The game directory:\n" + SystemStringFromCyString(dir) + "\n\nIs in a protected directory (" + _US(CFileIO(dir).dir().tokens("/", 1, 2).findReplace("/", "\\")) + ")\n\nThis might cause problems with installing anything, its better to move to game elsewhere, or you may need to run the Plugin Manager with admin access rights\n\nWould you like to surpress this warning in the future?", "Protected Directory", MessageBoxButtons::YesNo, MessageBoxIcon::Warning) == Windows::Forms::DialogResult::Yes ) {
|
98 |
if ( MessageBox::Show(this, "WARNING: The game directory:\n" + _US(dir) + "\n\nIs in a protected directory (" + _US(CFileIO(dir).dir().tokens("/", 1, 2).findReplace("/", "\\")) + ")\n\nThis might cause problems with installing anything, its better to move to game elsewhere, or you may need to run the Plugin Manager with admin access rights\n\nWould you like to surpress this warning in the future?", "Protected Directory", MessageBoxButtons::YesNo, MessageBoxIcon::Warning) == Windows::Forms::DialogResult::Yes ) {
|
99 |
m_pPackages->SurpressProtectedWarning();
|
99 |
m_pPackages->SurpressProtectedWarning();
|
100 |
}
|
100 |
}
|
101 |
}
|
101 |
}
|
102 |
}
|
102 |
}
|
103 |
}
|
103 |
}
|