Exemplo n.º 1
0
        internal long ProcessFile(FolderInDatabase owner, Win32.WIN32_FIND_DATAW findData, string fullpath)
        {
            //var newFile = new FileInDatabase(owner);
            var newFile = ProcessCompressed(owner, fullpath);

            ProcessCommon(newFile, findData, fullpath);

            newFile.IsReadOnly = (findData.dwFileAttributes & FileAttributes.ReadOnly) != 0;

            long highSize = (uint)findData.nFileSizeHigh;

            highSize       = highSize << 32;
            highSize      += (uint)findData.nFileSizeLow;
            newFile.Length = highSize;

            if (Properties.Settings.Default.ComputeCrc &&
                highSize < M250)
            {
                try
                {
                    var    buf   = File.ReadAllBytes(fullpath);
                    var    hash  = _md5.ComputeHash(buf);
                    UInt64 hash2 = BitConverter.ToUInt64(hash, 0);
                    newFile.Hash = hash2;
                }
                catch (Exception)
                {
                    // File might be locked
                }
            }

            ((IFolder)owner).AddToFiles(newFile);
            return(newFile.Length);
        }
Exemplo n.º 2
0
        internal void ProcessFolder(FolderInDatabase owner, Win32.WIN32_FIND_DATAW findData, string fullpath)
        {
            FolderInDatabase newFolder = new FolderInDatabase(owner);

            ProcessCommon(newFolder, findData, fullpath);
            ((IFolder)owner).AddToFolders(newFolder);

            ReadFromFolder(fullpath, newFolder);
        }
Exemplo n.º 3
0
        private static void ProcessCommon(ItemInDatabase item, Win32.WIN32_FIND_DATAW findData, string fullpath)
        {
            item.Name       = findData.cFileName;
            item.Attributes = findData.dwFileAttributes;
            string tmp = Path.GetExtension(fullpath);

            if (!string.IsNullOrEmpty(tmp))
            {
                tmp = tmp.ToLower();
                if (tmp.StartsWith("."))
                {
                    tmp = tmp.Substring(1);
                }
            }
            item.Extension = tmp;

            item.FullName       = fullpath;
            item.CreationTime   = findData.ftCreationTime.ToDateTime();
            item.LastAccessTime = findData.ftLastAccessTime.ToDateTime();
            item.LastWriteTime  = findData.ftLastWriteTime.ToDateTime();
        }