Example #1
0
        public static HtmlNode FilePage(SoftFile i)
        {
            HtmlNode node = HtmlNode.CreateNode("<div id=\"filepage\" />");
            var      head = node.AppendChild(HtmlNode.CreateNode("<div id=\"fileheader\" />"));

            head.AppendChild(HtmlNode.CreateNode($"<h1 id=\"filetitle\">{Encode.HtmlEncode(i.Name)}</h1>"));
            if (i.ThumbnailExists)
            {
                head.AppendChild(Thumbnail(i, i.Id.ToString()));
            }
            //node.AppendChild(Thumbnail(i, i.Id.ToString()));
            var tagsandref = node.AppendChild(HtmlNode.CreateNode("<div id=\"tagsandref\" />"));
            var refrr      = i.References;

            if (refrr.Count > 0)
            {
                tagsandref.AppendChild(List("div", "References", "filereferencelist", refrr.Select(n => $"<a id=\"filereferences\" href=\"/file&{n.Id}\">{Encode.HtmlEncode(n.Name)}</a>").ToArray()));
            }
            node.AppendChild(HtmlNode.CreateNode($"<p id=\"hashes\">{i.Hashes}</p>"));
            var tags = i.Tags;

            if (tags.Count > 0)
            {
                tagsandref.AppendChild(List("div", "Tags", "taglist", tags.Select(n => $"<p id=\"tag\">{n}</p>").ToArray()));
            }
            return(node);
        }
Example #2
0
 static void FileInfo(SoftFile f)
 {
     Console.WriteLine($"{f.Name} ({f.Id})");
     Console.WriteLine(f.Hashes);
     Console.WriteLine($"Thumbnail Path: {f.ThumbnailPath})");
     Tags(f);
 }
Example #3
0
 public void DatabaseAddFile(SoftFile i)
 {
     if (i != null)
     {
         _softFiles.Add(i);
     }
 }
Example #4
0
        public static HtmlNode FileStrip(SoftFile i)
        {
            HtmlNode node = HtmlNode.CreateNode("<div id=\"file\" />");
            HtmlNode name = Text(i.Name, "div", "filename");

            node.AppendChild(name);
            return(node);
        }
Example #5
0
 private static void SaveSoftFile(UnLoader a, SoftFile i)
 {
     a.PackInt(i.Id);
     a.PackString(i.Name);
     a.PackString(i.ThumbnailPath);
     Tags(a, i.TagArray);
     SaveSHA256(a, i.SHA256);
 }
Example #6
0
        public static HtmlNode FileCard(SoftFile i)
        {
            HtmlNode card = HtmlNode.CreateNode("<div id=\"filecard\" />");

            (card.AppendChild(Text("", "div", "filename"))).AppendChild(HtmlNode.CreateNode($"<a href=\"/file&{i.Id}\">{i.Name}</a>"));
            //HtmlNode name = Text(i.Name, "div", "filename");
            //card.AppendChild(name);
            return(card);
        }
Example #7
0
        static void SendFile(TcpClient client, SoftFile file, List <KeyValuePair <string, DateTime> > timings)
        {
            var a = HTML.FilePage(file);
            var b = GetHtml();

            b.DocumentNode.SelectSingleNode("//html/body").AppendChild(a);
            timings.Add(new KeyValuePair <string, DateTime>("HTML Document", DateTime.Now));
            client.Client.Send(new HttpResponse(new ResponseHeader(), new Content(b.Serialize())).Serialize());
            timings.Add(new KeyValuePair <string, DateTime>("Sending", DateTime.Now));
        }
Example #8
0
        static IEnumerable <SoftDirectory> Search(SoftFile i)
        {
            Console.WriteLine("Search by hash and id");
            List <SoftDirectory> results = new List <SoftDirectory>();

            foreach (var a in Program.CentralDirectory.Directories)
            {
                Directories(results, a, i);
            }
            return(results);
        }
Example #9
0
 public SoftFile AddFile(SoftFile i, bool check = true)
 {
     if (!check || (check && !Exists(i.Id)))
     {
         _softFiles.Add(i);
     }
     else
     {
         throw new InvalidOperationException("File already exists");
     }
     return(i);
 }
Example #10
0
        private static CentralIndex LoadCentralIndex(Loader a)
        {
            int nextid     = a.NextInt;
            int numoffiles = a.NextInt;

            SoftFile[] cindex = new SoftFile[numoffiles];
            for (int i = 0; i < numoffiles; i++)
            {
                cindex[i] = LoadSoftFile(a);
            }
            return(new CentralIndex(nextid, cindex));
        }
Example #11
0
 static void Directories(List <SoftDirectory> ok, SoftDirectory cur, SoftFile i)
 {
     foreach (var a in cur.SubDirectories)
     {
         Directories(ok, a, i);
     }
     foreach (var a in cur.SoftFiles)
     {
         if (i == a)
         {
             ok.Add(cur);
         }
     }
 }
Example #12
0
        static SoftDirectory Import(DirectoryInfo i)
        {
            var d = i.GetDirectories();
            var e = i.GetFiles();

            SoftDirectory[] ss = new SoftDirectory[d.Length];
            SoftFile[]      ee = new SoftFile[e.Length];
            for (int m = 0; m < d.Length; m++)
            {
                ss[m] = Import(d[m]);
            }
            for (int g = 0; g < e.Length; g++)
            {
                ee[g] = Import(e[g], Program.CentralDirectory);
            }
            return(new SoftDirectory(Program.CentralDirectory.NextId, i.Name, ss, ee, new string[0]));
        }
Example #13
0
        static void Reference()
        {
            SoftFile fileFirst = QueryFile();
            SoftFile fileRefer = QueryFile();

            if (fileFirst == null || fileRefer == null)
            {
                return;
            }
            fileFirst.AddReference(fileRefer);
            Console.WriteLine($"{fileFirst} ({fileFirst.Id}) => {fileRefer} ({fileRefer.Id})");
            if (fileFirst.Equals(fileRefer))
            {
                Console.WriteLine("This file equals the reference");
            }
            else
            {
                Console.WriteLine("The file does not equal the reference");
            }
        }
Example #14
0
 public bool Exists(SoftFile i)
 {
     return(_softFiles.Exists(n => n.Id == i.Id));
 }
Example #15
0
        //public static bool operator !=(SoftFile i, SoftFile b)
        //{
        //    return ((!i.Compare(b) && i.Id != b.Id));
        //}

        //public static bool operator== (SoftFile i, SoftFile b)
        //{
        //    return (i.Compare(b) && i.Id == b.Id);
        //}

        public bool Equals(SoftFile obj)
        {
            return((Compare(obj) && Id == obj.Id));
        }