Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FilenameUtil |
|
| 2.5;2.5 |
1 | //////////////////////////////////////////////////////////////////////////////// | |
2 | // | |
3 | // ObjectLab is sponsoring QALab | |
4 | // | |
5 | // Based in London, we are world leaders in the design and development | |
6 | // of bespoke applications for the Securities Financing markets. | |
7 | // | |
8 | // <a href="http://www.objectlab.co.uk/open">Click here to learn more</a> | |
9 | // ___ _ _ _ _ _ | |
10 | // / _ \| |__ (_) ___ ___| |_| | __ _| |__ | |
11 | // | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \ | |
12 | // | |_| | |_) | | __/ (__| |_| |__| (_| | |_) | | |
13 | // \___/|_.__// |\___|\___|\__|_____\__,_|_.__/ | |
14 | // |__/ | |
15 | // | |
16 | // http://www.ObjectLab.co.uk | |
17 | // --------------------------------------------------------------------------- | |
18 | // | |
19 | //QALab is released under the GNU General Public License. | |
20 | // | |
21 | //QALab: Collects QA Statistics from your build over time. | |
22 | //2005+, ObjectLab Ltd | |
23 | // | |
24 | //This library is free software; you can redistribute it and/or | |
25 | //modify it under the terms of the GNU General Public | |
26 | //License as published by the Free Software Foundation; either | |
27 | //version 2.1 of the License, or (at your option) any later version. | |
28 | // | |
29 | //This library is distributed in the hope that it will be useful, | |
30 | //but WITHOUT ANY WARRANTY; without even the implied warranty of | |
31 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
32 | //General Public License for more details. | |
33 | // | |
34 | //You should have received a copy of the GNU General Public | |
35 | //License along with this library; if not, write to the Free Software | |
36 | //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
37 | // | |
38 | //////////////////////////////////////////////////////////////////////////////// | |
39 | package net.objectlab.qalab.util; | |
40 | ||
41 | ||
42 | /** | |
43 | * Utility class for file name manipulations. | |
44 | * | |
45 | * @author Dave Sag | |
46 | */ | |
47 | public final class FilenameUtil { | |
48 | /** | |
49 | * default constructor. | |
50 | */ | |
51 | 0 | private FilenameUtil() { |
52 | 0 | } |
53 | ||
54 | /** | |
55 | * Trims the supplied filename by forcing it to be a unix path and choping | |
56 | * off everything below the src directory. | |
57 | * | |
58 | * @param aFilename | |
59 | * The original absolute filename. | |
60 | * @param aSrcDir | |
61 | * the path to the src folder. | |
62 | * @return a trimmed file name suitable for display. | |
63 | */ | |
64 | public static String trimFilename(final String aFilename, final String aSrcDir) { | |
65 | // force path separators to be unix for display. | |
66 | 903 | String fn = aFilename.replace('\\', '/'); |
67 | 903 | if (aSrcDir != null && aSrcDir.length() > 0) { |
68 | 903 | final String sdir = aSrcDir.replace('\\', '/'); |
69 | ||
70 | 903 | final int startCutPoint = fn.indexOf(sdir); |
71 | ||
72 | 903 | if (startCutPoint >= 0) { |
73 | 750 | int cutpoint = startCutPoint + sdir.length(); |
74 | ||
75 | 750 | if (!sdir.endsWith("/")) { |
76 | // must skip the first "/" from the file name. | |
77 | 738 | cutpoint++; |
78 | } | |
79 | ||
80 | 750 | fn = fn.substring(cutpoint); |
81 | } | |
82 | } | |
83 | ||
84 | 903 | return fn; |
85 | } | |
86 | } | |
87 | /* | |
88 | * ObjectLab is sponsoring QALab | |
89 | * | |
90 | * Based in London, we are world leaders in the design and development | |
91 | * of bespoke applications for the securities financing markets. | |
92 | * | |
93 | * <a href="http://www.objectlab.co.uk/open">Click here to learn more about us</a> | |
94 | * ___ _ _ _ _ _ | |
95 | * / _ \| |__ (_) ___ ___| |_| | __ _| |__ | |
96 | * | | | | '_ \| |/ _ \/ __| __| | / _` | '_ \ | |
97 | * | |_| | |_) | | __/ (__| |_| |__| (_| | |_) | | |
98 | * \___/|_.__// |\___|\___|\__|_____\__,_|_.__/ | |
99 | * |__/ | |
100 | * | |
101 | * www.ObjectLab.co.uk | |
102 | */ |