Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apiCount.include.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**API count: 897**
**API count: 892**

### Per Target Framework

Expand Down
1 change: 1 addition & 0 deletions api_list.include.md
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@
* `string GetRelativePath(string, string)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getrelativepath?view=net-11.0)
* `bool HasExtension(ReadOnlySpan<char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilenamewithoutextension?view=net-11.0#system-io-path-getfilenamewithoutextension(system-readonlyspan((system-char))))
* `bool IsPathRooted(ReadOnlySpan<char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.ispathrooted?view=net-11.0#system-io-path-ispathrooted(system-readonlyspan((system-char))))
* `string Join(string?[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.join?view=net-11.0#system-io-path-join(system-string()))
* `ReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.trimendingdirectoryseparator?view=net-11.0#system-io-path-trimendingdirectoryseparator(system-readonlyspan((system-char))))
* `string TrimEndingDirectorySeparator(string)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.trimendingdirectoryseparator?view=net-11.0#system-io-path-trimendingdirectoryseparator(system-string))

Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ The class `Polyfill` includes the following extension methods:
* `string GetRelativePath(string, string)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getrelativepath?view=net-11.0)
* `bool HasExtension(ReadOnlySpan<char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.getfilenamewithoutextension?view=net-11.0#system-io-path-getfilenamewithoutextension(system-readonlyspan((system-char))))
* `bool IsPathRooted(ReadOnlySpan<char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.ispathrooted?view=net-11.0#system-io-path-ispathrooted(system-readonlyspan((system-char))))
* `string Join(string?[])` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.join?view=net-11.0#system-io-path-join(system-string()))
* `ReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char>)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.trimendingdirectoryseparator?view=net-11.0#system-io-path-trimendingdirectoryseparator(system-readonlyspan((system-char))))
* `string TrimEndingDirectorySeparator(string)` [reference](https://learn.microsoft.com/en-us/dotnet/api/system.io.path.trimendingdirectoryseparator?view=net-11.0#system-io-path-trimendingdirectoryseparator(system-string))

Expand Down
1 change: 1 addition & 0 deletions src/Consume/Consume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,7 @@ void Stopwatch_Methods()
void Path_Methods()
{
var relative = Path.GetRelativePath("/folder1/folder2", "/folder1/folder3");
var joined = Path.Join("a", "b", "c");
#if FeatureMemory
var rooted = Path.IsPathRooted("/root".AsSpan());
#endif
Expand Down
33 changes: 33 additions & 0 deletions src/Polyfill/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,39 @@ public static string TrimEndingDirectorySeparator(string path)

return path;
}

/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
//Link: https://learn.microsoft.com/en-us/dotnet/api/system.io.path.join?view=net-11.0#system-io-path-join(system-string())
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}

var builder = new System.Text.StringBuilder();

foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}

if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}

builder.Append(path);
}

return builder.ToString();
}
#endif
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
Expand Down
26 changes: 26 additions & 0 deletions src/Split/net461/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/net462/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/net47/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/net471/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/net472/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/net48/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/net481/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/netcoreapp2.0/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/netcoreapp2.1/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
26 changes: 26 additions & 0 deletions src/Split/netcoreapp2.2/PathPolyfill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,32 @@ public static string TrimEndingDirectorySeparator(string path)
}
return path;
}
/// <summary>
/// Concatenates a span of paths into a single path.
/// </summary>
public static string Join(params string?[] paths)
{
if (paths.Length == 0)
{
return string.Empty;
}
var builder = new System.Text.StringBuilder();
foreach (var path in paths)
{
if (string.IsNullOrEmpty(path))
{
continue;
}
if (builder.Length > 0 &&
!IsDirectorySeparator(builder[builder.Length - 1]) &&
!IsDirectorySeparator(path![0]))
{
builder.Append(Path.DirectorySeparatorChar);
}
builder.Append(path);
}
return builder.ToString();
}
static bool IsRoot(string path) =>
Path.IsPathRooted(path) && Path.GetDirectoryName(path) == null;
static bool IsDirectorySeparator(char c) =>
Expand Down
Loading
Loading