| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.ComponentModel; |
| | 7 | | using System.Globalization; |
| | 8 | | using System.Linq; |
| | 9 | | using System.Text; |
| | 10 | |
|
| | 11 | | #pragma warning disable SA1402 // File may only contain a single type |
| | 12 | |
|
| | 13 | | namespace Azure.Storage.Files.Shares.Models |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// The SMB properties for a file. |
| | 17 | | /// </summary> |
| | 18 | | public class FileSmbProperties |
| | 19 | | { |
| | 20 | | /// <summary> |
| | 21 | | /// The file system attributes for this file. |
| | 22 | | /// </summary> |
| | 23 | | public NtfsFileAttributes? FileAttributes { get; set; } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// The key of the file permission. |
| | 27 | | /// </summary> |
| | 28 | | public string FilePermissionKey { get; set; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// The creation time of the file. |
| | 32 | | /// </summary> |
| | 33 | | public DateTimeOffset? FileCreatedOn { get; set; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// The last write time of the file. |
| | 37 | | /// </summary> |
| | 38 | | public DateTimeOffset? FileLastWrittenOn { get; set; } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// The change time of the file. |
| | 42 | | /// </summary> |
| | 43 | | public DateTimeOffset? FileChangedOn { get; internal set; } |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// The fileId of the file. |
| | 47 | | /// </summary> |
| | 48 | | public string FileId { get; internal set; } |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// The parentId of the file |
| | 52 | | /// </summary> |
| | 53 | | public string ParentId { get; internal set; } |
| | 54 | |
|
| | 55 | | internal FileSmbProperties() |
| | 56 | | { |
| | 57 | | } |
| | 58 | |
|
| | 59 | | internal FileSmbProperties(RawStorageFileInfo rawStorageFileInfo) |
| | 60 | | { |
| | 61 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageFileInfo.FileAttributes); |
| | 62 | | FilePermissionKey = rawStorageFileInfo.FilePermissionKey; |
| | 63 | | FileCreatedOn = rawStorageFileInfo.FileCreationTime; |
| | 64 | | FileLastWrittenOn = rawStorageFileInfo.FileLastWriteTime; |
| | 65 | | FileChangedOn = rawStorageFileInfo.FileChangeTime; |
| | 66 | | FileId = rawStorageFileInfo.FileId; |
| | 67 | | ParentId = rawStorageFileInfo.FileParentId; |
| | 68 | |
|
| | 69 | | } |
| | 70 | |
|
| | 71 | | internal FileSmbProperties(RawStorageFileProperties rawStorageFileProperties) |
| | 72 | | { |
| | 73 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageFileProperties.FileAttributes); |
| | 74 | | FilePermissionKey = rawStorageFileProperties.FilePermissionKey; |
| | 75 | | FileCreatedOn = rawStorageFileProperties.FileCreationTime; |
| | 76 | | FileLastWrittenOn = rawStorageFileProperties.FileLastWriteTime; |
| | 77 | | FileChangedOn = rawStorageFileProperties.FileChangeTime; |
| | 78 | | FileId = rawStorageFileProperties.FileId; |
| | 79 | | ParentId = rawStorageFileProperties.FileParentId; |
| | 80 | | } |
| | 81 | |
|
| | 82 | | internal FileSmbProperties(FlattenedStorageFileProperties flattenedStorageFileProperties) |
| | 83 | | { |
| | 84 | | FileAttributes = ShareExtensions.ToFileAttributes(flattenedStorageFileProperties.FileAttributes); |
| | 85 | | FilePermissionKey = flattenedStorageFileProperties.FilePermissionKey; |
| | 86 | | FileCreatedOn = flattenedStorageFileProperties.FileCreationTime; |
| | 87 | | FileLastWrittenOn = flattenedStorageFileProperties.FileLastWriteTime; |
| | 88 | | FileChangedOn = flattenedStorageFileProperties.FileChangeTime; |
| | 89 | | FileId = flattenedStorageFileProperties.FileId; |
| | 90 | | ParentId = flattenedStorageFileProperties.FileParentId; |
| | 91 | | } |
| | 92 | |
|
| | 93 | | internal FileSmbProperties(RawStorageDirectoryInfo rawStorageDirectoryInfo) |
| | 94 | | { |
| | 95 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageDirectoryInfo.FileAttributes); |
| | 96 | | FilePermissionKey = rawStorageDirectoryInfo.FilePermissionKey; |
| | 97 | | FileCreatedOn = rawStorageDirectoryInfo.FileCreationTime; |
| | 98 | | FileLastWrittenOn = rawStorageDirectoryInfo.FileLastWriteTime; |
| | 99 | | FileChangedOn = rawStorageDirectoryInfo.FileChangeTime; |
| | 100 | | FileId = rawStorageDirectoryInfo.FileId; |
| | 101 | | ParentId = rawStorageDirectoryInfo.FileParentId; |
| | 102 | | } |
| | 103 | |
|
| | 104 | | internal FileSmbProperties(RawStorageDirectoryProperties rawStorageDirectoryProperties) |
| | 105 | | { |
| | 106 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageDirectoryProperties.FileAttributes); |
| | 107 | | FilePermissionKey = rawStorageDirectoryProperties.FilePermissionKey; |
| | 108 | | FileCreatedOn = rawStorageDirectoryProperties.FileCreationTime; |
| | 109 | | FileLastWrittenOn = rawStorageDirectoryProperties.FileLastWriteTime; |
| | 110 | | FileChangedOn = rawStorageDirectoryProperties.FileChangeTime; |
| | 111 | | FileId = rawStorageDirectoryProperties.FileId; |
| | 112 | | ParentId = rawStorageDirectoryProperties.FileParentId; |
| | 113 | | } |
| | 114 | |
|
| | 115 | | /// <summary> |
| | 116 | | /// Checks if two FileSmbProperties are equal. |
| | 117 | | /// </summary> |
| | 118 | | /// <param name="other">The other instance to compare to.</param> |
| | 119 | | /// <returns></returns> |
| | 120 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 121 | | public override bool Equals(object other) |
| | 122 | | => base.Equals(other); |
| | 123 | |
|
| | 124 | | /// <summary> |
| | 125 | | /// Gets the hash code for the FileSmbProperties. |
| | 126 | | /// </summary> |
| | 127 | | /// <returns></returns> |
| | 128 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | 129 | | public override int GetHashCode() => base.GetHashCode(); |
| | 130 | | } |
| | 131 | |
|
| | 132 | | /// <summary> |
| | 133 | | /// FilesModelFactory provides utilities for mocking. |
| | 134 | | /// </summary> |
| | 135 | | public static partial class SharesModelFactory |
| | 136 | | { |
| | 137 | | /// <summary> |
| | 138 | | /// Creates a new FileSmbProperties instance for mocking. |
| | 139 | | /// </summary> |
| | 140 | | public static FileSmbProperties FileSmbProperties( |
| | 141 | | DateTimeOffset? fileChangedOn, |
| | 142 | | string fileId, |
| 0 | 143 | | string parentId) => new FileSmbProperties |
| 0 | 144 | | { |
| 0 | 145 | | FileChangedOn = fileChangedOn, |
| 0 | 146 | | FileId = fileId, |
| 0 | 147 | | ParentId = parentId |
| 0 | 148 | | }; |
| | 149 | | } |
| | 150 | | } |