diff options
author | Clyhtsuriva <61652557+clyhtsuriva@users.noreply.github.com> | 2021-06-27 13:45:55 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-27 13:45:55 +0000 |
commit | 51ee4fe5f80e6dc6d9a25c4e95f53c8c122a9434 (patch) | |
tree | 9695b8cbd65fa1e914b30597b64c79e484cacdcd /target/site/jacoco/musichub.util/PathValidation.java.html | |
parent | e13eea333d7af2786dbbbb5ed60cea4593d5ee12 (diff) | |
parent | f5117515ab26658e93d9efc2d99651c332840782 (diff) |
Merge pull request #11 from Said-Belhadj/feature/STZ-0010
STZ-0010 : Extension check
Diffstat (limited to 'target/site/jacoco/musichub.util/PathValidation.java.html')
-rw-r--r-- | target/site/jacoco/musichub.util/PathValidation.java.html | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/target/site/jacoco/musichub.util/PathValidation.java.html b/target/site/jacoco/musichub.util/PathValidation.java.html index 7cb31d4..7518e59 100644 --- a/target/site/jacoco/musichub.util/PathValidation.java.html +++ b/target/site/jacoco/musichub.util/PathValidation.java.html @@ -25,15 +25,25 @@ public final class PathValidation { } /** - * Method that checks the validity of a given path + * Method that checks the validity of a given path and file. * * @param inputPath the path given by the user * @return a boolean */ public static boolean isPathValid(String inputPath) { -<span class="fc" id="L35"> Path path = Paths.get(inputPath);</span> -<span class="fc" id="L36"> return Files.exists(path);</span> +<span class="fc" id="L35"> boolean isExtensionValid=false;</span> + +<span class="fc" id="L37"> int index = inputPath.lastIndexOf('.');</span> +<span class="fc bfc" id="L38" title="All 2 branches covered."> if(index > 0) {</span> +<span class="fc" id="L39"> String extension = inputPath.substring(index + 1);</span> +<span class="fc bfc" id="L40" title="All 2 branches covered."> if (extension.equals("wav")){</span> +<span class="fc" id="L41"> isExtensionValid=true;</span> + } + } + +<span class="fc" id="L45"> Path path = Paths.get(inputPath);</span> +<span class="fc" id="L46"> return (Files.exists(path) & isExtensionValid);</span> } } |