Esempio n. 1
0
        public FATXFolderEntry GetFolder(string Path)
        {
            FATXFolderEntry ret = null;

            xReadToFolder(Path, out ret);

            return(ret);
        }
Esempio n. 2
0
        /// <summary>
        /// Attempts to read to a specified location
        /// </summary>
        /// <param name="Path">Path to read to</param>
        /// <param name="xFolderOut">FATXFolder of result</param>
        /// <returns></returns>
        public FATXReadContents ReadToFolder(string Path, out FATXFolderEntry xFolderOut)
        {
            if (ActiveCheck())
            {
                xFolderOut = null;
                return(null);
            }
            FATXReadContents xreturn = xReadToFolder(Path, out xFolderOut);

            xactive = false;
            return(xreturn);
        }
 public USBDriveEntry(string name, FATXReadContents contents, FATXFolderEntry entry)
 {
     this.entry = entry;
     this.name = name;
     this.contents = contents;
 }
 public FATXFileEntry(FATXFolderEntry folder, FATXEntry x)
     : base(folder, ref x)
 {
 }
        public FATXReadContents xRead()
        {
            FATXReadContents xreturn = new FATXReadContents();
            try
            {
                xDrive.GetIO();

                if (!Partition.xTable.xAllocTable.Accessed)
                {
                    return null;
                }
                List<FATXEntry> xEntries = new List<FATXEntry>();
                uint[] xBlocks = Partition.xTable.GetBlocks(xStartBlock);

                for (int i = 0; i < xBlocks.Length; i++)
                {
                    long xCurrent = Partition.BlockToOffset(xBlocks[i]);
                    if (xCurrent == -1)
                        break;

                    for (int x = 0; x < Partition.xEntryCount; x++)
                    {
                        xDrive.xIO.Position = xCurrent + (0x40 * x);
                        FATXEntry z = new FATXEntry(Partition.FatType,
                            (xCurrent + (0x40 * x)),
                            xDrive.xIO.ReadBytes(0x40),
                            ref xDrive);

                        z.SetAtts(Partition);

                        if (z.xIsValid)
                        {
                            xEntries.Add(z);
                        }
                        else
                        {
                            if (z.xNLen != 0xE5)
                                break;
                        }
                    }
                }
                xreturn.xfolds = new List<FATXFolderEntry>();
                xreturn.xfiles = new List<FATXFileEntry>();
                for (int i = 0; i < xEntries.Count; i++)
                {
                    if (xEntries[i].IsFolder)
                    {
                        if (string.Compare(xEntries[i].Name, this.Name, true) != 0)
                        {
                            var f = new FATXFolderEntry(this, xEntries[i], Path + "/" + xEntries[i].Name);

                            xreturn.xfolds.Add(f);
                        }
                    }
                    else
                    {
                        var f = new FATXFileEntry(this, xEntries[i]);

                        xreturn.xfiles.Add(f);
                    }
                }
                return xreturn;
            }
            catch { return (xreturn = null); }
        }
        public FATXReadContents xReadToFolder(string Path, out FATXFolderEntry xFolderOut)
        {
            xFolderOut = null;

            List<string> findFolders = GetPathFromString(Path);
            if (findFolders == null || findFolders.Count == 0)
                return null;

            string findPartition = findFolders[0];

            var partition = GetPartition(findPartition);
            if (partition == null)
                return null;

            int partIndex = GetPartitionIndex(partition);
            if (partIndex == -1)
                return null;

            var contents = GetPartitionContents(partIndex);
            if (contents == null)
                return null;

            if (findFolders.Count == 1)
            {
                xFolderOut = new FATXFolderEntry(contents.Folders[0].Parent, contents.Folders[0], Path);
                return contents;
            }

            findFolders.RemoveAt(0);
            while (findFolders.Count > 0)
            {
                var entry = GetSubEntry(findFolders[0], contents);

                if (entry != null)
                {
                    if (entry.xIsValid)
                    {
                        if (entry.IsFolder)
                        {
                            var fe = entry as FATXFolderEntry;
                            if (fe != null)
                            {
                                xFolderOut = fe;

                                contents = fe.xRead();
                            }
                            else
                            {
                                xFolderOut = null;
                                contents = null;
                            }
                        }
                        else
                        {
                            var fe = entry as FATXFileEntry;
                            if (fe != null)
                            {
                                xFolderOut = null;
                                contents = new FATXReadContents();
                                contents.xfiles = new List<FATXFileEntry>();
                                contents.xfolds = new List<FATXFolderEntry>();
                                contents.xfiles.Add(fe);
                            }
                            else
                            {
                                xFolderOut = null;
                                contents = null;
                            }
                        }
                    }
                }
                findFolders.RemoveAt(0);
                if (contents == null)
                    return null;

            }

            return contents;
            /*
            if (Folders.Length == 1)
            {
                return partContents;
            }

            int curFolder=1;

            FATXPartition xcurpart = xPartitions[PartitionIndex];
            int idx = 1;
            for (int i = 0; i < xcurpart.SubPartitions.Length; i++)
            {
                if (xcurpart.SubPartitions[i].PartitionName.ToLower() != Folders[1].ToLower())
                    continue;
                xcurpart = xcurpart.SubPartitions[i];
                idx++;
                if (Folders.Length == 2)
                {
                    FATXReadContents xread = new FATXReadContents();
                    xread.xfiles = new List<FATXFileEntry>();
                    xread.xfolds = new List<FATXFolderEntry>();
                    foreach (FATXFolderEntry xz in xcurpart.Folders)
                        xread.xfolds.Add(xz);
                    return xread;
                }
                break;
            }
            FATXFolderEntry xFold = null;
            foreach (FATXFolderEntry x in xcurpart.Folders)
            {
                if (x.Name.ToLower() != Folders[idx].ToLower())
                    continue;
                xFold = x;
                break;
            }
            if (xFold == null)
                return null;
            idx++;
            FATXReadContents xreadct;
            for (int i = idx; i < Folders.Length; i++)
            {
                bool found = false;
                xreadct = xFold.xRead();
                foreach (FATXFolderEntry x in xreadct.Folders)
                {
                    if (x.Name.ToLower() != Folders[i].ToLower())
                        continue;
                    found = true;
                    xFold = x;
                    break;
                }
                if (!found)
                    return null;
            }
            xFolderOut = xFold;
            return xFold.xRead();*/
        }
 /// <summary>
 /// Attempts to read to a specified location
 /// </summary>
 /// <param name="Path">Path to read to</param>
 /// <param name="xFolderOut">FATXFolder of result</param>
 /// <returns></returns>
 public FATXReadContents ReadToFolder(string Path, out FATXFolderEntry xFolderOut)
 {
     if (ActiveCheck())
     {
         xFolderOut = null;
         return null;
     }
     FATXReadContents xreturn = xReadToFolder(Path, out xFolderOut);
     xactive = false;
     return xreturn;
 }
Esempio n. 8
0
        internal FATXReadContents xReadToFolder(string Path, out FATXFolderEntry xFolderOut)
        {
            xFolderOut = null;
            if (Path == null || Path == "")
            {
                return(null);
            }
            Path = Path.Replace("\\", "/");
            if (Path[0] == '/')
            {
                Path = Path.Substring(1, Path.Length - 1);
            }
            if (Path[Path.Length - 1] == '/')
            {
                Path = Path.Substring(0, Path.Length - 1);
            }
            string[] Folders        = Path.Split(new char[] { '/' });
            sbyte    PartitionIndex = -1;

            for (int i = 0; i < xPartitions.Count; i++)
            {
                if (xPartitions[i].PartitionName.ToLower() != Folders[0].ToLower())
                {
                    continue;
                }
                PartitionIndex = (sbyte)i;
                break;
            }
            if (PartitionIndex == -1)
            {
                return(null);
            }
            if (Folders.Length == 1)
            {
                FATXReadContents xread = new FATXReadContents();
                xread.xfiles = new List <FATXFileEntry>();
                xread.xfolds = new List <FATXFolderEntry>();
                foreach (FATXFolderEntry xz in Partitions[PartitionIndex].Folders)
                {
                    xread.xfolds.Add(xz);
                }
                foreach (FATXPartition xz in Partitions[PartitionIndex].SubPartitions)
                {
                    xread.xsubparts.Add(xz);
                }
                return(xread);
            }
            FATXPartition xcurpart = xPartitions[PartitionIndex];
            int           idx      = 1;

            for (int i = 0; i < xcurpart.SubPartitions.Length; i++)
            {
                if (xcurpart.SubPartitions[i].PartitionName.ToLower() != Folders[1].ToLower())
                {
                    continue;
                }
                xcurpart = xcurpart.SubPartitions[i];
                idx++;
                if (Folders.Length == 2)
                {
                    FATXReadContents xread = new FATXReadContents();
                    xread.xfiles = new List <FATXFileEntry>();
                    xread.xfolds = new List <FATXFolderEntry>();
                    foreach (FATXFolderEntry xz in xcurpart.Folders)
                    {
                        xread.xfolds.Add(xz);
                    }
                    return(xread);
                }
                break;
            }
            FATXFolderEntry xFold = null;

            foreach (FATXFolderEntry x in xcurpart.Folders)
            {
                if (x.Name.ToLower() != Folders[idx].ToLower())
                {
                    continue;
                }
                xFold = x;
                break;
            }
            if (xFold == null)
            {
                return(null);
            }
            idx++;
            FATXReadContents xreadct;

            for (int i = idx; i < Folders.Length; i++)
            {
                bool found = false;
                xreadct = xFold.xRead();
                foreach (FATXFolderEntry x in xreadct.Folders)
                {
                    if (x.Name.ToLower() != Folders[i].ToLower())
                    {
                        continue;
                    }
                    found = true;
                    xFold = x;
                    break;
                }
                if (!found)
                {
                    return(null);
                }
            }
            xFolderOut = xFold;
            return(xFold.xRead());
        }
Esempio n. 9
0
 internal FATXReadContents xReadToFolder(string Path, out FATXFolderEntry xFolderOut)
 {
     xFolderOut = null;
     if (Path == null || Path == "")
         return null;
     Path = Path.Replace("\\", "/");
     if (Path[0] == '/')
         Path = Path.Substring(1, Path.Length - 1);
     if (Path[Path.Length - 1] == '/')
         Path = Path.Substring(0, Path.Length - 1);
     string[] Folders = Path.Split(new char[] { '/' });
     sbyte PartitionIndex = -1;
     for (int i = 0; i < xPartitions.Count; i++)
     {
         if (xPartitions[i].PartitionName.ToLower() != Folders[0].ToLower())
             continue;
         PartitionIndex = (sbyte)i;
         break;
     }
     if (PartitionIndex == -1)
         return null;
     if (Folders.Length == 1)
     {
         FATXReadContents xread = new FATXReadContents();
         xread.xfiles = new List<FATXFileEntry>();
         xread.xfolds = new List<FATXFolderEntry>();
         foreach (FATXFolderEntry xz in Partitions[PartitionIndex].Folders)
             xread.xfolds.Add(xz);
         foreach (FATXPartition xz in Partitions[PartitionIndex].SubPartitions)
             xread.xsubparts.Add(xz);
         return xread;
     }
     FATXPartition xcurpart = xPartitions[PartitionIndex];
     int idx = 1;
     for (int i = 0; i < xcurpart.SubPartitions.Length; i++)
     {
         if (xcurpart.SubPartitions[i].PartitionName.ToLower() != Folders[1].ToLower())
             continue;
         xcurpart = xcurpart.SubPartitions[i];
         idx++;
         if (Folders.Length == 2)
         {
             FATXReadContents xread = new FATXReadContents();
             xread.xfiles = new List<FATXFileEntry>();
             xread.xfolds = new List<FATXFolderEntry>();
             foreach (FATXFolderEntry xz in xcurpart.Folders)
                 xread.xfolds.Add(xz);
             return xread;
         }
         break;
     }
     FATXFolderEntry xFold = null;
     foreach (FATXFolderEntry x in xcurpart.Folders)
     {
         if (x.Name.ToLower() != Folders[idx].ToLower())
             continue;
         xFold = x;
         break;
     }
     if (xFold == null)
         return null;
     idx++;
     FATXReadContents xreadct;
     for (int i = idx; i < Folders.Length; i++)
     {
         bool found = false;
         xreadct = xFold.xRead();
         foreach (FATXFolderEntry x in xreadct.Folders)
         {
             if (x.Name.ToLower() != Folders[i].ToLower())
                 continue;
             found = true;
             xFold = x;
             break;
         }
         if (!found)
             return null;
     }
     xFolderOut = xFold;
     return xFold.xRead();
 }
 public FATXFolderEntry GetFolder(FATXFolderEntry e)
 {
     return GetFolder(e.Path);
 }
Esempio n. 11
0
        public FATXReadContents xReadToFolder(string Path, out FATXFolderEntry xFolderOut)
        {
            xFolderOut = null;

            List <string> findFolders = GetPathFromString(Path);

            if (findFolders == null || findFolders.Count == 0)
            {
                return(null);
            }


            string findPartition = findFolders[0];

            var partition = GetPartition(findPartition);

            if (partition == null)
            {
                return(null);
            }

            int partIndex = GetPartitionIndex(partition);

            if (partIndex == -1)
            {
                return(null);
            }

            var contents = GetPartitionContents(partIndex);

            if (contents == null)
            {
                return(null);
            }

            if (findFolders.Count == 1)
            {
                xFolderOut = new FATXFolderEntry(contents.Folders[0].Parent, contents.Folders[0], Path);
                return(contents);
            }

            findFolders.RemoveAt(0);
            while (findFolders.Count > 0)
            {
                var entry = GetSubEntry(findFolders[0], contents);

                if (entry != null)
                {
                    if (entry.xIsValid)
                    {
                        if (entry.IsFolder)
                        {
                            var fe = entry as FATXFolderEntry;
                            if (fe != null)
                            {
                                xFolderOut = fe;

                                contents = fe.xRead();
                            }
                            else
                            {
                                xFolderOut = null;
                                contents   = null;
                            }
                        }
                        else
                        {
                            var fe = entry as FATXFileEntry;
                            if (fe != null)
                            {
                                xFolderOut      = null;
                                contents        = new FATXReadContents();
                                contents.xfiles = new List <FATXFileEntry>();
                                contents.xfolds = new List <FATXFolderEntry>();
                                contents.xfiles.Add(fe);
                            }
                            else
                            {
                                xFolderOut = null;
                                contents   = null;
                            }
                        }
                    }
                }
                findFolders.RemoveAt(0);
                if (contents == null)
                {
                    return(null);
                }
            }



            return(contents);

            /*
             * if (Folders.Length == 1)
             * {
             *  return partContents;
             * }
             *
             * int curFolder=1;
             *
             *
             *
             * FATXPartition xcurpart = xPartitions[PartitionIndex];
             * int idx = 1;
             * for (int i = 0; i < xcurpart.SubPartitions.Length; i++)
             * {
             *  if (xcurpart.SubPartitions[i].PartitionName.ToLower() != Folders[1].ToLower())
             *      continue;
             *  xcurpart = xcurpart.SubPartitions[i];
             *  idx++;
             *  if (Folders.Length == 2)
             *  {
             *      FATXReadContents xread = new FATXReadContents();
             *      xread.xfiles = new List<FATXFileEntry>();
             *      xread.xfolds = new List<FATXFolderEntry>();
             *      foreach (FATXFolderEntry xz in xcurpart.Folders)
             *          xread.xfolds.Add(xz);
             *      return xread;
             *  }
             *  break;
             * }
             * FATXFolderEntry xFold = null;
             * foreach (FATXFolderEntry x in xcurpart.Folders)
             * {
             *  if (x.Name.ToLower() != Folders[idx].ToLower())
             *      continue;
             *  xFold = x;
             *  break;
             * }
             * if (xFold == null)
             *  return null;
             * idx++;
             * FATXReadContents xreadct;
             * for (int i = idx; i < Folders.Length; i++)
             * {
             *  bool found = false;
             *  xreadct = xFold.xRead();
             *  foreach (FATXFolderEntry x in xreadct.Folders)
             *  {
             *      if (x.Name.ToLower() != Folders[i].ToLower())
             *          continue;
             *      found = true;
             *      xFold = x;
             *      break;
             *  }
             *  if (!found)
             *      return null;
             * }
             * xFolderOut = xFold;
             * return xFold.xRead();*/
        }
Esempio n. 12
0
 private void upDirectoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (textBoxX1.Text == "")
         return;
     listView1.Enabled = false;
     if (textBoxX1.Text.CountOfBreak() == 1)
     {
         setdrive();
         listView1.Enabled = true;
         return;
     }
     status = "Reading Directory";
     string manipulate = textBoxX1.Text.Substring(0, textBoxX1.Text.Length - 1);
     int lastidx = manipulate.LastIndexOf('/');
     if (lastidx != -1)
         manipulate = manipulate.Substring(0, lastidx);
     else manipulate = "";
     FATXFolderEntry xfold = null;
     FATXReadContents x = xDrive.ReadToFolder(manipulate, out xfold);
     if (x == null)
     {
         MessageBox.Show("Error: Bad path?");
         status = "Idle";
         listView1.Enabled = true;
         return;
     }
     LastFolder = xfold;
     listView1.Items.Clear();
     foreach (FATXFolderEntry y in x.Folders)
         listView1.Items.Add(GetItem(y.Name, 1, y));
     foreach (FATXFileEntry y in x.Files)
         listView1.Items.Add(GetItem(y.Name, 2, y));
     foreach (FATXPartition y in x.SubPartitions)
         listView1.Items.Add(GetItem(y.PartitionName, 0, y));
     textBoxX1.Text = manipulate + "/";
     status = "Idle";
     listView1.Enabled = true;
 }
Esempio n. 13
0
 void setview(string locale)
 {
     listView1.Enabled = false;
     status = "Reading Directory";
     FATXFolderEntry xfold = null;
     FATXReadContents x = xDrive.ReadToFolder(locale, out xfold);
     if (x == null)
     {
         MessageBox.Show("Error: Bad path?");
         status = "Idle";
         listView1.Enabled = true;
         return;
     }
     LastFolder = xfold;
     List<ListViewItem> xlist = new List<ListViewItem>();
     foreach (FATXFolderEntry y in x.Folders)
         xlist.Add(GetItem(y.Name, 1, y));
     foreach (FATXFileEntry y in x.Files)
         xlist.Add(GetItem(y.Name, 2, y));
     listView1.Items.Clear();
     listView1.Items.AddRange(xlist.ToArray());
     if (locale[locale.Length - 1] == '/')
         locale = locale.Substring(0, locale.Length - 1);
     textBoxX1.Text = locale + "/";
     listView1.Enabled = true;
     status = "Idle";
 }
Esempio n. 14
0
        private void listView1_DoubleClick(object sender, EventArgs e)
        {
            if (x1 != MouseButtons.Left || x2 != MouseButtons.Left)
                return;
            if (listView1.SelectedItems.Count != 1)
                return;
            listView1.Enabled = false;
            status = "Reading Directory";
            ListViewItem selitem = listView1.SelectedItems[0];
            switch (selitem.ImageIndex)
            {
                case 0:
                    {
                        textBoxX1.Text += ((FATXPartition)selitem.Tag).PartitionName + "/";
                        FATXPartition x = ((FATXPartition)selitem.Tag);
                        List<ListViewItem> xlist = new List<ListViewItem>();
                        foreach (FATXFolderEntry y in x.Folders)
                            xlist.Add(GetItem(y.Name, 1, y));
                        foreach (FATXFileEntry y in x.Files)
                            xlist.Add(GetItem(y.Name, 2, y));
                        for (int i = 0; i < x.SubPartitions.Length; i++)
                            xlist.Add(GetItem(x.SubPartitions[i].PartitionName, 0, x.SubPartitions[i]));
                        listView1.Items.Clear();
                        listView1.Items.AddRange(xlist.ToArray());
                    }
                    break;

                case 1:
                    {
                        LastFolder = ((FATXFolderEntry)selitem.Tag);
                        FATXReadContents x = LastFolder.Read();
                        if (x == null)
                            break;
                        textBoxX1.Text += LastFolder.Name + "/";
                        List<ListViewItem> xlist = new List<ListViewItem>();
                        foreach (FATXFolderEntry y in x.Folders)
                            xlist.Add(GetItem(y.Name, 1, y));
                        foreach (FATXFileEntry y in x.Files)
                            xlist.Add(GetItem(y.Name, 2, y));
                        listView1.Items.Clear();
                        listView1.Items.AddRange(xlist.ToArray());
                    }
                    break;

                default: break;
            }
            status = "Idle";
            listView1.Enabled = true;
        }
Esempio n. 15
0
 private void goToToolStripMenuItem_Click(object sender, EventArgs e)
 {
     GoToDialog x = new GoToDialog();
     if (x.ShowDialog() != DialogResult.OK)
         return;
     listView1.Enabled = false;
     status = "Reading Directory";
     FATXFolderEntry xfold;
     FATXReadContents z = xDrive.ReadToFolder(x.ChosenPath, out xfold);
     if (z == null)
     {
         MessageBox.Show("Error: Bad path?");
         status = "Idle";
         listView1.Enabled = true;
         return;
     }
     LastFolder = xfold;
     List<ListViewItem> xlist = new List<ListViewItem>();
     foreach (FATXFolderEntry u in z.Folders)
         xlist.Add(GetItem(u.Name, 1, u));
     foreach (FATXFileEntry u in z.Files)
         xlist.Add(GetItem(u.Name, 2, u));
     foreach (FATXPartition u in z.SubPartitions)
         xlist.Add(GetItem(u.PartitionName, 0, u));
     listView1.Items.Clear();
     listView1.Items.AddRange(xlist.ToArray());
     textBoxX1.Text = x.ChosenPath + "/";
     status = "Idle";
     listView1.Enabled = true;
 }