This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 499b22b9e Deprecate unused method FileNameUtils.getBaseName(String)
499b22b9e is described below
commit 499b22b9e553e58d445e68a4787202e61d81ad3e
Author: Gary Gregory <[email protected]>
AuthorDate: Sat Jan 13 14:50:36 2024 -0500
Deprecate unused method FileNameUtils.getBaseName(String)
- Deprecate unused method FileNameUtils.getExtension(String)
---
src/changes/changes.xml | 2 ++
.../org/apache/commons/compress/utils/FileNameUtils.java | 15 ++++++---------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 58d9fc160..fded109b3 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -65,6 +65,8 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate
CRC32VerifyingInputStream.CRC32VerifyingInputStream(InputStream, long,
int).</action>
<action type="fix" issue="COMPRESS-655" dev="ggregory"
due-to="cpreisler, Gary Gregory">FramedSnappyCompressorOutputStream produces
incorrect output when writing a large buffer #457.</action>
<action type="fix" issue="COMPRESS-657" dev="ggregory" due-to="Sebastian
Schuberth, Gary Gregory">Fix TAR directory entries being misinterpreted as
files #460.</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate unused
method FileNameUtils.getBaseName(String).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">Deprecate unused
method FileNameUtils.getExtension(String).</action>
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Add
ZipFile.builder(), add ZipFile.Builder, deprecated constructors.</action>
<!-- UPDATE -->
diff --git a/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java
b/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java
index c107e89ed..b24959cd6 100644
--- a/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java
+++ b/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java
@@ -29,11 +29,6 @@ import org.apache.commons.io.FilenameUtils;
*/
public class FileNameUtils {
- private static String fileNameToBaseName(final String name) {
- final int extensionIndex = name.lastIndexOf('.');
- return extensionIndex < 0 ? name : name.substring(0, extensionIndex);
- }
-
/**
* Gets the base name (i.e. the part up to and not including the last ".")
of the last path segment of a file name.
* <p>
@@ -49,24 +44,25 @@ public class FileNameUtils {
return null;
}
final Path fileName = path.getFileName();
- return fileName != null ? fileNameToBaseName(fileName.toString()) :
null;
+ return fileName != null ?
FilenameUtils.removeExtension(fileName.toString()) : null;
}
/**
* Gets the base name (i.e. the part up to and not including the last ".")
of the last path segment of a file name.
- *
* <p>
* Will return the file name itself if it doesn't contain any dots. All
leading directories of the {@code file name} parameter are skipped.
* </p>
*
* @return the base name of file name
* @param fileName the name of the file to obtain the base name of.
+ * @deprecated No longer used, no replacement.
*/
+ @Deprecated
public static String getBaseName(final String fileName) {
if (fileName == null) {
return null;
}
- return fileNameToBaseName(new File(fileName).getName());
+ return FilenameUtils.removeExtension(new File(fileName).getName());
}
/**
@@ -90,7 +86,6 @@ public class FileNameUtils {
/**
* Gets the extension (i.e. the part after the last ".") of a file.
- *
* <p>
* Will return an empty string if the file name doesn't contain any dots.
Only the last segment of a the file name is consulted - i.e. all leading
* directories of the {@code fileName} parameter are skipped.
@@ -98,7 +93,9 @@ public class FileNameUtils {
*
* @return the extension of file name
* @param fileName the name of the file to obtain the extension of.
+ * @deprecated Use {@link FilenameUtils#getExtension(String)}.
*/
+ @Deprecated
public static String getExtension(final String fileName) {
return FilenameUtils.getExtension(fileName);
}