cwk_path_has_extension.md (1538B)
1 --- 2 title: cwk_path_has_extension 3 description: Determines whether the file path has an extension. 4 --- 5 6 _(since v1.0.0)_ 7 Determines whether the file path has an extension. 8 9 ## Description 10 ```c 11 bool cwk_path_has_extension(const char *path); 12 ``` 13 14 This function determines whether the submitted file path has an extension. This 15 will evaluate to true if the last segment of the path contains a dot. In order 16 to read more information about the extension see **[cwk_path_get_extension]({{ site.baseurl }}{% link reference/cwk_path_get_extension.md %})**. 17 18 ## Parameters 19 * **path**: The path which will be inspected. 20 21 ## Return Value 22 Returns ``true`` if the path has an extension or ``false`` otherwise. 23 24 ## Outcomes 25 26 | Path | Result | 27 |----------------------------|------------| 28 | ``/my/path.txt`` | ``true`` | 29 | ``/my/path`` | ``false`` | 30 | ``/my/.path`` | ``true`` | 31 | ``/my/path.`` | ``true`` | 32 | ``/my/path.abc.txt.tests`` | ``true`` | 33 34 ## Example 35 ```c 36 #include <cwalk.h> 37 #include <stdio.h> 38 #include <stddef.h> 39 #include <stdlib.h> 40 41 int main(int argc, char *argv[]) 42 { 43 if (cwk_path_has_extension("/my/path.txt")) { 44 printf("yes."); 45 } else { 46 printf("no."); 47 } 48 49 return EXIT_SUCCESS; 50 } 51 ``` 52 53 Ouput: 54 ``` 55 yes. 56 ``` 57 58 ## Changelog 59 60 | Version | Description | 61 |------------|--------------------------------------------------------| 62 | **v1.0.0** | The function is introduced. |