示例#1
0
        private void DoRoot()
        {
            MakinaFolder newMaster = new MakinaFolder(null, FriendlyName);

            newMaster.Server = this;
            newMaster.Id     = Identifiers.GENERAL_ROOT;

            MakinaFolder subdir = new MakinaFolder(newMaster, FriendlyName);

            subdir.Server = this;
            newMaster.AddSubFolder(subdir);
            FileInfo[] files;
            if (this.Tags.Count > 1)
            {
                files = GetFilesByTags(this.Tags, false);
            }
            else
            {
                files = GetFilesByTag(this.Tags[0]);
            }

            foreach (FileInfo file in files)
            {
                var t = GetFile(subdir, file);
                subdir.AddResource(t);
            }
            RegisterNewMaster(newMaster);
            //Thumbnail();
        }
示例#2
0
        internal static BaseFile GetFile(MakinaFolder parentFolder, FileInfo file,
                                         DlnaMime type, DlnaMediaTypes mediaType)
        {
            switch (mediaType)
            {
            case DlnaMediaTypes.Video:
            //return new VideoFile(parentFolder.Server, file, type);
            case DlnaMediaTypes.Audio:
            //return new AudioFile(parentFolder.Server, file, type);
            case DlnaMediaTypes.Image:
                return(new ImageFile(parentFolder.Server, file, type));

            default:
                return(new BaseFile(parentFolder.Server, file, type, mediaType));
            }
        }
示例#3
0
        internal BaseFile GetFile(MakinaFolder aParent, System.IO.FileInfo info)
        {
            BaseFile item;

            lock (ids)
            {
                item = ids.GetItemByPath(info.FullName) as BaseFile;
            }
            if (item != null &&
                item.InfoDate == info.LastWriteTimeUtc &&
                item.InfoSize == info.Length)
            {
                return(item);
            }

            string         ext = System.IO.Path.GetExtension(info.FullName).Replace(".", String.Empty).ToUpper();
            DlnaMime       type;
            DlnaMediaTypes mediaType;

            if (ext == "BMP")
            {
                type      = DlnaMaps.Ext2Dlna["JPG"];
                mediaType = DlnaMaps.Ext2Media["JPG"];
            }
            else
            {
                type      = DlnaMaps.Ext2Dlna[ext];
                mediaType = DlnaMaps.Ext2Media[ext];
            }

            //var mediaType = DlnaMaps.Ext2Media[ext];
            var rv = BaseFile.GetFile(aParent, info, type, mediaType);

            //pendingFiles.Enqueue(new WeakReference(rv));
            return(rv);
        }