UniversalIndentGUI 1.2.0
TemplateBatchScript.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2012 by Thomas Schweitzer                          *
00003  *   thomas-schweitzer(at)arcor.de                                         *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License version 2.0 as   *
00007  *   published by the Free Software Foundation.                            *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU General Public License     *
00015  *   along with this program in the file LICENSE.GPL; if not, write to the *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00018  ***************************************************************************/
00019 
00020 #include "TemplateBatchScript.h"
00021 
00022 // Need to include QObject here so that platform specific defines like Q_OS_WIN32 are set.
00023 #include <QObject>
00024 
00036 const char* TemplateBatchScript::getTemplateBatchScript() {
00037     static const char* templateBatchScript =
00038 #if defined(Q_OS_WIN32)
00039         "@echo off\n"
00040         "\n"
00041         "IF (%1)==() GOTO error\n"
00042         "dir /b /ad %1 >nul 2>nul && GOTO indentDir\n"
00043         "IF NOT EXIST %1 GOTO error\n"
00044         "goto indentFile\n"
00045         "\n"
00046         ":indentDir\n"
00047         "set searchdir=%1\n"
00048         "\n"
00049         "IF (%2)==() GOTO assignDefaultSuffix\n"
00050         "set filesuffix=%2\n"
00051         "\n"
00052         "GOTO run\n"
00053         "\n"
00054         ":assignDefaultSuffix\n"
00055         "::echo !!!!DEFAULT SUFFIX!!!\n"
00056         "set filesuffix=*\n"
00057         "\n"
00058         ":run\n"
00059         "FOR /F \"tokens=*\" %%G IN ('DIR /B /S %searchdir%\\*.%filesuffix%') DO (\n"
00060         "echo Indenting file \"%%G\"\n"
00061         "__INDENTERCALLSTRING1__\n"
00062         ")\n"
00063         "GOTO ende\n"
00064         "\n"
00065         ":indentFile\n"
00066         "echo Indenting one file %1\n"
00067         "__INDENTERCALLSTRING2__\n"
00068         "\n"
00069         "GOTO ende\n"
00070         "\n"
00071         ":error\n"
00072         "echo .\n"
00073         "echo ERROR: As parameter given directory or file does not exist!\n"
00074         "echo Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ dirname filesuffix\n"
00075         "echo Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ filename\n"
00076         "echo Example: __INDENTERCALLSTRINGSCRIPTNAME__ temp cpp\n"
00077         "echo .\n"
00078         "\n"
00079         ":ende\n";
00080 
00081 #else
00082 
00083         "#!/bin/sh \n"
00084         "\n"
00085         "if [ ! -n \"$1\" ]; then\n"
00086         "echo \"Syntax is: recurse.sh dirname filesuffix\"\n"
00087         "echo \"Syntax is: recurse.sh filename\"\n"
00088         "echo \"Example: recurse.sh temp cpp\"\n"
00089         "exit 1\n"
00090         "fi\n"
00091         "\n"
00092         "if [ -d \"$1\" ]; then\n"
00093         "#echo \"Dir ${1} exists\"\n"
00094         "if [ -n \"$2\" ]; then\n"
00095         "filesuffix=$2\n"
00096         "else\n"
00097         "filesuffix=\"*\"\n"
00098         "fi\n"
00099         "\n"
00100         "#echo \"Filtering files using suffix ${filesuffix}\"\n"
00101         "\n"
00102         "file_list=`find ${1} -name \"*.${filesuffix}\" -type f`\n"
00103         "for file2indent in $file_list\n"
00104         "do \n"
00105         "echo \"Indenting file $file2indent\"\n"
00106         "__INDENTERCALLSTRING1__\n"
00107         "done\n"
00108         "else\n"
00109         "if [ -f \"$1\" ]; then\n"
00110         "echo \"Indenting one file $1\"\n"
00111         "__INDENTERCALLSTRING2__\n"
00112         "else\n"
00113         "echo \"ERROR: As parameter given directory or file does not exist!\"\n"
00114         "echo \"Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ dirname filesuffix\"\n"
00115         "echo \"Syntax is: __INDENTERCALLSTRINGSCRIPTNAME__ filename\"\n"
00116         "echo \"Example: __INDENTERCALLSTRINGSCRIPTNAME__ temp cpp\"\n"
00117         "exit 1\n"
00118         "fi\n"
00119         "fi\n";
00120 #endif // #if defined(Q_OS_WIN32)
00121     return templateBatchScript;
00122 }
00123 
00124 
00125 /* Here comes the original batch script without the c++ markup
00126 @echo off
00127 
00128 IF (%1)==() GOTO error
00129 dir /b /ad %1 >nul 2>nul && GOTO indentDir
00130 IF NOT EXIST %1 GOTO error
00131 goto indentFile
00132 
00133 :indentDir
00134 set searchdir=%1
00135 
00136 IF (%2)==() GOTO assignDefaultSuffix
00137 set filesuffix=%2
00138 
00139 GOTO run
00140 
00141 :assignDefaultSuffix
00142 ::echo !!!!DEFAULT SUFFIX!!!
00143 set filesuffix=*
00144 
00145 :run
00146 FOR /F "tokens=*" %%G IN ('DIR /B /S %searchdir%\*.%filesuffix%') DO (
00147     echo Indenting file "%%G"
00148     ::call call_CSSTidy.bat "%%G"
00149     "C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" "%%G" --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false  indentoutput.css
00150     move /Y indentoutput.css "%%G"
00151 )
00152 GOTO ende
00153 
00154 :indentFile
00155 echo Indenting one file %1
00156 "C:/Dokumente und Einstellungen/ts/Eigene Dateien/Visual Studio 2005/Projects/UiGuixy/indenters/csstidy.exe" %1 --timestamp=true --allow_html_in_templates=false --compress_colors=true --compress_font=true --lowercase_s=false --preserve_css=false --remove_last_;=false --remove_bslash=true --sort_properties=false --sort_selectors=false  indentoutput.css
00157 move /Y indentoutput.css %1
00158 
00159 GOTO ende
00160 
00161 :error
00162 echo .
00163 echo ERROR: As parameter given directory or file does not exist!
00164 echo Syntax is: recurse.bat dirname filesuffix
00165 echo Syntax is: recurse.bat filename
00166 echo Example: recurse.bat temp cpp
00167 echo .
00168 
00169 :ende
00170 
00171 */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines