private static void Gather(Media medium, XDvdFsFileSystemEntry entry, FilesystemMetadataEntity parent)
        {
            IDatabaseDriver dbDriver = AzusaContext.GetInstance().DatabaseDriver;

            FilesystemMetadataEntity dirEntity = new FilesystemMetadataEntity();

            dirEntity.FullName    = entry.FullPath;
            dirEntity.IsDirectory = entry.IsFolder;
            dirEntity.MediaId     = medium.Id;
            dirEntity.Modified    = null;
            dirEntity.ParentId    = parent != null ? parent.Id : -1;
            if (entry.IsFolder)
            {
                dbDriver.AddFilesystemInfo(dirEntity);
                foreach (XDvdFsFileSystemEntry subfile in entry.Files)
                {
                    Gather(medium, subfile, dirEntity);
                }
            }
            else
            {
                int    readSize = (int)Math.Min(2048, entry.LogicalFileSize);
                byte[] buffer   = new byte[readSize];
                Stream inStream = entry.GetStream();
                readSize = inStream.Read(buffer, 0, readSize);
                inStream.Close();
                Array.Resize(ref buffer, readSize);
                dirEntity.Header = buffer;
                dbDriver.AddFilesystemInfo(dirEntity);
            }
        }
        private static void Gather(Media medium, DirectoryInfo di, FilesystemMetadataEntity parent)
        {
            IDatabaseDriver dbDriver = AzusaContext.GetInstance().DatabaseDriver;

            FilesystemMetadataEntity dirEntity = new FilesystemMetadataEntity();

            dirEntity.FullName    = di.FullName.Replace(di.Root.FullName, "");
            dirEntity.IsDirectory = true;
            dirEntity.MediaId     = medium.Id;
            dirEntity.Modified    = di.LastWriteTime;
            dirEntity.ParentId    = parent != null ? parent.Id : -1;
            dbDriver.AddFilesystemInfo(dirEntity);

            foreach (DirectoryInfo subdir in di.GetDirectories())
            {
                Gather(medium, subdir, dirEntity);
            }

            foreach (FileInfo file in di.GetFiles())
            {
                FilesystemMetadataEntity fileEntity = new FilesystemMetadataEntity();
                fileEntity.FullName    = file.FullName;
                fileEntity.IsDirectory = false;
                fileEntity.MediaId     = medium.Id;
                fileEntity.Modified    = file.LastWriteTime;
                fileEntity.ParentId    = dirEntity.Id;
                fileEntity.Size        = file.Length;

                int    readSize = (int)Math.Min(2048, file.Length);
                byte[] buffer   = new byte[readSize];
                Stream inStream = file.OpenRead();
                readSize = inStream.Read(buffer, 0, readSize);
                inStream.Close();
                Array.Resize(ref buffer, readSize);
                fileEntity.Header = buffer;

                dbDriver.AddFilesystemInfo(fileEntity);
            }
        }