litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package org.litesoft.servlet;
import java.io.*;
public class WebInfLocator
{
public static String getLocationAnchorPath( Object pForClassLoader ) // e.g.: file:/C:/zDev/litesoft/GWT_Sandbox/UIdesign/war/WEB-INF/lib/LocationAnchor.jar
{
try
{
Class<?> zClass = pForClassLoader.getClass().getClassLoader().loadClass( "org.litesoft.locationanchor.LocationAnchor" );
return zClass.newInstance().toString();
}
catch ( Exception e )
{
e.printStackTrace();
return null;
}
}
public static File extractDir( String pLocationAnchorPath ) // e.g.: file:/C:/zDev/litesoft/GWT_Sandbox/UIdesign/war/WEB-INF/lib/LocationAnchor.jar
{ // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .01234
if ( pLocationAnchorPath == null )
{
System.out.println( "WebInfLocator.extractDir: No Path?" );
return null;
}
int at = pLocationAnchorPath.indexOf( "/WEB-INF/" ); // . . . . . . . . . . . . . . . . .0123456
if ( (at <= 6) /* . . . . . . . . .. . 012345678 */ || !pLocationAnchorPath.startsWith( "file:/" ) )
{
System.out.println( "WebInfLocator.extractDir: Path? '" + pLocationAnchorPath + "'" );
return null;
}
String zPath = pLocationAnchorPath.substring( 5, at + 8 );
if ( Character.isLetter( zPath.charAt( 1 ) ) && ":/".equals( zPath.substring( 2, 4 ) ) ) // Stupid Windows
{
zPath = zPath.substring( 1 ); // Drop the leading slash, leaving the start as the drive reference
}
File zDir = new File( zPath );
if ( !zDir.isDirectory() )
{
System.out.println( "WebInfLocator.extractDir, Not a Directory: " + zDir.getPath() );
return null;
}
try
{
return zDir.getCanonicalFile();
}
catch ( IOException e )
{
System.out.println( "WebInfLocator.extractDirr, Could not Canonicalize: " + zDir.getPath() );
return null;
}
}
public static File getDir( Object pForClassLoader )
{
return extractDir( getLocationAnchorPath( pForClassLoader ) );
}
}
|
Revision |
Author |
Commited |
Message |
466
|
GeorgeS
|
Thu 25 Aug, 2011 12:47:41 +0000 |
|