예제 #1
0
파일: SQLite.cs 프로젝트: fire-eggs/octopus
        private static void ReadLogicalFolderItems(SQLiteConnection conn, VolumeDatabase mem)
        {
            string txt = "SELECT * FROM [LFoldMap]";

            using (SQLiteCommand cmd = new SQLiteCommand(txt, conn))
            {
                using (SQLiteDataReader rdr = cmd.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        int lFoldId = rdr.GetInt32(1);
                        int iidId   = rdr.GetInt32(2);
                        int typeId  = rdr.GetInt16(3);

                        LogicalFolder  lfold = _lfoldHash[lFoldId] as LogicalFolder;
                        ItemInDatabase iid   = null;
                        switch (typeId)
                        {
                        case 1:
                            // folder
                            iid = _foldHash[iidId] as ItemInDatabase;
                            break;

                        case 2:
                            // file
                            iid = _fileHash[iidId] as ItemInDatabase;
                            break;

                        case 3:
                            // disc. brute it.
                            foreach (var discInDatabase in mem.GetDiscs())
                            {
                                if (-discInDatabase.DbId == iidId)
                                {
                                    iid = discInDatabase as ItemInDatabase;
                                    break;
                                }
                            }
                            break;
                        }

                        lfold.AddItem(iid); // TODO make sure the two-way mapping is set!
                    }
                }
            }
        }
예제 #2
0
        internal void AddItemAsDvd(IFolder folderInDatabase)
        {
            LogicalFolder newFolder = new LogicalFolder((folderInDatabase as ItemInDatabase).Name, LogicalFolderType.Disc, 0, 0);

            AddFolder(newFolder);
            foreach (FileInDatabase file in folderInDatabase.Files)
            {
                newFolder.AddItem(file);
            }
            foreach (IFolder folder in folderInDatabase.Folders)
            {
                if (folder is FolderInDatabase)
                {
                    // nie dodajemy CompressedFile
                    newFolder.AddItemAsFolder(folder, null);
                }
            }
        }
예제 #3
0
        internal void AddItemAsFolder(IFolder folderInDatabase, string asName)
        {
            LogicalFolder newFolder = new LogicalFolder(folderType, asName != null ? asName : (folderInDatabase as ItemInDatabase).Name);

            AddFolder(newFolder);
            foreach (FileInDatabase file in folderInDatabase.Files)
            {
                newFolder.AddItem(file);
            }
            foreach (IFolder folder in folderInDatabase.Folders)
            {
                if (folder is FolderInDatabase)
                {
                    // nie dodajemy CompressedFile
                    newFolder.AddItemAsFolder(folder, null);
                }
            }
        }