mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-12 05:14:10 +02:00
Add Path.ChangeExtension
This commit is contained in:
parent
f77ccb8994
commit
dcd9bc35ac
1 changed files with 28 additions and 0 deletions
|
@ -54,6 +54,34 @@ namespace System.IO
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ChangeExtension(StringView path, StringView ext, String outPath)
|
||||||
|
{
|
||||||
|
if (path.IsNull)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CheckInvalidPathChars(path);
|
||||||
|
|
||||||
|
outPath.Set(path);
|
||||||
|
for (int i = path.Length; --i >= 0;)
|
||||||
|
{
|
||||||
|
let ch = path[i];
|
||||||
|
if (ch == '.')
|
||||||
|
{
|
||||||
|
outPath.Set(path.Substring(0, i));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ch == DirectorySeparatorChar || ch == AltDirectorySeparatorChar || ch == VolumeSeparatorChar) break;
|
||||||
|
}
|
||||||
|
if (!ext.IsNull && path.Length != 0)
|
||||||
|
{
|
||||||
|
if (ext.IsEmpty || ext[0] != '.')
|
||||||
|
{
|
||||||
|
outPath.Append('.');
|
||||||
|
}
|
||||||
|
outPath.Append(ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void GetFileName(StringView inPath, String outFileName)
|
public static void GetFileName(StringView inPath, String outFileName)
|
||||||
{
|
{
|
||||||
if (inPath.IsEmpty)
|
if (inPath.IsEmpty)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue