[Arakhnę-Dev] [271] * Ensure that the '.' character is present when FileSystem is adding or replacing an filename extension . |
[ Thread Index |
Date Index
| More arakhne.org/dev Archives
]
- To: dev@xxxxxxxxxxx
- Subject: [Arakhnę-Dev] [271] * Ensure that the '.' character is present when FileSystem is adding or replacing an filename extension .
- From: subversion@xxxxxxxxxxxxx
- Date: Tue, 23 Aug 2011 19:17:38 +0200
Revision: 271
Author: galland
Date: 2011-08-23 19:17:38 +0200 (Tue, 23 Aug 2011)
Log Message:
-----------
* Ensure that the '.' character is present when FileSystem is adding or replacing an filename extension.
Modified Paths:
--------------
trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2011-08-22 13:58:16 UTC (rev 270)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java 2011-08-23 17:17:38 UTC (rev 271)
@@ -976,7 +976,10 @@
else {
buf.append(largeBasename.substring(0, idx));
}
- buf.append(extension);
+ String extent = extension;
+ if (!"".equals(extent) && !extent.startsWith(EXTENSION_SEPARATOR)) //$NON-NLS-1$
+ extent = EXTENSION_SEPARATOR+extent;
+ buf.append(extent);
try {
if (isJarURL(filename)) {
return new URL(
@@ -1026,7 +1029,10 @@
*/
public static File addExtension(File filename, String extension) {
if (filename!=null && !hasExtension(filename, extension)) {
- return new File(filename.getParentFile(), filename.getName()+extension);
+ String extent = extension;
+ if (!"".equals(extent) && !extent.startsWith(EXTENSION_SEPARATOR)) //$NON-NLS-1$
+ extent = EXTENSION_SEPARATOR+extent;
+ return new File(filename.getParentFile(), filename.getName()+extent);
}
return filename;
}
@@ -1044,7 +1050,10 @@
if (filename!=null && !hasExtension(filename, extension)) {
String basename = largeBasename(filename);
URL dirname = dirname(filename);
- return join(dirname, basename+extension);
+ String extent = extension;
+ if (!"".equals(extent) && !extent.startsWith(EXTENSION_SEPARATOR)) //$NON-NLS-1$
+ extent = EXTENSION_SEPARATOR+extent;
+ return join(dirname, basename+extent);
}
return filename;
}