示例#1
0
        public DidlLite Items(uint aStartIndex, uint aCount)
        {
            iMutex.WaitOne();

            DidlLite didl = new DidlLite();

            foreach (string s in iFolders)
            {
                storageFolder folder   = new storageFolder();
                resource      resource = new resource();
                folder.Res.Add(resource);

                folder.Id          = s;
                folder.ParentId    = kRootId;
                folder.Title       = s;
                folder.WriteStatus = "PROTECTED";
                folder.Restricted  = true;
                folder.Searchable  = true;

                resource.Uri = s;

                didl.Add(folder);
            }

            iMutex.ReleaseMutex();

            return(didl);
        }
示例#2
0
        public DidlLite Items(uint aStartIndex, uint aCount)
        {
            DidlLite didl = new DidlLite();

            uint endIndex = aStartIndex + aCount;

            for (uint i = aStartIndex; i < endIndex && i < (iDirectories.Length + iFiles.Length); ++i)
            {
                if (i < iDirectories.Length)
                {
                    DirectoryInfo d          = iDirectories[i];
                    string        artworkUri = string.Empty;
                    try
                    {
                        artworkUri = UpnpObjectFactory.FindArtworkUri(d, iVirtualFileSystem);
                    }
                    catch (UnauthorizedAccessException) { } // failed on directory permissions, just create an empty uri
                    storageFolder folder = UpnpObjectFactory.Create(d, artworkUri);
                    folder.ParentId = (d.Parent == null) ? "" : d.Parent.FullName;

                    didl.Add(folder);
                }
                else
                {
                    FileInfo f = iFiles[i - iDirectories.Length];

                    string resUri     = iVirtualFileSystem.Uri(f.FullName);
                    string artworkUri = UpnpObjectFactory.FindArtworkUri(iPath, iVirtualFileSystem);

                    upnpObject obj = UpnpObjectFactory.Create(f, artworkUri, resUri);
                    obj.ParentId = f.Directory.FullName;

                    didl.Add(obj);
                }
            }

            return(didl);
        }