converted line endings to unix

This commit is contained in:
Leonard Iklé committed 2023-05-08 09:35:38 +02:00
1 parent 2434a7a719
commit cfe8282fce
35 files changed
+6398 -6398

No files matched your search

+5 -5
View File
@@ -1,6 +1,6 @@
defaults:
-
scope:
path: "" # an empty string here means all files in the project
values:
defaults:
-
scope:
path: "" # an empty string here means all files in the project
values:
layout: "default"
+42 -42
View File
@@ -1,42 +1,42 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{ page.title }} - cwalk</title>
<meta name="description" content="{{ page.description }}" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Mono" rel="stylesheet">
<link href="{{ site.baseurl }}/assets/css/default.css?v4" rel="stylesheet" type="text/css">
<link href="{{ site.baseurl }}/assets/css/monakai.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="{{ site.baseurl }}/assets/img/favicon.png">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-127837944-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-127837944-1');
</script>
</head>
<body>
<header>
<div class="inner">
<a href="{{ site.baseurl }}{% link index.md %}" class="logo">cwalk</a>
<nav>
<a href="{{ site.baseurl }}{% link build.md %}">build</a>
<a href="{{ site.baseurl }}{% link embed.md %}">embed</a>
<a href="{{ site.baseurl }}{% link reference/index.md %}">reference</a>
</nav>
</div>
</header>
<div class="main">
<div class="content">
<h1>{{ page.title }}</h1>
{{ content }}
</div>
</div>
</body>
<footer>
find this repository on <a href="https://github.com/likle/cwalk/tree/master">github</a>
</footer>
</html>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>{{ page.title }} - cwalk</title>
<meta name="description" content="{{ page.description }}" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Ubuntu+Mono" rel="stylesheet">
<link href="{{ site.baseurl }}/assets/css/default.css?v4" rel="stylesheet" type="text/css">
<link href="{{ site.baseurl }}/assets/css/monakai.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="{{ site.baseurl }}/assets/img/favicon.png">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-127837944-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-127837944-1');
</script>
</head>
<body>
<header>
<div class="inner">
<a href="{{ site.baseurl }}{% link index.md %}" class="logo">cwalk</a>
<nav>
<a href="{{ site.baseurl }}{% link build.md %}">build</a>
<a href="{{ site.baseurl }}{% link embed.md %}">embed</a>
<a href="{{ site.baseurl }}{% link reference/index.md %}">reference</a>
</nav>
</div>
</header>
<div class="main">
<div class="content">
<h1>{{ page.title }}</h1>
{{ content }}
</div>
</div>
</body>
<footer>
find this repository on <a href="https://github.com/likle/cwalk/tree/master">github</a>
</footer>
</html>
+126 -126
View File
@@ -1,126 +1,126 @@
html,
body {
height: 100%;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
margin: auto;
padding: 20px;
background: #FAFAFA;
padding: 0;
display: flex;
flex-flow: column;
}
header {
text-align: right;
margin-bottom: 20px;
padding: 20px 20px;
font-family: 'Ubuntu Mono';
background: #55FF99;
color: #D5FFE6;
border-bottom: 10px solid #37C871;
}
header .inner {
max-width: 800px;
margin: auto;
}
header .logo {
float: left;
vertical-align: middle;
display: inline-block;
font-weight: bold;
font-size: 32pt;
padding: 0;
margin-left: 10px;
line-height: 50px;
}
header nav {
line-height: 50px;
}
header a {
padding: 10px;
text-decoration: none;
font-weight: bold;
font-size: 18pt;
overflow: auto;
color: #078e3d;;
}
.main {
flex: 1;
}
footer {
text-align: center;
margin-top: 50px;
padding: 40px 20px;
font-family: 'Ubuntu Mono';
background: #49483e;
color: #e6db74;
}
a {
color: #37C871;
}
h1, h2 {
font-family: 'Ubuntu Mono';
padding-bottom: 5px;
border-bottom: 1px solid rgba(255,255,255,.2);
}
.content {
color: #49483e;
padding-top: 20px;
max-width: 800px;
margin: auto;
}
.highlight {
padding: 10px;
margin: 0;
overflow: auto;
white-space: pre-wrap;
}
.highlighter-rouge {
background: rgba(0,0,0,0.1);
}
table {
border-collapse: collapse;
}
table td,
table th {
border: 1px solid #DDDDDD;
background: #ffffff;
padding: 5px 8px;
}
table tr:nth-child(even) td {
background: #f8f9fb;
}
@media (max-width: 1000px) {
header {
text-align: center;
}
header .logo {
display: block;
float: none;
margin-bottom: 10px;
}
.content {
padding: 0 20px;
}
}
html,
body {
height: 100%;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
margin: auto;
padding: 20px;
background: #FAFAFA;
padding: 0;
display: flex;
flex-flow: column;
}
header {
text-align: right;
margin-bottom: 20px;
padding: 20px 20px;
font-family: 'Ubuntu Mono';
background: #55FF99;
color: #D5FFE6;
border-bottom: 10px solid #37C871;
}
header .inner {
max-width: 800px;
margin: auto;
}
header .logo {
float: left;
vertical-align: middle;
display: inline-block;
font-weight: bold;
font-size: 32pt;
padding: 0;
margin-left: 10px;
line-height: 50px;
}
header nav {
line-height: 50px;
}
header a {
padding: 10px;
text-decoration: none;
font-weight: bold;
font-size: 18pt;
overflow: auto;
color: #078e3d;;
}
.main {
flex: 1;
}
footer {
text-align: center;
margin-top: 50px;
padding: 40px 20px;
font-family: 'Ubuntu Mono';
background: #49483e;
color: #e6db74;
}
a {
color: #37C871;
}
h1, h2 {
font-family: 'Ubuntu Mono';
padding-bottom: 5px;
border-bottom: 1px solid rgba(255,255,255,.2);
}
.content {
color: #49483e;
padding-top: 20px;
max-width: 800px;
margin: auto;
}
.highlight {
padding: 10px;
margin: 0;
overflow: auto;
white-space: pre-wrap;
}
.highlighter-rouge {
background: rgba(0,0,0,0.1);
}
table {
border-collapse: collapse;
}
table td,
table th {
border: 1px solid #DDDDDD;
background: #ffffff;
padding: 5px 8px;
}
table tr:nth-child(even) td {
background: #f8f9fb;
}
@media (max-width: 1000px) {
header {
text-align: center;
}
header .logo {
display: block;
float: none;
margin-bottom: 10px;
}
.content {
padding: 0 20px;
}
}
+68 -68
View File
@@ -1,69 +1,69 @@
---
title: cwk_path_change_basename
description: Changes the basename of a file path.
---
_(since v1.2.0)_
Changes the basename of a file path.
## Description
```c
size_t cwk_path_change_basename(const char *path, const char *new_basename,
char *buffer, size_t buffer_size);
```
This function changes the basename of a file path. This function will not
write out more than the specified buffer can contain. However, the generated
string is always null-terminated - even if not the whole path is written out.
The function returns the total number of characters the complete buffer would
have, even if it was not written out completely. The path may be the same
memory address as the buffer.
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so. Separators before and after the submitted basename will be trimmed,
but not removed from the source path. The value may contain separators which
will introduce new segments. If the submitted path does not have any segments,
the basename will be appended as a new segment.
## Parameters
* **path**: The original path which will be used for the modified path.
* **new_basename**: The new basename which will replace the old one.
* **buffer**: The buffer where the changed path will be written to.
* **buffer_size**: The size of the result buffer where the changed path is written to.
## Return Value
Returns the size which the complete new path would have if it was not truncated.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[FILENAME_MAX];
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_change_basename("C:\\test.txt", "another.txt", buffer,
sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: 'C:\another.txt'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
---
title: cwk_path_change_basename
description: Changes the basename of a file path.
---
_(since v1.2.0)_
Changes the basename of a file path.
## Description
```c
size_t cwk_path_change_basename(const char *path, const char *new_basename,
char *buffer, size_t buffer_size);
```
This function changes the basename of a file path. This function will not
write out more than the specified buffer can contain. However, the generated
string is always null-terminated - even if not the whole path is written out.
The function returns the total number of characters the complete buffer would
have, even if it was not written out completely. The path may be the same
memory address as the buffer.
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so. Separators before and after the submitted basename will be trimmed,
but not removed from the source path. The value may contain separators which
will introduce new segments. If the submitted path does not have any segments,
the basename will be appended as a new segment.
## Parameters
* **path**: The original path which will be used for the modified path.
* **new_basename**: The new basename which will replace the old one.
* **buffer**: The buffer where the changed path will be written to.
* **buffer_size**: The size of the result buffer where the changed path is written to.
## Return Value
Returns the size which the complete new path would have if it was not truncated.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[FILENAME_MAX];
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_change_basename("C:\\test.txt", "another.txt", buffer,
sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: 'C:\another.txt'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.0** | The function is introduced. |
+71 -71
View File
@@ -1,71 +1,71 @@
---
title: cwk_path_change_extension
description: Changes the extension of a file path.
---
_(since v1.2.0)_
Changes the extension of a file path.
## Description
```c
size_t cwk_path_change_extension(const char *path, const char *new_extension,
char *buffer, size_t buffer_size);
```
This function changes the extension of a file name. The function will append
an extension if the basename does not have an extension, or use the extension
as a basename if the path does not have a basename. This function will not
write out more than the specified buffer can contain. However, the generated
string is always null-terminated - even if not the whole path is written out.
The function returns the total number of characters the complete buffer would
have, even if it was not written out completely. The path may be the same
memory address as the buffer.
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so.
**Note:** If the ``new_extension`` parameter starts with a dot, the first dot will
be ignored when the new extension is appended.
## Parameters
* **path**: The path which will be used to make the change.
* **new_extension**: The extension which will be placed within the new path.
* **buffer**: The output buffer where the result will be written to.
* **buffer_size**: The size of the output buffer where the result will be written to.
## Return Value
Returns the total size which the output would have if it was not truncated.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[FILENAME_MAX];
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_change_extension("C:\\test.txt", "md", buffer,
sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: 'C:\test.md'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.0** | The function is introduced. |
---
title: cwk_path_change_extension
description: Changes the extension of a file path.
---
_(since v1.2.0)_
Changes the extension of a file path.
## Description
```c
size_t cwk_path_change_extension(const char *path, const char *new_extension,
char *buffer, size_t buffer_size);
```
This function changes the extension of a file name. The function will append
an extension if the basename does not have an extension, or use the extension
as a basename if the path does not have a basename. This function will not
write out more than the specified buffer can contain. However, the generated
string is always null-terminated - even if not the whole path is written out.
The function returns the total number of characters the complete buffer would
have, even if it was not written out completely. The path may be the same
memory address as the buffer.
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so.
**Note:** If the ``new_extension`` parameter starts with a dot, the first dot will
be ignored when the new extension is appended.
## Parameters
* **path**: The path which will be used to make the change.
* **new_extension**: The extension which will be placed within the new path.
* **buffer**: The output buffer where the result will be written to.
* **buffer_size**: The size of the output buffer where the result will be written to.
## Return Value
Returns the total size which the output would have if it was not truncated.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[FILENAME_MAX];
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_change_extension("C:\\test.txt", "md", buffer,
sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: 'C:\test.md'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.0** | The function is introduced. |
+68 -68
View File
@@ -1,69 +1,69 @@
---
title: cwk_path_change_root
description: Changes the root of a path.
---
_(since v1.2.0)_
Changes the root of a path.
## Description
```c
size_t cwk_path_change_root(const char *path, const char *new_root,
char *buffer, size_t buffer_size);
```
This function changes the root of a path. It does not normalize the result.
The result will be written to a buffer, which might be truncated if the
buffer is not large enough to hold the full path. However, the truncated
result will always be null-terminated. The returned value is the amount of
characters which the resulting path would take if it was not truncated
(excluding the null-terminating character).
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so. The new root may contain separators which will introduce new segments.
If the submitted path does not have any root, the new root will be prepended to
the path.
## Parameters
* **path**: The original path which will get a new root.
* **new_root**: The new root which will be placed in the path.
* **buffer**: The output buffer where the result is written to.
* **buffer_size**: The size of the output buffer where the result is written
to.
## Return Value
Returns the total amount of characters of the new path.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[FILENAME_MAX];
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_change_root("C:\\test.txt", "D:\\", buffer,
sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: 'D:\another.txt'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
---
title: cwk_path_change_root
description: Changes the root of a path.
---
_(since v1.2.0)_
Changes the root of a path.
## Description
```c
size_t cwk_path_change_root(const char *path, const char *new_root,
char *buffer, size_t buffer_size);
```
This function changes the root of a path. It does not normalize the result.
The result will be written to a buffer, which might be truncated if the
buffer is not large enough to hold the full path. However, the truncated
result will always be null-terminated. The returned value is the amount of
characters which the resulting path would take if it was not truncated
(excluding the null-terminating character).
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so. The new root may contain separators which will introduce new segments.
If the submitted path does not have any root, the new root will be prepended to
the path.
## Parameters
* **path**: The original path which will get a new root.
* **new_root**: The new root which will be placed in the path.
* **buffer**: The output buffer where the result is written to.
* **buffer_size**: The size of the output buffer where the result is written
to.
## Return Value
Returns the total amount of characters of the new path.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char buffer[FILENAME_MAX];
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_change_root("C:\\test.txt", "D:\\", buffer,
sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: 'D:\another.txt'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.0** | The function is introduced. |
+72 -72
View File
@@ -1,72 +1,72 @@
---
title: cwk_path_change_segment
description: Changes the content of a segment.
---
_(since v1.2.0)_
Changes the content of a segment.
## Description
```c
size_t cwk_path_change_segment(struct cwk_segment *segment, const char *value,
char *buffer, size_t buffer_size);
```
This function overrides the content of a segment to the submitted value and
outputs the whole new path to the submitted buffer. The result might require
less or more space than before if the new value length differs from the
original length. The output is truncated if the new path is larger than the
submitted buffer size, but it is always null-terminated. The source of the
segment and the submitted buffer may be the same.
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so. Separators before and after the value will be trimmed. The value may
contain separators which will introduce new segments.
## Parameters
* **segment**: The segment which will be modifier.
* **value**: The new content of the segment.
* **buffer**: The buffer where the modified path will be written to.
* **buffer_size**: The size of the output buffer.
## Return Value
Returns the total size which would have been written if the output was not
truncated.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
const char *path;
char buffer[FILENAME_MAX];
struct cwk_segment segment;
path = "/this/cool/path/";
if (!cwk_path_get_first_segment(path, &segment)) {
return EXIT_FAILURE;
}
cwk_path_change_segment(&segment, "other", buffer, sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: '/other/cool/path/'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.0** | The function is introduced. |
---
title: cwk_path_change_segment
description: Changes the content of a segment.
---
_(since v1.2.0)_
Changes the content of a segment.
## Description
```c
size_t cwk_path_change_segment(struct cwk_segment *segment, const char *value,
char *buffer, size_t buffer_size);
```
This function overrides the content of a segment to the submitted value and
outputs the whole new path to the submitted buffer. The result might require
less or more space than before if the new value length differs from the
original length. The output is truncated if the new path is larger than the
submitted buffer size, but it is always null-terminated. The source of the
segment and the submitted buffer may be the same.
**Note:** This function does not normalize the resulting path. You can use
**[cwk_path_normalize]({{ site.baseurl }}{% link reference/cwk_path_normalize.md %})**
to do so. Separators before and after the value will be trimmed. The value may
contain separators which will introduce new segments.
## Parameters
* **segment**: The segment which will be modifier.
* **value**: The new content of the segment.
* **buffer**: The buffer where the modified path will be written to.
* **buffer_size**: The size of the output buffer.
## Return Value
Returns the total size which would have been written if the output was not
truncated.
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
const char *path;
char buffer[FILENAME_MAX];
struct cwk_segment segment;
path = "/this/cool/path/";
if (!cwk_path_get_first_segment(path, &segment)) {
return EXIT_FAILURE;
}
cwk_path_change_segment(&segment, "other", buffer, sizeof(buffer));
printf("The new path: '%s'", buffer);
return EXIT_SUCCESS;
}
```
Ouput:
```
The new path: '/other/cool/path/'
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.0** | The function is introduced. |
+78 -78
View File
@@ -1,78 +1,78 @@
---
title: cwk_path_guess_style
description: Guesses the path style.
---
_(since v1.2.0)_
Guesses the path style.
## Description
```c
enum cwk_path_style cwk_path_guess_style(const char *path);
```
This function guesses the path style based on a submitted path-string. The guessing will look at the root and the type of slashes contained in the path and return the style which is more likely used in the path.
The algorithm checks the following:
1. If the root is longer than 1 character -> ``CWK_STYLE_WINDOWS``
1. If the first separator is a backslash -> ``CWK_STYLE_WINDOWS``
1. If the first separator is a slash -> ``CWK_STYLE_UNIX``
1. If the last segment starts with a dot -> ``CWK_STYLE_UNIX``
1. If the last segment contains a dot -> ``CWK_STYLE_WINDOWS``
1. If nothing was found to determine the style -> ``CWK_STYLE_UNIX``
## Parameters
* **path**: The path which will be inspected.
## Return Value
Returns the style which is most likely used for the path.
## Outcomes
| Path | Result |
|-----------------------------|-----------------------|
| ``C:\\test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:/test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:/.test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:/folder/.test`` | ``CWK_STYLE_WINDOWS`` |
| ``\directory\other`` | ``CWK_STYLE_WINDOWS`` |
| ``\directory\.other`` | ``CWK_STYLE_WINDOWS`` |
| ``myfile.txt`` | ``CWK_STYLE_WINDOWS`` |
| ``/directory`` | ``CWK_STYLE_UNIX`` |
| ``/directory/other`` | ``CWK_STYLE_UNIX`` |
| ``/directory/other.txt`` | ``CWK_STYLE_UNIX`` |
| ``.my_hidden_file`` | ``CWK_STYLE_UNIX`` |
| ``.my_hidden_file.txt`` | ``CWK_STYLE_UNIX`` |
| ``/a/directory/myfile.txt`` | ``CWK_STYLE_UNIX`` |
| ``myfile`` | ``CWK_STYLE_UNIX`` |
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (cwk_path_guess_style("C:\\myfile") == CWK_STYLE_UNIX) {
printf("UNIX.");
} else {
printf("WINDOWS.");
}
return EXIT_SUCCESS;
}
```
Ouput:
```
WINDOWS.
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.1** | Fixed crash on call with empty string. |
| **v1.2.0** | The function is introduced. |
---
title: cwk_path_guess_style
description: Guesses the path style.
---
_(since v1.2.0)_
Guesses the path style.
## Description
```c
enum cwk_path_style cwk_path_guess_style(const char *path);
```
This function guesses the path style based on a submitted path-string. The guessing will look at the root and the type of slashes contained in the path and return the style which is more likely used in the path.
The algorithm checks the following:
1. If the root is longer than 1 character -> ``CWK_STYLE_WINDOWS``
1. If the first separator is a backslash -> ``CWK_STYLE_WINDOWS``
1. If the first separator is a slash -> ``CWK_STYLE_UNIX``
1. If the last segment starts with a dot -> ``CWK_STYLE_UNIX``
1. If the last segment contains a dot -> ``CWK_STYLE_WINDOWS``
1. If nothing was found to determine the style -> ``CWK_STYLE_UNIX``
## Parameters
* **path**: The path which will be inspected.
## Return Value
Returns the style which is most likely used for the path.
## Outcomes
| Path | Result |
|-----------------------------|-----------------------|
| ``C:\\test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:/test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:/.test`` | ``CWK_STYLE_WINDOWS`` |
| ``C:/folder/.test`` | ``CWK_STYLE_WINDOWS`` |
| ``\directory\other`` | ``CWK_STYLE_WINDOWS`` |
| ``\directory\.other`` | ``CWK_STYLE_WINDOWS`` |
| ``myfile.txt`` | ``CWK_STYLE_WINDOWS`` |
| ``/directory`` | ``CWK_STYLE_UNIX`` |
| ``/directory/other`` | ``CWK_STYLE_UNIX`` |
| ``/directory/other.txt`` | ``CWK_STYLE_UNIX`` |
| ``.my_hidden_file`` | ``CWK_STYLE_UNIX`` |
| ``.my_hidden_file.txt`` | ``CWK_STYLE_UNIX`` |
| ``/a/directory/myfile.txt`` | ``CWK_STYLE_UNIX`` |
| ``myfile`` | ``CWK_STYLE_UNIX`` |
## Example
```c
#include <cwalk.h>
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (cwk_path_guess_style("C:\\myfile") == CWK_STYLE_UNIX) {
printf("UNIX.");
} else {
printf("WINDOWS.");
}
return EXIT_SUCCESS;
}
```
Ouput:
```
WINDOWS.
```
## Changelog
| Version | Description |
|------------|--------------------------------------------------------|
| **v1.2.1** | Fixed crash on call with empty string. |
| **v1.2.0** | The function is introduced. |