Ejemplo n.º 1
0
        internal static VolumeItem CreateInstance(VolumeItemType type, VolumeDatabase database)
        {
            VolumeItem item = null;

            switch (type)
            {
            case VolumeItemType.DirectoryVolumeItem:
                item = new DirectoryVolumeItem(database);
                break;

            case VolumeItemType.FileVolumeItem:
                item = new FileVolumeItem(database);
                break;

            case VolumeItemType.AudioCdRootVolumeItem:
                item = new AudioCdRootVolumeItem(database);
                break;

            case VolumeItemType.AudioTrackVolumeItem:
                item = new AudioTrackVolumeItem(database);
                break;

            default:
                throw new NotImplementedException(string.Format("Instantiation of type {0} is not implemented", type.ToString()));
            }
            return(item);
        }
Ejemplo n.º 2
0
        private void AppendDirRows(TreeStore store, TreeIter parent, DirectoryVolumeItem item)
        {
            bool					parentIsRoot	= (parent.Stamp == TreeIter.Zero.Stamp);
            DirectoryVolumeItem[]	dirs			= item.GetDirectories();
            FileVolumeItem[]		files			= item.GetFiles();

            // if no files or dirs have been found, add an empty node
            if (dirs.Length == 0 && files.Length == 0) {
                AppendDirValues(store, parent, parentIsRoot, null, STR_EMPTY, null);
            } else {
                foreach (DirectoryVolumeItem dir in dirs) {
                    TreeIter iter = AppendDirValues(store, parent, parentIsRoot, GetImage(dir), dir.Name, dir);
                    if (iter.Stamp != TreeIter.Zero.Stamp)
                        AppendDirValues(store, iter, false, loadingIcon, STR_LOADING, null);
                }

                foreach (FileVolumeItem file in files) {
                    AppendDirValues(store, parent, parentIsRoot, GetImage(file), file.Name, file);
                }
            }
        }
Ejemplo n.º 3
0
        private void ImportMedia(XmlNode node,
		                         string borrow,
		                         string comment,
		                         long volumeID)
        {
            FileSystemVolume v = new FileSystemVolume(targetDb);
            VolumeDriveType driveType = driveTypeMapping[node.Attributes["type"].Value];
            DateTime added;
            if (!DateTime.TryParseExact(node.Attributes["time"].Value, DATETIME_FORMAT,
                                        ci.DateTimeFormat, DateTimeStyles.None, out added))
                added = DateTime.MinValue;

            v.SetVolumeFields(volumeID,
                              node.Attributes["name"].Value,
                              added,
                              false,
                              node.Attributes["number"].Value,
                              driveType,
                              borrow,
                              DateTime.MinValue,
                              DateTime.MinValue,
                              null,
                              comment,
                              null);

            v.SetFileSystemVolumeFields(counters[TOTAL_FILES],
                                        counters[TOTAL_DIRS],
                                        counters[TOTAL_SIZE]);

            v.InsertIntoDB();

            // insert root item
            DirectoryVolumeItem item = new DirectoryVolumeItem(targetDb);

            item.SetFileSystemVolumeItemFields(null,
                                               DateTime.MinValue,
                                               VolumeDatabase.ID_NONE);

            item.SetVolumeItemFields(volumeID,
                                     1L,
                                     0L,
                                     "/",
                                     VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY,
                                     MetadataStore.Empty,
                                     null,
                                     null);

            item.InsertIntoDB();
        }
Ejemplo n.º 4
0
 internal static VolumeItem CreateInstance(VolumeItemType type, VolumeDatabase database)
 {
     VolumeItem item = null;
     switch (type) {
         case VolumeItemType.DirectoryVolumeItem:
             item = new DirectoryVolumeItem(database);
             break;
         case VolumeItemType.FileVolumeItem:
             item = new FileVolumeItem(database);
             break;
         case VolumeItemType.AudioCdRootVolumeItem:
             item = new AudioCdRootVolumeItem(database);
             break;
         case VolumeItemType.AudioTrackVolumeItem:
             item = new AudioTrackVolumeItem(database);
             break;
         default:
             throw new NotImplementedException(string.Format("Instantiation of type {0} is not implemented", type.ToString()));
     }
     return item;
 }
Ejemplo n.º 5
0
        private void ImportFile(XmlNode node,
		                        string comment,
		                        long volumeID,		                        
		                        long parentID,
		                        long itemID,
		                        Stack<string> path,
		                        MetadataStore metaData)
        {
            FileSystemVolumeItem item;
            string location = "/" + string.Join("/", path.Reverse());
            string name = node.Attributes["name"].Value;
            string mimeType;
            DateTime lastWriteTime;

            if (node.Name == "directory") {
                item = new DirectoryVolumeItem(targetDb);
                mimeType = VolumeScanner.FilesystemVolumeScanner.MIME_TYPE_DIRECTORY;
                counters[TOTAL_DIRS]++;
            } else {
                item = new FileVolumeItem(targetDb);
                // prepend a non-existing path to ensure the file doesn't actually exist
                // in the current environment directory
                mimeType = MimeType.GetMimeTypeForFile(mimePathPrefix + name);
                long size = ConvertSize(node.Attributes["size"].Value);

                ((FileVolumeItem)item).SetFileVolumeItemFields(size, null);
                counters[TOTAL_FILES]++;
                counters[TOTAL_SIZE] += size;
            }

            if (!DateTime.TryParseExact(node.Attributes["time"].Value, DATETIME_FORMAT, ci.DateTimeFormat,
                                        DateTimeStyles.None, out lastWriteTime))
                lastWriteTime = DateTime.MinValue;

            item.SetFileSystemVolumeItemFields(location,
                                               lastWriteTime,
                                               VolumeDatabase.ID_NONE);
            item.SetVolumeItemFields(volumeID,
                                     itemID,
                                     parentID,
                                     name,
                                     mimeType,
                                     metaData,
                                     comment,
                                     null);

            writer.Write(item);
        }