Esempio n. 1
0
        private void BuildDirNode(string dirPath, DirNode parent, bool handleSMBAttributes)
        {
            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;

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

            foreach (var subDirInfo in LongPathDirectoryExtension.GetDirectories(dirPath))
            {
                DirNode subDirNode = new DirNode(subDirInfo.Remove(0, dirPath.Length));
                this.BuildDirNode(subDirInfo, subDirNode, handleSMBAttributes);
                parent.AddDirNode(subDirNode);
            }
        }
Esempio n. 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>();
        }
Esempio n. 3
0
        private void BuildDirNode(DirectoryInfo dirInfo, DirNode parent, bool handleSMBAttributes = false)
        {
            if (handleSMBAttributes)
            {
                DateTimeOffset?creationTime   = null;
                DateTimeOffset?lastWriteTime  = null;
                FileAttributes?fileAttributes = null;

#if DOTNET5_4
                LongPathFileExtension.GetFileProperties(dirInfo.FullName, out creationTime, out lastWriteTime, out fileAttributes, true);
#else
                LongPathFileExtension.GetFileProperties(dirInfo.FullName, out creationTime, out lastWriteTime, out fileAttributes);
#endif
                parent.CreationTime  = creationTime;
                parent.LastWriteTime = lastWriteTime;
            }

            foreach (FileInfo fileInfo in dirInfo.GetFiles())
            {
                FileNode fileNode = new FileNode(fileInfo.Name);
                this.BuildFileNode(fileInfo, fileNode, handleSMBAttributes);
                parent.AddFileNode(fileNode);
            }

            foreach (DirectoryInfo subDirInfo in dirInfo.GetDirectories())
            {
                DirNode subDirNode = new DirNode(subDirInfo.Name);
                this.BuildDirNode(subDirInfo, subDirNode, handleSMBAttributes);
                parent.AddDirNode(subDirNode);
            }
        }
Esempio n. 4
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);
                }
            }
        }