GH-1065 Normalize usage of directory vs folder
This commit is contained in:
		@@ -15,7 +15,7 @@ void ensureExists(const QDir &dir)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	if (!QDir().mkpath(dir.absolutePath()))
 | 
						if (!QDir().mkpath(dir.absolutePath()))
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		throw FileSystemException("Unable to create directory " + dir.dirName() + " (" +
 | 
							throw FileSystemException("Unable to create folder " + dir.dirName() + " (" +
 | 
				
			||||||
									  dir.absolutePath() + ")");
 | 
														  dir.absolutePath() + ")");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -265,7 +265,7 @@ QString ResolveExecutable(QString path)
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * Normalize path
 | 
					 * Normalize path
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * Any paths inside the current directory will be normalized to relative paths (to current)
 | 
					 * Any paths inside the current folder will be normalized to relative paths (to current)
 | 
				
			||||||
 * Other paths will be made absolute
 | 
					 * Other paths will be made absolute
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
QString NormalizePath(QString path)
 | 
					QString NormalizePath(QString path)
 | 
				
			||||||
@@ -324,7 +324,7 @@ QString DirNameFromString(QString string, QString inDir)
 | 
				
			|||||||
	return dirName;
 | 
						return dirName;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Does the directory path contain any '!'? If yes, return true, otherwise false.
 | 
					// Does the folder path contain any '!'? If yes, return true, otherwise false.
 | 
				
			||||||
// (This is a problem for Java)
 | 
					// (This is a problem for Java)
 | 
				
			||||||
bool checkProblemticPathJava(QDir folder)
 | 
					bool checkProblemticPathJava(QDir folder)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -140,7 +140,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
 | 
				
			|||||||
		// --dir
 | 
							// --dir
 | 
				
			||||||
		parser.addOption("dir", applicationDirPath());
 | 
							parser.addOption("dir", applicationDirPath());
 | 
				
			||||||
		parser.addShortOpt("dir", 'd');
 | 
							parser.addShortOpt("dir", 'd');
 | 
				
			||||||
		parser.addDocumentation("dir", "use the supplied directory as MultiMC root instead of "
 | 
							parser.addDocumentation("dir", "use the supplied folder as MultiMC root instead of "
 | 
				
			||||||
									   "the binary location (use '.' for current)");
 | 
														   "the binary location (use '.' for current)");
 | 
				
			||||||
		// --launch
 | 
							// --launch
 | 
				
			||||||
		parser.addOption("launch");
 | 
							parser.addOption("launch");
 | 
				
			||||||
@@ -188,7 +188,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
 | 
				
			|||||||
	QString binPath = applicationDirPath();
 | 
						QString binPath = applicationDirPath();
 | 
				
			||||||
	QString adjustedBy;
 | 
						QString adjustedBy;
 | 
				
			||||||
	QString dataPath;
 | 
						QString dataPath;
 | 
				
			||||||
	// change directory
 | 
						// change folder
 | 
				
			||||||
	QString dirParam = args["dir"].toString();
 | 
						QString dirParam = args["dir"].toString();
 | 
				
			||||||
	if (!dirParam.isEmpty())
 | 
						if (!dirParam.isEmpty())
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,16 +11,7 @@
 | 
				
			|||||||
   </rect>
 | 
					   </rect>
 | 
				
			||||||
  </property>
 | 
					  </property>
 | 
				
			||||||
  <layout class="QVBoxLayout" name="verticalLayout">
 | 
					  <layout class="QVBoxLayout" name="verticalLayout">
 | 
				
			||||||
   <property name="leftMargin">
 | 
					   <property name="margin">
 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="topMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="rightMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="bottomMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					    <number>0</number>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
   <item>
 | 
					   <item>
 | 
				
			||||||
@@ -29,7 +20,7 @@
 | 
				
			|||||||
      <enum>QTabWidget::Rounded</enum>
 | 
					      <enum>QTabWidget::Rounded</enum>
 | 
				
			||||||
     </property>
 | 
					     </property>
 | 
				
			||||||
     <property name="currentIndex">
 | 
					     <property name="currentIndex">
 | 
				
			||||||
      <number>0</number>
 | 
					      <number>2</number>
 | 
				
			||||||
     </property>
 | 
					     </property>
 | 
				
			||||||
     <widget class="QWidget" name="minecraftTab">
 | 
					     <widget class="QWidget" name="minecraftTab">
 | 
				
			||||||
      <attribute name="title">
 | 
					      <attribute name="title">
 | 
				
			||||||
@@ -413,7 +404,7 @@
 | 
				
			|||||||
       <item>
 | 
					       <item>
 | 
				
			||||||
        <widget class="QLabel" name="labelCustomCmdsDescription">
 | 
					        <widget class="QLabel" name="labelCustomCmdsDescription">
 | 
				
			||||||
         <property name="text">
 | 
					         <property name="text">
 | 
				
			||||||
          <string><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits.</p><p>Both will be run in MultiMC's working directory with extra environment variables:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_NAME - Name of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_ID - ID of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_DIR - absolute path of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_MC_DIR - absolute path of minecraft</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_JAVA - java binary used for launch</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_JAVA_ARGS - command-line parameters used for launch</li></ul></body></html></string>
 | 
					          <string><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits.</p><p>Both will be run in MultiMC's working folder with extra environment variables:</p><ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_NAME - Name of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_ID - ID of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_DIR - absolute path of the instance</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_MC_DIR - absolute path of minecraft</li><li style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_JAVA - java binary used for launch</li><li style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">INST_JAVA_ARGS - command-line parameters used for launch</li></ul></body></html></string>
 | 
				
			||||||
         </property>
 | 
					         </property>
 | 
				
			||||||
         <property name="alignment">
 | 
					         <property name="alignment">
 | 
				
			||||||
          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
 | 
					          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -86,7 +86,7 @@ void ExternalToolsPage::on_jprofilerPathBtn_clicked()
 | 
				
			|||||||
	QString error;
 | 
						QString error;
 | 
				
			||||||
	do
 | 
						do
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		raw_dir = QFileDialog::getExistingDirectory(this, tr("JProfiler Directory"), raw_dir);
 | 
							raw_dir = QFileDialog::getExistingDirectory(this, tr("JProfiler Folder"), raw_dir);
 | 
				
			||||||
		if (raw_dir.isEmpty())
 | 
							if (raw_dir.isEmpty())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
@@ -164,7 +164,7 @@ void ExternalToolsPage::on_mceditPathBtn_clicked()
 | 
				
			|||||||
#warning stuff
 | 
					#warning stuff
 | 
				
			||||||
		raw_dir = QFileDialog::getOpenFileName(this, tr("MCEdit Application"), raw_dir);
 | 
							raw_dir = QFileDialog::getOpenFileName(this, tr("MCEdit Application"), raw_dir);
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
		raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Directory"), raw_dir);
 | 
							raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Folder"), raw_dir);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		if (raw_dir.isEmpty())
 | 
							if (raw_dir.isEmpty())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,16 +17,7 @@
 | 
				
			|||||||
   </sizepolicy>
 | 
					   </sizepolicy>
 | 
				
			||||||
  </property>
 | 
					  </property>
 | 
				
			||||||
  <layout class="QVBoxLayout" name="verticalLayout">
 | 
					  <layout class="QVBoxLayout" name="verticalLayout">
 | 
				
			||||||
   <property name="leftMargin">
 | 
					   <property name="margin">
 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="topMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="rightMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					 | 
				
			||||||
   </property>
 | 
					 | 
				
			||||||
   <property name="bottomMargin">
 | 
					 | 
				
			||||||
    <number>0</number>
 | 
					    <number>0</number>
 | 
				
			||||||
   </property>
 | 
					   </property>
 | 
				
			||||||
   <item>
 | 
					   <item>
 | 
				
			||||||
@@ -273,7 +264,7 @@
 | 
				
			|||||||
          </sizepolicy>
 | 
					          </sizepolicy>
 | 
				
			||||||
         </property>
 | 
					         </property>
 | 
				
			||||||
         <property name="text">
 | 
					         <property name="text">
 | 
				
			||||||
          <string><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working directory with INST_ID, INST_DIR, and INST_NAME as environment variables.</p><p>Wrapper command allows running java using an extra wrapper program (like 'optirun' on Linux)</p></body></html></string>
 | 
					          <string><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working folder with INST_ID, INST_DIR, and INST_NAME as environment variables.</p><p>Wrapper command allows running java using an extra wrapper program (like 'optirun' on Linux)</p></body></html></string>
 | 
				
			||||||
         </property>
 | 
					         </property>
 | 
				
			||||||
         <property name="alignment">
 | 
					         <property name="alignment">
 | 
				
			||||||
          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
 | 
					          <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -99,7 +99,7 @@ bool MultiMCPage::apply()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void MultiMCPage::on_ftbLauncherBrowseBtn_clicked()
 | 
					void MultiMCPage::on_ftbLauncherBrowseBtn_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Launcher Directory"),
 | 
						QString raw_dir = QFileDialog::getExistingDirectory(this, tr("FTB Launcher Folder"),
 | 
				
			||||||
														ui->ftbLauncherBox->text());
 | 
																			ui->ftbLauncherBox->text());
 | 
				
			||||||
	QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
						QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -112,7 +112,7 @@ void MultiMCPage::on_ftbLauncherBrowseBtn_clicked()
 | 
				
			|||||||
void MultiMCPage::on_ftbBrowseBtn_clicked()
 | 
					void MultiMCPage::on_ftbBrowseBtn_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString raw_dir =
 | 
						QString raw_dir =
 | 
				
			||||||
		QFileDialog::getExistingDirectory(this, tr("FTB Directory"), ui->ftbBox->text());
 | 
							QFileDialog::getExistingDirectory(this, tr("FTB Folder"), ui->ftbBox->text());
 | 
				
			||||||
	QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
						QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// do not allow current dir - it's dirty. Do not allow dirs that don't exist
 | 
						// do not allow current dir - it's dirty. Do not allow dirs that don't exist
 | 
				
			||||||
@@ -124,7 +124,7 @@ void MultiMCPage::on_ftbBrowseBtn_clicked()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void MultiMCPage::on_instDirBrowseBtn_clicked()
 | 
					void MultiMCPage::on_instDirBrowseBtn_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Directory"),
 | 
					    QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Instance Folder"),
 | 
				
			||||||
                                                        ui->instDirTextBox->text());
 | 
					                                                        ui->instDirTextBox->text());
 | 
				
			||||||
    QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
					    QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -157,7 +157,7 @@ void MultiMCPage::on_instDirBrowseBtn_clicked()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void MultiMCPage::on_iconsDirBrowseBtn_clicked()
 | 
					void MultiMCPage::on_iconsDirBrowseBtn_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Directory"),
 | 
						QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Icons Folder"),
 | 
				
			||||||
														ui->iconsDirTextBox->text());
 | 
																			ui->iconsDirTextBox->text());
 | 
				
			||||||
	QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
						QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -169,7 +169,7 @@ void MultiMCPage::on_iconsDirBrowseBtn_clicked()
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
void MultiMCPage::on_modsDirBrowseBtn_clicked()
 | 
					void MultiMCPage::on_modsDirBrowseBtn_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Directory"),
 | 
						QString raw_dir = QFileDialog::getExistingDirectory(this, tr("Mods Folder"),
 | 
				
			||||||
														ui->modsDirTextBox->text());
 | 
																			ui->modsDirTextBox->text());
 | 
				
			||||||
	QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
						QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -181,7 +181,7 @@ void MultiMCPage::on_modsDirBrowseBtn_clicked()
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
void MultiMCPage::on_lwjglDirBrowseBtn_clicked()
 | 
					void MultiMCPage::on_lwjglDirBrowseBtn_clicked()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	QString raw_dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Directory"),
 | 
						QString raw_dir = QFileDialog::getExistingDirectory(this, tr("LWJGL Folder"),
 | 
				
			||||||
														ui->lwjglDirTextBox->text());
 | 
																			ui->lwjglDirTextBox->text());
 | 
				
			||||||
	QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
						QString cooked_dir = FS::NormalizePath(raw_dir);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user