2013-01-07 23:24:29 +03:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using Umbraco.Core.CodeAnnotations;
|
2012-08-20 10:46:32 -01:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.IO
|
|
|
|
|
|
{
|
2012-11-08 08:27:38 +05:00
|
|
|
|
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
|
|
|
|
|
|
public static class FileSystemExtensions
|
2012-08-20 10:46:32 -01:00
|
|
|
|
{
|
2013-01-07 23:24:29 +03:00
|
|
|
|
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
|
2013-01-02 14:28:15 -01:00
|
|
|
|
internal static long GetSize(this IFileSystem fs, string path)
|
2012-08-20 10:46:32 -01:00
|
|
|
|
{
|
2013-08-23 11:46:55 +10:00
|
|
|
|
using (var s = fs.OpenFile(path))
|
|
|
|
|
|
{
|
|
|
|
|
|
var size = s.Length;
|
|
|
|
|
|
s.Close();
|
2012-08-20 10:46:32 -01:00
|
|
|
|
|
2013-08-23 11:46:55 +10:00
|
|
|
|
return size;
|
|
|
|
|
|
}
|
2012-08-20 10:46:32 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-01-07 23:24:29 +03:00
|
|
|
|
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
|
2013-01-02 14:28:15 -01:00
|
|
|
|
internal static void CopyFile(this IFileSystem fs, string path, string newPath)
|
2012-08-20 10:46:32 -01:00
|
|
|
|
{
|
2012-08-20 11:42:18 -01:00
|
|
|
|
fs.AddFile(newPath, fs.OpenFile(path));
|
2012-08-20 10:46:32 -01:00
|
|
|
|
}
|
2013-01-07 23:24:29 +03:00
|
|
|
|
|
|
|
|
|
|
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
|
|
|
|
|
|
internal static string GetExtension(this IFileSystem fs, string path)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Path.GetExtension(fs.GetFullPath(path));
|
|
|
|
|
|
}
|
2013-01-08 00:58:22 +03:00
|
|
|
|
|
|
|
|
|
|
[UmbracoExperimentalFeature("http://issues.umbraco.org/issue/U4-1156", "Will be declared public after 4.10")]
|
|
|
|
|
|
internal static string GetFileName(this IFileSystem fs, string path)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Path.GetFileName(fs.GetFullPath(path));
|
|
|
|
|
|
}
|
2012-08-20 10:46:32 -01:00
|
|
|
|
}
|
|
|
|
|
|
}
|