| | 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> |
| 1437 | 23 | | public NtfsFileAttributes? FileAttributes { get; set; } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// The key of the file permission. |
| | 27 | | /// </summary> |
| 2633 | 28 | | public string FilePermissionKey { get; set; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// The creation time of the file. |
| | 32 | | /// </summary> |
| 1441 | 33 | | public DateTimeOffset? FileCreatedOn { get; set; } |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// The last write time of the file. |
| | 37 | | /// </summary> |
| 1441 | 38 | | public DateTimeOffset? FileLastWrittenOn { get; set; } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// The change time of the file. |
| | 42 | | /// </summary> |
| 800 | 43 | | public DateTimeOffset? FileChangedOn { get; internal set; } |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// The fileId of the file. |
| | 47 | | /// </summary> |
| 800 | 48 | | public string FileId { get; internal set; } |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// The parentId of the file |
| | 52 | | /// </summary> |
| 800 | 53 | | public string ParentId { get; internal set; } |
| | 54 | |
|
| 621 | 55 | | internal FileSmbProperties() |
| | 56 | | { |
| 621 | 57 | | } |
| | 58 | |
|
| 254 | 59 | | internal FileSmbProperties(RawStorageFileInfo rawStorageFileInfo) |
| | 60 | | { |
| 254 | 61 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageFileInfo.FileAttributes); |
| 254 | 62 | | FilePermissionKey = rawStorageFileInfo.FilePermissionKey; |
| 254 | 63 | | FileCreatedOn = rawStorageFileInfo.FileCreationTime; |
| 254 | 64 | | FileLastWrittenOn = rawStorageFileInfo.FileLastWriteTime; |
| 254 | 65 | | FileChangedOn = rawStorageFileInfo.FileChangeTime; |
| 254 | 66 | | FileId = rawStorageFileInfo.FileId; |
| 254 | 67 | | ParentId = rawStorageFileInfo.FileParentId; |
| | 68 | |
|
| 254 | 69 | | } |
| | 70 | |
|
| 74 | 71 | | internal FileSmbProperties(RawStorageFileProperties rawStorageFileProperties) |
| | 72 | | { |
| 74 | 73 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageFileProperties.FileAttributes); |
| 74 | 74 | | FilePermissionKey = rawStorageFileProperties.FilePermissionKey; |
| 74 | 75 | | FileCreatedOn = rawStorageFileProperties.FileCreationTime; |
| 74 | 76 | | FileLastWrittenOn = rawStorageFileProperties.FileLastWriteTime; |
| 74 | 77 | | FileChangedOn = rawStorageFileProperties.FileChangeTime; |
| 74 | 78 | | FileId = rawStorageFileProperties.FileId; |
| 74 | 79 | | ParentId = rawStorageFileProperties.FileParentId; |
| 74 | 80 | | } |
| | 81 | |
|
| 61 | 82 | | internal FileSmbProperties(FlattenedStorageFileProperties flattenedStorageFileProperties) |
| | 83 | | { |
| 61 | 84 | | FileAttributes = ShareExtensions.ToFileAttributes(flattenedStorageFileProperties.FileAttributes); |
| 61 | 85 | | FilePermissionKey = flattenedStorageFileProperties.FilePermissionKey; |
| 61 | 86 | | FileCreatedOn = flattenedStorageFileProperties.FileCreationTime; |
| 61 | 87 | | FileLastWrittenOn = flattenedStorageFileProperties.FileLastWriteTime; |
| 61 | 88 | | FileChangedOn = flattenedStorageFileProperties.FileChangeTime; |
| 61 | 89 | | FileId = flattenedStorageFileProperties.FileId; |
| 61 | 90 | | ParentId = flattenedStorageFileProperties.FileParentId; |
| 61 | 91 | | } |
| | 92 | |
|
| 339 | 93 | | internal FileSmbProperties(RawStorageDirectoryInfo rawStorageDirectoryInfo) |
| | 94 | | { |
| 339 | 95 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageDirectoryInfo.FileAttributes); |
| 339 | 96 | | FilePermissionKey = rawStorageDirectoryInfo.FilePermissionKey; |
| 339 | 97 | | FileCreatedOn = rawStorageDirectoryInfo.FileCreationTime; |
| 339 | 98 | | FileLastWrittenOn = rawStorageDirectoryInfo.FileLastWriteTime; |
| 339 | 99 | | FileChangedOn = rawStorageDirectoryInfo.FileChangeTime; |
| 339 | 100 | | FileId = rawStorageDirectoryInfo.FileId; |
| 339 | 101 | | ParentId = rawStorageDirectoryInfo.FileParentId; |
| 339 | 102 | | } |
| | 103 | |
|
| 40 | 104 | | internal FileSmbProperties(RawStorageDirectoryProperties rawStorageDirectoryProperties) |
| | 105 | | { |
| 40 | 106 | | FileAttributes = ShareExtensions.ToFileAttributes(rawStorageDirectoryProperties.FileAttributes); |
| 40 | 107 | | FilePermissionKey = rawStorageDirectoryProperties.FilePermissionKey; |
| 40 | 108 | | FileCreatedOn = rawStorageDirectoryProperties.FileCreationTime; |
| 40 | 109 | | FileLastWrittenOn = rawStorageDirectoryProperties.FileLastWriteTime; |
| 40 | 110 | | FileChangedOn = rawStorageDirectoryProperties.FileChangeTime; |
| 40 | 111 | | FileId = rawStorageDirectoryProperties.FileId; |
| 40 | 112 | | ParentId = rawStorageDirectoryProperties.FileParentId; |
| 40 | 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) |
| 0 | 122 | | => base.Equals(other); |
| | 123 | |
|
| | 124 | | /// <summary> |
| | 125 | | /// Gets the hash code for the FileSmbProperties. |
| | 126 | | /// </summary> |
| | 127 | | /// <returns></returns> |
| | 128 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 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, |
| | 143 | | string parentId) => new FileSmbProperties |
| | 144 | | { |
| | 145 | | FileChangedOn = fileChangedOn, |
| | 146 | | FileId = fileId, |
| | 147 | | ParentId = parentId |
| | 148 | | }; |
| | 149 | | } |
| | 150 | | } |