示例#1
0
        private void BuildFileNode(FileInfo fileInfo, FileNode fileNode, bool handleSMBAttributes, PreserveSMBPermissions getPermissions)
        {
            fileNode.MD5 = Helper.GetFileContentMD5(fileInfo.FullName);
            fileNode.LastModifiedTime = fileInfo.LastWriteTimeUtc;
            fileNode.SizeInByte       = fileInfo.Length;
            fileNode.Metadata         = new Dictionary <string, string>();

            if (CrossPlatformHelpers.IsWindows)
            {
                DateTimeOffset?creationTime   = null;
                DateTimeOffset?lastWriteTime  = null;
                FileAttributes?fileAttributes = null;
                LongPathFileExtension.GetFileProperties(fileInfo.FullName, out creationTime, out lastWriteTime, out fileAttributes);

                fileNode.CreationTime  = creationTime;
                fileNode.LastWriteTime = lastWriteTime;

                if (handleSMBAttributes)
                {
                    fileNode.SMBAttributes = Helper.ToCloudFileNtfsAttributes(fileAttributes.Value);
                }

                if (PreserveSMBPermissions.None != getPermissions)
                {
                    fileNode.PortableSDDL = LongPathFileExtension.GetFilePortableSDDL(fileInfo.FullName, getPermissions);
                }
            }
        }
示例#2
0
        private void BuildFileNode(string path, FileNode fileNode, bool handleSMBAttributes, PreserveSMBPermissions getPermissions)
        {
            fileNode.MD5 = Helper.GetFileContentMD5(LongPathExtension.GetFullPath(path));
            // fileNode.LastModifiedTime =
            using (FileStream fs = LongPathFileExtension.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                fileNode.SizeInByte = fs.Length;
            }

            DateTimeOffset?creationTime   = null;
            DateTimeOffset?lastWriteTime  = null;
            FileAttributes?fileAttributes = null;

            LongPathFileExtension.GetFileProperties(path, out creationTime, out lastWriteTime, out fileAttributes);

            fileNode.CreationTime  = creationTime;
            fileNode.LastWriteTime = lastWriteTime;

            if (handleSMBAttributes)
            {
                fileNode.SMBAttributes = Helper.ToCloudFileNtfsAttributes(fileAttributes.Value);
            }

            if (PreserveSMBPermissions.None != getPermissions)
            {
                fileNode.PortableSDDL = LongPathFileExtension.GetFilePortableSDDL(path, getPermissions);
            }

            fileNode.Metadata = new Dictionary <string, string>();
        }
示例#3
0
        private void BuildDirNode(string dirPath, DirNode parent, bool handleSMBAttributes, PreserveSMBPermissions getSMBPermissions)
        {
            dirPath = AppendDirectorySeparator(dirPath);

            DateTimeOffset?creationTime   = null;
            DateTimeOffset?lastWriteTime  = null;
            FileAttributes?fileAttributes = null;

#if DOTNET5_4
            LongPathFileExtension.GetFileProperties(dirPath, out creationTime, out lastWriteTime, out fileAttributes, true);
#else
            LongPathFileExtension.GetFileProperties(dirPath, out creationTime, out lastWriteTime, out fileAttributes);
#endif

            parent.CreationTime  = creationTime;
            parent.LastWriteTime = lastWriteTime;

            if (PreserveSMBPermissions.None != getSMBPermissions)
            {
                parent.PortableSDDL = LongPathFileExtension.GetFilePortableSDDL(dirPath, getSMBPermissions);
            }

            foreach (var fileInfo in LongPathDirectoryExtension.GetFiles(dirPath))
            {
                FileNode fileNode = new FileNode(fileInfo.Remove(0, dirPath.Length));
                this.BuildFileNode(fileInfo, fileNode, handleSMBAttributes, getSMBPermissions);
                parent.AddFileNode(fileNode);
            }

            foreach (var subDirInfo in LongPathDirectoryExtension.GetDirectories(dirPath))
            {
                DirNode subDirNode = new DirNode(subDirInfo.Remove(0, dirPath.Length));
                this.BuildDirNode(subDirInfo, subDirNode, handleSMBAttributes, getSMBPermissions);
                parent.AddDirNode(subDirNode);
            }
        }