741 |
10 Oct 06 |
olle |
1 |
/* |
1652 |
22 May 07 |
gregory |
$Id$ |
741 |
10 Oct 06 |
olle |
3 |
|
1916 |
31 Aug 07 |
jari |
Copyright (C) 2006 Olle Mansson |
1916 |
31 Aug 07 |
jari |
Copyright (C) 2007 Gregory Vincic |
741 |
10 Oct 06 |
olle |
6 |
|
1652 |
22 May 07 |
gregory |
This file is part of Proteios. |
1652 |
22 May 07 |
gregory |
Available at http://www.proteios.org/ |
741 |
10 Oct 06 |
olle |
9 |
|
1652 |
22 May 07 |
gregory |
Proteios is free software; you can redistribute it and/or modify it |
1652 |
22 May 07 |
gregory |
under the terms of the GNU General Public License as published by |
1652 |
22 May 07 |
gregory |
the Free Software Foundation; either version 2 of the License, or |
1652 |
22 May 07 |
gregory |
(at your option) any later version. |
741 |
10 Oct 06 |
olle |
14 |
|
1652 |
22 May 07 |
gregory |
Proteios is distributed in the hope that it will be useful, but |
1652 |
22 May 07 |
gregory |
WITHOUT ANY WARRANTY; without even the implied warranty of |
1652 |
22 May 07 |
gregory |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1652 |
22 May 07 |
gregory |
General Public License for more details. |
741 |
10 Oct 06 |
olle |
19 |
|
1652 |
22 May 07 |
gregory |
You should have received a copy of the GNU General Public License |
1652 |
22 May 07 |
gregory |
along with this program; if not, write to the Free Software |
1652 |
22 May 07 |
gregory |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
1652 |
22 May 07 |
gregory |
02111-1307, USA. |
1652 |
22 May 07 |
gregory |
24 |
*/ |
741 |
10 Oct 06 |
olle |
25 |
|
741 |
10 Oct 06 |
olle |
// Xerver Free Web Server |
741 |
10 Oct 06 |
olle |
// Copyright (C) 2002-2005 Omid Rouhani |
741 |
10 Oct 06 |
olle |
28 |
// |
741 |
10 Oct 06 |
olle |
29 |
// |
741 |
10 Oct 06 |
olle |
// This program is free software; you can redistribute it and/or |
741 |
10 Oct 06 |
olle |
// modify it under the terms of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// as published by the Free Software Foundation; either version 2 |
741 |
10 Oct 06 |
olle |
// of the License, or (at your option) any later version. |
741 |
10 Oct 06 |
olle |
34 |
// |
741 |
10 Oct 06 |
olle |
// This program is distributed in the hope that it will be useful, |
741 |
10 Oct 06 |
olle |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
741 |
10 Oct 06 |
olle |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
741 |
10 Oct 06 |
olle |
// GNU General Public License for more details. |
741 |
10 Oct 06 |
olle |
39 |
// |
741 |
10 Oct 06 |
olle |
// You should have received a copy of the GNU General Public License |
741 |
10 Oct 06 |
olle |
// along with this program; if not, write to the Free Software |
741 |
10 Oct 06 |
olle |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
741 |
10 Oct 06 |
olle |
43 |
// |
741 |
10 Oct 06 |
olle |
44 |
// |
741 |
10 Oct 06 |
olle |
45 |
// ############################################################# |
741 |
10 Oct 06 |
olle |
// ## YOU CAN CONTACT THE AUTHOR (OMID ROUHANI) AT: ## |
741 |
10 Oct 06 |
olle |
// ## HTTP://WWW.JAVASCRIPT.NU/XERVER/ ## |
741 |
10 Oct 06 |
olle |
48 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## IF YOUR SOFTWARE IS NOT RELEASED UNDER THE ## |
741 |
10 Oct 06 |
olle |
// ## GNU GENERAL PUBLIC LICENSE (GPL), ## |
741 |
10 Oct 06 |
olle |
// ## PLEASE DO NOT COPY ANYTHING FROM THIS SOURCE CODE!!! ## |
741 |
10 Oct 06 |
olle |
52 |
// ## ## |
741 |
10 Oct 06 |
olle |
// ## FOR FULL LICENSE, PLEASE READ "XERVER LICENSE". ## |
741 |
10 Oct 06 |
olle |
54 |
// ############################################################# |
741 |
10 Oct 06 |
olle |
55 |
|
1652 |
22 May 07 |
gregory |
56 |
package se.lu.thep.coreftpd.webserver; |
741 |
10 Oct 06 |
olle |
57 |
|
741 |
10 Oct 06 |
olle |
58 |
import java.io.BufferedReader; |
741 |
10 Oct 06 |
olle |
59 |
import java.io.File; |
741 |
10 Oct 06 |
olle |
60 |
import java.io.InputStreamReader; |
741 |
10 Oct 06 |
olle |
61 |
import javax.swing.UIManager; |
741 |
10 Oct 06 |
olle |
62 |
|
741 |
10 Oct 06 |
olle |
63 |
/** |
1652 |
22 May 07 |
gregory |
64 |
* |
1652 |
22 May 07 |
gregory |
* <B>About this class:</B> <BR> |
1652 |
22 May 07 |
gregory |
* This class creates the directories that Xerver needs and moves files into |
1652 |
22 May 07 |
gregory |
* these directories when Xerver is installed. <BR> |
741 |
10 Oct 06 |
olle |
* You can also (safety) run this class when Xerver already has been installed. |
1652 |
22 May 07 |
gregory |
69 |
* |
741 |
10 Oct 06 |
olle |
* @author <a href="http://www.JavaScript.nu/xerver/" TARGET="_top">Omid Rouhani</a> |
741 |
10 Oct 06 |
olle |
* @version 1.0 |
741 |
10 Oct 06 |
olle |
72 |
*/ |
741 |
10 Oct 06 |
olle |
73 |
|
1652 |
22 May 07 |
gregory |
74 |
final public class InstallXerver { |
1652 |
22 May 07 |
gregory |
75 |
private String hiddenFolder = "data" + File.separator; |
741 |
10 Oct 06 |
olle |
76 |
|
1652 |
22 May 07 |
gregory |
77 |
private String errorFilesFolder = "errorHTML" + File.separator; |
741 |
10 Oct 06 |
olle |
78 |
|
1652 |
22 May 07 |
gregory |
79 |
private String helpFilesFolder = "help" + File.separator; |
741 |
10 Oct 06 |
olle |
80 |
|
1652 |
22 May 07 |
gregory |
81 |
private final String zipFileName = "filesZipped.zip"; |
1652 |
22 May 07 |
gregory |
82 |
|
1652 |
22 May 07 |
gregory |
83 |
private final static boolean b_showErrors = false; |
1652 |
22 May 07 |
gregory |
84 |
|
1652 |
22 May 07 |
gregory |
85 |
public static void main(String[] s) { |
1652 |
22 May 07 |
gregory |
86 |
try { |
1652 |
22 May 07 |
gregory |
// UIManager.setLookAndFeel( |
1652 |
22 May 07 |
gregory |
// UIManager.getCrossPlatformLookAndFeelClassName()); |
1652 |
22 May 07 |
gregory |
89 |
UIManager |
1652 |
22 May 07 |
gregory |
90 |
.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); // Try |
1652 |
22 May 07 |
gregory |
// to |
1652 |
22 May 07 |
gregory |
// use |
1652 |
22 May 07 |
gregory |
// Windows |
1652 |
22 May 07 |
gregory |
// interface |
1652 |
22 May 07 |
gregory |
95 |
} catch (Exception e) { |
1652 |
22 May 07 |
gregory |
96 |
} |
1652 |
22 May 07 |
gregory |
97 |
|
741 |
10 Oct 06 |
olle |
98 |
new InstallXerver(); |
741 |
10 Oct 06 |
olle |
99 |
} |
741 |
10 Oct 06 |
olle |
100 |
|
741 |
10 Oct 06 |
olle |
101 |
/** |
1652 |
22 May 07 |
gregory |
* Run the main method to start this constructor which is only used to start |
1652 |
22 May 07 |
gregory |
* an terminal based install program where the user is asked where to |
1652 |
22 May 07 |
gregory |
* install Xerver. |
1652 |
22 May 07 |
gregory |
105 |
*/ |
1652 |
22 May 07 |
gregory |
106 |
InstallXerver() { |
1652 |
22 May 07 |
gregory |
107 |
String indata = null; |
741 |
10 Oct 06 |
olle |
108 |
BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); |
741 |
10 Oct 06 |
olle |
109 |
System.out.println("What do you want to do?"); |
1652 |
22 May 07 |
gregory |
110 |
System.out |
1652 |
22 May 07 |
gregory |
111 |
.println("[1] Start Xerver installer (require a graphical interface). (RECOMMENDED)"); |
741 |
10 Oct 06 |
olle |
112 |
System.out.println("[2] Install Xerver in the current directory."); |
1652 |
22 May 07 |
gregory |
113 |
System.out |
1652 |
22 May 07 |
gregory |
114 |
.println("[3] I want to enter a location where Xerver shall be installed."); |
741 |
10 Oct 06 |
olle |
115 |
System.out.println(""); |
1652 |
22 May 07 |
gregory |
116 |
do { |
741 |
10 Oct 06 |
olle |
117 |
System.out.println("Please enter 1, 2, 3 or \"exit\" to quit:"); |
741 |
10 Oct 06 |
olle |
118 |
try { |
1652 |
22 May 07 |
gregory |
119 |
indata = in.readLine(); |
741 |
10 Oct 06 |
olle |
120 |
|
741 |
10 Oct 06 |
olle |
121 |
if (indata.toLowerCase().equals("exit")) |
741 |
10 Oct 06 |
olle |
122 |
System.exit(0); |
1652 |
22 May 07 |
gregory |
123 |
else if (indata.equals("1")) { |
741 |
10 Oct 06 |
olle |
124 |
System.out.println("Starting Xerver installer..."); |
741 |
10 Oct 06 |
olle |
125 |
new SetupWindow(); |
1652 |
22 May 07 |
gregory |
126 |
System.out |
1652 |
22 May 07 |
gregory |
127 |
.println("Start Xerver Setup with \"java SetupXerver\"."); |
741 |
10 Oct 06 |
olle |
128 |
System.out.println("Start Xerver with \"java Start\"."); |
1652 |
22 May 07 |
gregory |
129 |
} else if (indata.equals("2")) { |
741 |
10 Oct 06 |
olle |
130 |
System.out.println("Installing in progress..."); |
741 |
10 Oct 06 |
olle |
131 |
new InstallXerver(""); |
741 |
10 Oct 06 |
olle |
132 |
System.out.println("Installing done!"); |
741 |
10 Oct 06 |
olle |
133 |
System.out.println(""); |
741 |
10 Oct 06 |
olle |
134 |
System.out.println("Starting Xerver Setup:"); |
741 |
10 Oct 06 |
olle |
135 |
new SetupXerver(); |
1652 |
22 May 07 |
gregory |
136 |
} else if (indata.equals("3")) { |
741 |
10 Oct 06 |
olle |
137 |
System.out.println("Where do you want to install Xerver:"); |
1652 |
22 May 07 |
gregory |
138 |
String s_installPathEntered = in.readLine(); |
1652 |
22 May 07 |
gregory |
139 |
File f_installPathEntered = new File(s_installPathEntered); |
1652 |
22 May 07 |
gregory |
140 |
if (f_installPathEntered.isDirectory() |
1652 |
22 May 07 |
gregory |
141 |
&& !s_installPathEntered.equals("")) { |
741 |
10 Oct 06 |
olle |
142 |
System.out.println("Installing in progress..."); |
741 |
10 Oct 06 |
olle |
143 |
new InstallXerver(f_installPathEntered.getPath()); |
741 |
10 Oct 06 |
olle |
144 |
System.out.println("Installing done!"); |
1652 |
22 May 07 |
gregory |
145 |
System.out.println("When you are in " |
1652 |
22 May 07 |
gregory |
146 |
+ f_installPathEntered.getAbsolutePath() |
1652 |
22 May 07 |
gregory |
147 |
+ ", you can use these commands:"); |
1652 |
22 May 07 |
gregory |
148 |
System.out |
1652 |
22 May 07 |
gregory |
149 |
.println("\"java SetupXerver\" - Start Xerver Setup"); // Note, |
1652 |
22 May 07 |
gregory |
// we |
1652 |
22 May 07 |
gregory |
// can't |
1652 |
22 May 07 |
gregory |
// start |
1652 |
22 May 07 |
gregory |
// "new |
1652 |
22 May 07 |
gregory |
// SetupXerver()" |
1652 |
22 May 07 |
gregory |
// automatically |
1652 |
22 May 07 |
gregory |
// as |
1652 |
22 May 07 |
gregory |
// it |
1652 |
22 May 07 |
gregory |
// might |
1652 |
22 May 07 |
gregory |
// not |
1652 |
22 May 07 |
gregory |
// have |
1652 |
22 May 07 |
gregory |
// been |
1652 |
22 May 07 |
gregory |
// installed |
1652 |
22 May 07 |
gregory |
// (extracted) |
1652 |
22 May 07 |
gregory |
// Xerver |
1652 |
22 May 07 |
gregory |
// in |
1652 |
22 May 07 |
gregory |
// the |
1652 |
22 May 07 |
gregory |
// "present |
1652 |
22 May 07 |
gregory |
// working |
1652 |
22 May 07 |
gregory |
// directory"... |
741 |
10 Oct 06 |
olle |
170 |
System.out.println("\"java Start\" - Start Xerver"); |
1652 |
22 May 07 |
gregory |
171 |
} else { |
1652 |
22 May 07 |
gregory |
172 |
indata = "dummy value"; // not 1, 2 or 3 |
1652 |
22 May 07 |
gregory |
173 |
System.out.println(f_installPathEntered.getPath() |
1652 |
22 May 07 |
gregory |
174 |
+ " does not exists! Try again!"); |
741 |
10 Oct 06 |
olle |
175 |
} |
741 |
10 Oct 06 |
olle |
176 |
} |
1652 |
22 May 07 |
gregory |
177 |
} catch (Exception e) { |
1652 |
22 May 07 |
gregory |
178 |
if (b_showErrors) |
1652 |
22 May 07 |
gregory |
179 |
System.out.println("An error occured:\n" + e.getMessage()); |
1652 |
22 May 07 |
gregory |
180 |
} |
1652 |
22 May 07 |
gregory |
181 |
} while (!indata.equals("1") && !indata.equals("2") |
1652 |
22 May 07 |
gregory |
182 |
&& !indata.equals("3")); |
741 |
10 Oct 06 |
olle |
183 |
} |
741 |
10 Oct 06 |
olle |
184 |
|
741 |
10 Oct 06 |
olle |
185 |
/** |
1652 |
22 May 07 |
gregory |
* This installs Xerver into <CODE>s_installPath</CODE>. Make sure the |
1652 |
22 May 07 |
gregory |
* zip file <CODE>zipFileName</CODE> is located in the "current working |
1652 |
22 May 07 |
gregory |
* directory" (usually the same folder as this class file is located). |
1652 |
22 May 07 |
gregory |
* <CODE>s_installPath</CODE> must be a valid path or "" ("" = install in |
1652 |
22 May 07 |
gregory |
* "present working directory") |
1652 |
22 May 07 |
gregory |
191 |
*/ |
1652 |
22 May 07 |
gregory |
192 |
InstallXerver(String s_installPath) { |
1652 |
22 May 07 |
gregory |
193 |
if (s_installPath == null) |
1652 |
22 May 07 |
gregory |
194 |
s_installPath = ""; |
741 |
10 Oct 06 |
olle |
195 |
else if ((new File(s_installPath)).exists()) |
1652 |
22 May 07 |
gregory |
196 |
s_installPath = (new File(s_installPath)).getPath() |
1652 |
22 May 07 |
gregory |
197 |
+ File.separator; |
741 |
10 Oct 06 |
olle |
198 |
else |
1652 |
22 May 07 |
gregory |
199 |
s_installPath = ""; |
741 |
10 Oct 06 |
olle |
200 |
|
1652 |
22 May 07 |
gregory |
// System.out.println("*******************************************"); |
1652 |
22 May 07 |
gregory |
// System.out.println("**** Xerver is being installed! ****"); |
1652 |
22 May 07 |
gregory |
// System.out.println("*******************************************"); |
1652 |
22 May 07 |
gregory |
// System.out.println(""); |
1652 |
22 May 07 |
gregory |
// System.out.print("* Extracting \""+zipFileName+"...\" "); |
1652 |
22 May 07 |
gregory |
206 |
new ExtractZipFileInstall(zipFileName, true, s_installPath); // true=overwrite |
1652 |
22 May 07 |
gregory |
// files |
1652 |
22 May 07 |
gregory |
// (ExtractZipFileInstall |
1652 |
22 May 07 |
gregory |
// will |
1652 |
22 May 07 |
gregory |
// never |
1652 |
22 May 07 |
gregory |
// owerwrite |
1652 |
22 May 07 |
gregory |
// "xerver.cfg") |
1652 |
22 May 07 |
gregory |
213 |
moveAllFiles(s_installPath); // In case the user has unzipped the |
1652 |
22 May 07 |
gregory |
// zip-file manually or if someone only |
1652 |
22 May 07 |
gregory |
// got all files coming with the source |
1652 |
22 May 07 |
gregory |
// files in one folder. |
1652 |
22 May 07 |
gregory |
// System.out.println("[ DONE! ]"); |
1652 |
22 May 07 |
gregory |
// System.out.println(""); |
1652 |
22 May 07 |
gregory |
// System.out.println("* Running Xerver Setup [ DONE! ]"); |
1652 |
22 May 07 |
gregory |
// System.out.println(""); |
1652 |
22 May 07 |
gregory |
// (new Thread(new SetupXerverKernel())).start(); |
1652 |
22 May 07 |
gregory |
// System.out.println("[NOTE: Visit http://localhost:32123/ now!]"); |
1652 |
22 May 07 |
gregory |
// System.out.println(""); |
1652 |
22 May 07 |
gregory |
// System.out.print("* Starting Xerver "); |
1652 |
22 May 07 |
gregory |
// new Start(); |
1652 |
22 May 07 |
gregory |
// System.out.println("[ DONE! ]"); |
1652 |
22 May 07 |
gregory |
// System.out.println(""); |
1652 |
22 May 07 |
gregory |
// System.out.println("* Install is finished!"); |
741 |
10 Oct 06 |
olle |
229 |
} |
741 |
10 Oct 06 |
olle |
230 |
|
741 |
10 Oct 06 |
olle |
231 |
/** |
1652 |
22 May 07 |
gregory |
* Move all files Xerver uses to the correct directories. This is actually |
1652 |
22 May 07 |
gregory |
* not used during a normal install, as <CODE>ExtractZipFileInstall</CODE> |
1652 |
22 May 07 |
gregory |
* takes care of that, but this is useful for example when someone already |
1652 |
22 May 07 |
gregory |
* has extracted all files in one directory and now runs the "java |
1652 |
22 May 07 |
gregory |
* InstallXerver" to move all files to the correct directories. |
1652 |
22 May 07 |
gregory |
237 |
*/ |
1652 |
22 May 07 |
gregory |
238 |
private void moveAllFiles(String s_installPath) { |
1652 |
22 May 07 |
gregory |
239 |
String[] filesThatShallBeHidden = { "AddAliasSetup.html", |
1652 |
22 May 07 |
gregory |
240 |
"AddDirSetup.html", "AddExtSetup.html", "AddIndSetup.html", |
1652 |
22 May 07 |
gregory |
241 |
"AddProtDirSetup.html", "AddProtFrameSetup.html", |
1652 |
22 May 07 |
gregory |
242 |
"AddProtSetup.html", "AddProtUserSetup.html", |
1652 |
22 May 07 |
gregory |
243 |
"AddScriptExtSetup.html", "empty.html", |
1652 |
22 May 07 |
gregory |
244 |
"WizGeneralSettings.html", "WizFrames.html", "WizMenu.html", |
1652 |
22 May 07 |
gregory |
245 |
"WizStep1.html", "WizStep2.html", "WizStep3.html", |
1652 |
22 May 07 |
gregory |
246 |
"WizStep4.html", "WizStep5.html", "WizStep6.html", |
1652 |
22 May 07 |
gregory |
247 |
"WizStep7.html", "WizStep8.html", "WizStep9.html", |
1652 |
22 May 07 |
gregory |
248 |
"WizardHelp.html", "Xerver.cfg", "Xerver.cfg.txt", |
1652 |
22 May 07 |
gregory |
249 |
"empty.html", "imagefileicon.gif", "imagefolder.gif", |
1652 |
22 May 07 |
gregory |
250 |
"imageinvisible.gif", "imagelogo.gif", "imagestartbutton.gif", |
1652 |
22 May 07 |
gregory |
251 |
"imagestartsetupbutton.gif", "imagestopbutton.gif", |
1652 |
22 May 07 |
gregory |
252 |
"imagestopsetupbutton.gif", "imagewizardbig.gif", |
1652 |
22 May 07 |
gregory |
253 |
"imagewizardsmall.gif", "imagexerverlogo.gif" }; |
741 |
10 Oct 06 |
olle |
254 |
|
1652 |
22 May 07 |
gregory |
255 |
String[] filesThatCanBeEdited = { "error400badrequest.html", |
1652 |
22 May 07 |
gregory |
256 |
"error401notauthorized.html", |
1652 |
22 May 07 |
gregory |
257 |
"error403hiddenfilenotshared.html", |
1652 |
22 May 07 |
gregory |
258 |
"error403noaccessextension.html", |
1652 |
22 May 07 |
gregory |
259 |
"error403noaccessfolder.html", |
1652 |
22 May 07 |
gregory |
260 |
"error403nodirectorylisting.html", |
1652 |
22 May 07 |
gregory |
261 |
"error403webservercantreadfile.html", |
1652 |
22 May 07 |
gregory |
262 |
"error404filedoesnotexist.html", "error505unknownhttp.html" }; |
741 |
10 Oct 06 |
olle |
263 |
|
1652 |
22 May 07 |
gregory |
264 |
String[] helpFiles = { "help403forbidden.html", "helpcantrunperl.html", |
1652 |
22 May 07 |
gregory |
265 |
"helpcantrunphp.html", "helpdifferentrunmodes.html", |
1652 |
22 May 07 |
gregory |
266 |
"helpfriendscantbrowse.html", "helpisxerverfree.html", |
1652 |
22 May 07 |
gregory |
267 |
"helpjavainstalled.html", "helplowsystemresources.html", |
1652 |
22 May 07 |
gregory |
268 |
"helpownerrorpages.html", "helppasswordtofolders.html", |
1652 |
22 May 07 |
gregory |
269 |
"helpperlhelloworld.html", "helpperlwontrun.html", |
1652 |
22 May 07 |
gregory |
270 |
"helpphphelloworld.html", "helpphpwontrun.html", |
1652 |
22 May 07 |
gregory |
271 |
"helpproblemwithscripts.html", "helprunotherscripts.html", |
1652 |
22 May 07 |
gregory |
272 |
"helprunxerver.html", "helpstartxerver.html", |
1652 |
22 May 07 |
gregory |
273 |
"helpuninstall.html", "helpwhatisxerver.html", "index.html", |
1652 |
22 May 07 |
gregory |
274 |
"main.html", "menu.html" }; |
741 |
10 Oct 06 |
olle |
275 |
|
741 |
10 Oct 06 |
olle |
276 |
createFolders(s_installPath); |
741 |
10 Oct 06 |
olle |
277 |
moveFiles(hiddenFolder, filesThatShallBeHidden, s_installPath); |
741 |
10 Oct 06 |
olle |
278 |
moveFiles(errorFilesFolder, filesThatCanBeEdited, s_installPath); |
741 |
10 Oct 06 |
olle |
279 |
moveFiles(helpFilesFolder, helpFiles, s_installPath); |
741 |
10 Oct 06 |
olle |
280 |
} |
741 |
10 Oct 06 |
olle |
281 |
|
741 |
10 Oct 06 |
olle |
282 |
/** |
1652 |
22 May 07 |
gregory |
* This creates all necessary directories for Xerver at <CODE>s_installPath</CODE>. |
1652 |
22 May 07 |
gregory |
* <CODE>s_installPath</CODE> shall be "" if you want create the |
1652 |
22 May 07 |
gregory |
* directories in the "present working directory". |
1652 |
22 May 07 |
gregory |
286 |
*/ |
1652 |
22 May 07 |
gregory |
287 |
private void createFolders(String s_installPath) { |
1652 |
22 May 07 |
gregory |
288 |
(new File(s_installPath + hiddenFolder)).mkdir(); |
1652 |
22 May 07 |
gregory |
289 |
(new File(s_installPath + errorFilesFolder)).mkdir(); |
1652 |
22 May 07 |
gregory |
290 |
(new File(s_installPath + helpFilesFolder)).mkdir(); |
741 |
10 Oct 06 |
olle |
291 |
} |
741 |
10 Oct 06 |
olle |
292 |
|
741 |
10 Oct 06 |
olle |
293 |
/** |
1652 |
22 May 07 |
gregory |
* Moves all files located at <CODE>s_installPath</CODE> and listed in |
1652 |
22 May 07 |
gregory |
* <CODE>filesToHide</CODE> into a folder called <CODE>s_installPath</CODE>+<CODE>folder</CODE>. |
1652 |
22 May 07 |
gregory |
* <CODE>s_installPath</CODE> can, but must not, end with an \ or /. For |
1652 |
22 May 07 |
gregory |
* example: "C:\dir" works as well as "C:\dir\". <CODE>s_installPath</CODE> |
1652 |
22 May 07 |
gregory |
* might be "" if you want to use relative path's (relative from "present |
1652 |
22 May 07 |
gregory |
* working directory") in <CODE>folder</CODE> and <CODE>filesToHide</CODE>. |
1652 |
22 May 07 |
gregory |
300 |
*/ |
1652 |
22 May 07 |
gregory |
301 |
private void moveFiles(String folder, String[] filesToHide, |
1652 |
22 May 07 |
gregory |
302 |
String s_installPath) { |
1652 |
22 May 07 |
gregory |
303 |
if (s_installPath == null) |
1652 |
22 May 07 |
gregory |
304 |
s_installPath = ""; |
741 |
10 Oct 06 |
olle |
305 |
|
1652 |
22 May 07 |
gregory |
306 |
if (s_installPath != "" || (new File(s_installPath)).exists()) { |
1652 |
22 May 07 |
gregory |
307 |
s_installPath = (new File(s_installPath)).getPath() |
1652 |
22 May 07 |
gregory |
308 |
+ File.separator; |
1652 |
22 May 07 |
gregory |
309 |
for (int i = 0, filesToHideLength = filesToHide.length; i < filesToHideLength; i++) // Optimization... |
741 |
10 Oct 06 |
olle |
310 |
{ |
1652 |
22 May 07 |
gregory |
311 |
File theFile = new File(s_installPath + filesToHide[i]); |
1652 |
22 May 07 |
gregory |
312 |
if (theFile.exists() && theFile.isFile()) // Om filen man ska |
1652 |
22 May 07 |
gregory |
// flytta finns |
741 |
10 Oct 06 |
olle |
314 |
{ |
1652 |
22 May 07 |
gregory |
315 |
File theFileToReplace = new File(s_installPath + folder |
1652 |
22 May 07 |
gregory |
316 |
+ filesToHide[i]); |
1652 |
22 May 07 |
gregory |
317 |
if (theFileToReplace.exists() |
1652 |
22 May 07 |
gregory |
318 |
&& !filesToHide[i].toLowerCase().equals( |
1652 |
22 May 07 |
gregory |
319 |
"xerver.cfg")) // If a file already exists |
1652 |
22 May 07 |
gregory |
// (and if it isn't |
1652 |
22 May 07 |
gregory |
// "xerver.cfg"), remove |
1652 |
22 May 07 |
gregory |
// it... (so you don't have |
1652 |
22 May 07 |
gregory |
// to remove it manually |
1652 |
22 May 07 |
gregory |
// when you update Xerver; |
1652 |
22 May 07 |
gregory |
// However, do not replace |
1652 |
22 May 07 |
gregory |
// "Xerver.cfg", as it's a |
1652 |
22 May 07 |
gregory |
// data file) |
741 |
10 Oct 06 |
olle |
328 |
{ |
741 |
10 Oct 06 |
olle |
329 |
theFileToReplace.delete(); |
741 |
10 Oct 06 |
olle |
330 |
} |
1652 |
22 May 07 |
gregory |
331 |
theFile.renameTo(new File(s_installPath + folder |
1652 |
22 May 07 |
gregory |
332 |
+ filesToHide[i])); // Flytta filen |
741 |
10 Oct 06 |
olle |
333 |
} |
1652 |
22 May 07 |
gregory |
// else the file doesn't exists, which means that the |
1652 |
22 May 07 |
gregory |
// installation has already been done |
741 |
10 Oct 06 |
olle |
336 |
} |
741 |
10 Oct 06 |
olle |
337 |
} |
741 |
10 Oct 06 |
olle |
338 |
} |
741 |
10 Oct 06 |
olle |
339 |
} |