-
Notifications
You must be signed in to change notification settings - Fork 3
/
AzureBlobFileSystemEntry.cs
77 lines (70 loc) · 2.21 KB
/
AzureBlobFileSystemEntry.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using FubarDev.FtpServer.FileSystem;
using FubarDev.FtpServer.FileSystem.Generic;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdamHurwitz.FtpServer.FileSystem.AzureBlob
{
public class AzureBlobFileSystemEntry : IUnixFileSystemEntry
{
public AzureBlobFileSystemEntry(AzureBlobFileSystem fileSystem, IListBlobItem item)
{
FileSystem = fileSystem;
Item = item;
if (Item.GetType().Name == "CloudBlobDirectory")
IsFolder = true;
else
IsFolder = false;
Permissions = new GenericUnixPermissions(
new GenericAccessMode(true, true, IsFolder),
new GenericAccessMode(true, true, IsFolder),
new GenericAccessMode(true, true, IsFolder));
}
public bool IsFolder { get; }
public IListBlobItem Item { get; }
public IUnixFileSystem FileSystem { get; }
public string Group => "group";
public long NumberOfLinks => 1;
public string Owner => "owner";
public IUnixPermissions Permissions { get; }
public DateTimeOffset? CreatedTime
{
get
{
if (IsFolder)
return null;
else
return ((CloudBlockBlob)Item).Properties.LastModified;
}
}
public DateTimeOffset? LastWriteTime
{
get
{
if (IsFolder)
return null;
else
return ((CloudBlockBlob)Item).Properties.LastModified;
}
}
public string Name
{
get
{
if (IsFolder)
{
var dir = (CloudBlobDirectory)Item;
return dir.Prefix.Replace(dir.Parent.Prefix,"").TrimEnd('/');
}
else
{
var blob = (CloudBlockBlob)Item;
return blob.Name.Replace(blob.Parent.Prefix, "");
}
}
}
}
}