コード例 #1
0
        async void ShareBill(object sender, EventArgs args)
        {
            ViewHare.IsEnabled = false;
            try
            {
                if (_file != null)
                {
                    await DependencyService.Get <IFileWorker>().SaveTextAsync(_filename, _file);

                    FileBase fileBase = new ReadOnlyFile(DependencyService.Get <IFileWorker>().GetFilePath(_filename));
                    await Xamarin.Essentials.Share.RequestAsync(new ShareFileRequest(AppResources.ShareBill, fileBase));
                }
                else
                {
                    await DisplayAlert(null, AppResources.ErrorFileLoading, "OK");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                ViewHare.IsEnabled = true;
            }
        }
コード例 #2
0
ファイル: ReadOnlyFileUnitTest.cs プロジェクト: klopsiQ88/TP
        public void EndsWithPropertyNameTest()
        {
            InitFile();
            dynamic _rFile = new ReadOnlyFile(TestFilePath);

            foreach (string line in _rFile.Patrick(StringSearchOption.StartsWith, true))
            {
                Assert.IsTrue(line.ToUpper().EndsWith("Patrick".ToUpper()));
            }
        }
コード例 #3
0
ファイル: ReadOnlyFileUnitTest.cs プロジェクト: klopsiQ88/TP
        public void ContainsPropertyNameTest()
        {
            InitFile();
            dynamic _rFile = new ReadOnlyFile(TestFilePath);

            foreach (string line in _rFile.Customer(StringSearchOption.Contains, true))
            {
                Assert.IsTrue(line.ToUpper().Contains("Customer".ToUpper()));
            }
        }
コード例 #4
0
        public void FtpFileReadTest()
        {
            ReadOnlyFile ftpFile = new ReadOnlyFile("ftp://speedtest.tele2.net/1KB.zip");

            using (ReadOnlyStream s = ftpFile.Open())
            {
                byte[] data = s.ReadAllBytes();
                Assert.AreEqual(data.Length, 0x400);
                Assert.IsFalse(s.CanWrite);

                var temp = Utility.GetTempFilePath();
                ftpFile.Copy(temp);
                Assert.IsTrue(data.IsEqual(File.ReadAllBytes(temp)));
                File.Delete(temp);
            }
        }
コード例 #5
0
        public void LocalFileReadTest()
        {
            ReadOnlyFile localFile = new ReadOnlyFile(@"C:\Windows\notepad.exe");

            using (ReadOnlyStream s = localFile.Open())
            {
                byte[] data = s.ReadAllBytes();
                Assert.IsTrue(s.Length > 0);
                Assert.AreEqual(data.Length, s.Length);
                Assert.IsFalse(s.CanWrite);

                var temp = Utility.GetTempFilePath();
                localFile.Copy(temp);
                Assert.IsTrue(data.IsEqual(File.ReadAllBytes(temp)));
                File.Delete(temp);
            }
        }
コード例 #6
0
ファイル: ReadOnlyFileUnitTest.cs プロジェクト: klopsiQ88/TP
 public void CtorNotExistingFileTest()
 {
     ReadOnlyFile _readOnlyFile = new ReadOnlyFile("$$$.%%%");
 }
コード例 #7
0
 public OpenFileRequest(string title, FileBase file)
 {
     Title = title;
     File  = new ReadOnlyFile(file);
 }
コード例 #8
0
 public OpenFileRequest(string title, ReadOnlyFile file)
 {
     Title = title;
     File  = file;
 }
コード例 #9
0
        /// <summary>
        /// Rename extracted files based on Wise installer names
        /// </summary>
        /// <param name="outputPath">Output directory for extracted files</param>
        private void RenameFiles(string outputPath)
        {
            ReadOnlyFile extractedFile = null;
            string       newName       = string.Empty;
            long         l;
            int          sh0, sh1, l1, l2, l3 = 0, l4, l5;

            int res     = 1;
            int instcnt = 0;
            int fileno  = 1;

            for (; fileno < extracted && fileno < 6 && res != 0; fileno++)
            {
                extractedFile = new ReadOnlyFile(outputPath, $"WISE{fileno.ToString("X").PadLeft(4, '0')}");
                l             = 0;
                while (res != 0 && l < extractedFile.Length)
                {
                    while (l < extractedFile.Length && (extractedFile.ReadByte(l + 0) != 0x25 || extractedFile.ReadByte(l + 1) != 0x5c))
                    {
                        l++;
                    }

                    if (l < extractedFile.Length)
                    {
                        l1 = 1;
                        while (l1 < 0x40 && (extractedFile.ReadByte(l - l1 + 0) != 0x25 || extractedFile.ReadByte(l - l1 + 1) == 0x5c))
                        {
                            l1++;
                        }

                        if (l1 < 0x40)
                        {
                            res = 0;
                        }
                        else
                        {
                            l++;
                        }
                    }
                }

                if (res != 0)
                {
                    extractedFile.Close();
                }
            }

            if (fileno < 6 && fileno < extracted)
            {
                ReadOnlyFile df = new ReadOnlyFile(outputPath, "WISE0000");
                l5 = (int)((df.Length - 0x4) / 0x4);

                do
                {
                    do
                    {
                        l1  = df.ReadInt32(l5 * 0x4 - 0x4);
                        l2  = df.ReadInt32(l5 * 0x4 - 0);
                        l   = extractedFile.Length - 0x7;
                        res = 1;

                        while (l >= 0 && res != 0)
                        {
                            l -= 1;
                            l3 = extractedFile.ReadInt32(l + 0);
                            l4 = extractedFile.ReadInt32(l + 0x4);
                            if (l4 > l3 && l4 < l2 && l3 < l1 && l4 - l3 == l2 - l1)
                            {
                                res = 0;
                            }
                        }

                        if (res != 0)
                        {
                            l5 -= 1;
                        }
                    }while (res != 0 && l5 != 0);

                    sh0 = l1 - l3;

                    if (res == 0)
                    {
                        do
                        {
                            l1  = df.ReadInt32(l5 * 0x4 - 0x4);
                            l2  = df.ReadInt32(l5 * 0x4 - 0);
                            l   = extractedFile.Length - 0x7;
                            res = 1;
                            while (l >= 0 && res != 0)
                            {
                                l -= 1;
                                l3 = extractedFile.ReadInt32(l + 0);
                                l4 = extractedFile.ReadInt32(l + 0x4);
                                if (l4 > l3 && l4 < l2 && l3 < l1 && l4 - l3 == l2 - l1)
                                {
                                    res = 0;
                                }
                            }

                            if (res != 0)
                            {
                                l5 -= 1;
                            }
                        }while (res != 0 && l5 != 0);
                    }

                    sh1 = l1 - l3;
                }while (l5 != 0 && (res != 0 || sh0 != sh1));

                if (res == 0)
                {
                    /* shiftvalue = sh0 */
                    l5 = -0x4;
                    while (l5 + 8 < df.Length)
                    {
                        l5 += 0x4;
                        l1  = df.ReadInt32(l5 + 0);
                        l2  = df.ReadInt32(l5 + 0x4);
                        uint l0 = 0xffffffff;
                        res = 1;
                        while (l0 + 0x29 < extractedFile.Length && res != 0)
                        {
                            l0 += 1;
                            l3  = extractedFile.ReadInt32(l0 + 0);
                            l4  = extractedFile.ReadInt32(l0 + 0x4);
                            if (l1 == l3 + sh0 && l2 == l4 + sh0)
                            {
                                res = 0;
                            }
                        }

                        int offset = 0;
                        if (res == 0)
                        {
                            l2      = extractedFile.ReadInt16(l0 - 2);
                            newName = "";
                            offset  = (int)l0;
                            l0     += 0x28;
                            res     = 2;
                            if (extractedFile.ReadByte(l0) == 0x25)
                            {
                                while (extractedFile.ReadByte(l0) != 0)
                                {
                                    newName = newName + (char)extractedFile.ReadByte(l0);
                                    if (extractedFile.ReadByte(l0) < 0x20)
                                    {
                                        res = 1;
                                    }

                                    if (extractedFile.ReadByte(l0) == 0x25 && res != 1)
                                    {
                                        res = 3;
                                    }

                                    if (extractedFile.ReadByte(l0) == 0x5c && extractedFile.ReadByte(l0 - 1) == 0x25 && res == 3)
                                    {
                                        res = 4;
                                    }

                                    if (res == 4)
                                    {
                                        res = 0;
                                    }

                                    l0++;
                                }
                            }

                            if (res != 0)
                            {
                                res = 0x80;
                            }
                        }

                        l1 = (l5 + 0x4) / 0x4;
                        if (res == 0)
                        {
                            newName = newName
                                      .Replace("%", string.Empty)
                                      .Replace("\\\\", "\\")
                                      .Replace('\\', Path.DirectorySeparatorChar);

                            newName = Path.Combine(outputPath, newName);

                            string fname = Path.Combine(outputPath, $"WISE{l1.ToString("X").PadLeft(4, '0')}");

                            /* Make directories */
                            string nnDir = Path.GetDirectoryName(newName);
                            Directory.CreateDirectory(nnDir);

                            /* Rename file */
                            File.Delete(newName);
                            File.Move(fname, newName);
                            var dt = extractedFile.ReadDateTime(offset + 0x8);
                            File.SetCreationTime(newName, dt);
                            File.SetLastWriteTime(newName, dt);
                        }
                        else if (res == 0x80)
                        {
                            instcnt++;

                            /* Rename file */
                            File.Delete(Path.Combine(outputPath, $"INST{instcnt.ToString("X").PadLeft(4, '0')}"));
                            File.Move(Path.Combine(outputPath, $"WISE{l1.ToString("X").PadLeft(4, '0')}"),
                                      Path.Combine(outputPath, $"INST{instcnt.ToString("X").PadLeft(4, '0')}"));
                        }
                    }
                }

                df.Close();
                extractedFile.Close();
            }
        }
コード例 #10
0
 public OpenFileRequest(string title, FileBase file)
 {
     ExperimentalFeatures.VerifyEnabled(ExperimentalFeatures.OpenFileRequest);
     Title = title;
     File = new ReadOnlyFile(file);
 }