GetFullPath() public static méthode

public static GetFullPath ( string path ) : string
path string
Résultat string
Exemple #1
0
 public void getPaths()
 {
     try
     {
         if (Classes.Prefrences.CommonPathsStorage.Collection.ModLoaderConfigs != null && Classes.Prefrences.CommonPathsStorage.Collection.ModLoaderConfigsNames != null)
         {
             Classes.Prefrences.CommonPathsStorage.Collection.ModLoaderConfigs.Clear();
             Classes.Prefrences.CommonPathsStorage.Collection.ModLoaderConfigsNames.Clear();
         }
         string[] filePaths = Directory.GetFiles(Path.GetFullPath(Environment.CurrentDirectory + "\\Config\\"), "*.ini", SearchOption.TopDirectoryOnly);
         if (filePaths != null)
         {
             foreach (string file in filePaths)
             {
                 string config   = File.ReadAllText(file);
                 string fileName = file.Substring(file.LastIndexOf("\\") + 1);
                 if (Classes.Prefrences.CommonPathsStorage.Collection.ModLoaderConfigs == null)
                 {
                     Classes.Prefrences.CommonPathsStorage.Collection.ModLoaderConfigs = new StringCollection();
                 }
                 addModConfig(config);
                 addModConfigName(fileName);
             }
         }
     }
     catch (System.IO.DirectoryNotFoundException)
     {
         return;
     }
 }
Exemple #2
0
            public void TestXamlGenerator()
            {
                string xamlInputFile  = CreateXamlInputFile();
                string xamlOutputFile = IOPath.GetTempFileName();
                var    item           = new TaskItem(xamlInputFile);

                item.SetMetadata("TargetPath", xamlInputFile);

                string testAssemblyBinPath =
#if DEBUG
                    "Debug";
#else
                    "Release";
#endif

                var dir = IOPath.GetFullPath(
                    IOPath.Combine(
                        TestContext.CurrentContext.TestDirectory, "Xamarin.Forms.Controls.dll"));
                var xamlg = new XamlGTask()
                {
                    BuildEngine  = new DummyBuildEngine(),
                    AssemblyName = "test",
                    Language     = "C#",
                    XamlFiles    = new[] { item },
                    OutputFiles  = new[] { new TaskItem(xamlOutputFile) },
                    References   = dir
                };

                var generator = new XamlGenerator(item, xamlg.Language, xamlg.AssemblyName, xamlOutputFile, xamlg.References, null);
                Assert.IsTrue(generator.Execute());

                Assert.IsTrue(xamlg.Execute());
            }
Exemple #3
0
        private void FileDrop(string[] files)
        {
            if (files == null || files.Length == 0)
            {
                return;
            }
            var validFiles = new List <string>();

            validFiles.AddRange(files.Where(f => Path.GetExtension(f) == ".ass"));
            if (validFiles.Count == 0)
            {
                return;
            }
            for (int i = 0; i < validFiles.Count(); ++i)
            {
                validFiles[i] = Path.GetFullPath(validFiles[i]);
            }

            this.AssFileList.ItemsSource = validFiles;
            string dir = Path.GetDirectoryName(validFiles[0]);

            this.FontFolder.Text   = dir + "\\fonts";
            this.OutputFolder.Text = dir + "\\output";

            this.FontFolder.Select(this.FontFolder.Text.Length - 1, 0);
            this.OutputFolder.Select(this.OutputFolder.Text.Length - 1, 0);
        }
Exemple #4
0
        //https://bugzilla.xamarin.com/show_bug.cgi?id=33256
        public void AlwaysUseGlobalReference()
        {
            var xaml = @"
			<ContentPage
				xmlns=""http://xamarin.com/schemas/2014/forms""
				xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
				x:Class=""FooBar"" >
				<Label x:Name=""label0""/>
			</ContentPage>"            ;

            using (var reader = new StringReader(xaml))
            {
                var references = string.Join(";",
                                             IOPath.GetFullPath(
                                                 IOPath.Combine(
                                                     TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.dll")),
                                             IOPath.GetFullPath(
                                                 IOPath.Combine(
                                                     TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.Controls.dll"))
                                             );

                var generator = new XamlGenerator(null, null, null, null, null, null, references);
                generator.ParseXaml(reader);

                Assert.IsTrue(generator.BaseType.Options.HasFlag(CodeTypeReferenceOptions.GlobalReference));
                Assert.IsTrue(generator.NamedFields.Select(cmf => cmf.Type).First().Options.HasFlag(CodeTypeReferenceOptions.GlobalReference));
            }
        }
Exemple #5
0
        //https://github.com/xamarin/Microsoft.Maui.Controls/issues/2574
        public void xNameOnRoot()
        {
            var xaml = @"<ContentPage
		xmlns=""http://xamarin.com/schemas/2014/forms""
		xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
		x:Class=""Foo""
		x:Name=""bar"">
	</ContentPage>"    ;

            var references = string.Join(";",
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.dll")),
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.Controls.dll"))
                                         );

            var generator = new XamlGenerator(null, null, null, null, null, null, references);

            generator.ParseXaml(new StringReader(xaml));

            Assert.AreEqual(1, generator.NamedFields.Count());
            Assert.AreEqual("bar", generator.NamedFields.First().Name);
            Assert.AreEqual("Microsoft.Maui.Controls.ContentPage", generator.NamedFields.First().Type.BaseType);
        }
        string FindConfigureScript(string startpath)
        {
            if (String.IsNullOrEmpty(startpath))
            {
                return(null);
            }

            string path = startpath;

            while (true)
            {
                string fname = SPath.Combine(path, "configure.in");
                if (File.Exists(fname))
                {
                    return(fname);
                }

                fname = SPath.Combine(path, "configure.ac");
                if (File.Exists(fname))
                {
                    return(fname);
                }

                string parentpath = SPath.GetFullPath(SPath.Combine(path, ".."));
                if (parentpath == path)
                {
                    //reached root
                    return(null);
                }

                path = parentpath;
            }
        }
Exemple #7
0
        public void MulipleXTypeArgumentsOnRootElementWithWhitespace()
        {
            var xaml   = @"<ObservableWrapper 
						    xmlns=""http://xamarin.com/schemas/2014/forms""
						    xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
							x:Class=""FooBar"" 
							x:TypeArguments=""x:String, x:Int32""
			/>"            ;
            var reader = new StringReader(xaml);

            var references = string.Join(";",
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.dll")),
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.Controls.dll"))
                                         );

            var generator = new XamlGenerator(null, null, null, null, null, null, references);

            generator.ParseXaml(reader);

            Assert.AreEqual("FooBar", generator.RootType);
            Assert.AreEqual("Microsoft.Maui.Controls.ObservableWrapper`2", generator.BaseType.BaseType);
            Assert.AreEqual(2, generator.BaseType.TypeArguments.Count);
            Assert.AreEqual("System.String", generator.BaseType.TypeArguments[0].BaseType);
            Assert.AreEqual("System.Int32", generator.BaseType.TypeArguments[1].BaseType);
        }
Exemple #8
0
        private void ButtonDefaultPreviewPath_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new Microsoft.Win32.SaveFileDialog();

            try
            {
                var initial = Path.GetFullPath(TxtBoxDefaultPreviewPath.Text);
                dialog.InitialDirectory = Path.GetDirectoryName(initial);
            }
            catch
            {
                dialog.InitialDirectory = "";
            }
            dialog.Title    = "Select default preview output directory";
            dialog.Filter   = "Directory|*.this.directory";
            dialog.FileName = "select";
            var result = dialog.ShowDialog();

            if (result == true)
            {
                var path      = dialog.FileName;
                var outputDir = Path.GetDirectoryName(Path.GetFullPath(path));
                if (Directory.Exists(outputDir))
                {
                    Properties.Settings.Default.defaultPreviewPath = outputDir;
                    PrefsHaveChanged = true;
                }
            }
        }
        public static void ExtractZipFileToDirectory(string sourceZipFilePath, string destinationDirectoryName, bool overwrite)
        {
            using (var archive = ZipFile.Open(sourceZipFilePath, ZipArchiveMode.Read))
            {
                if (!overwrite)
                {
                    archive.ExtractToDirectory(destinationDirectoryName);
                    return;
                }

                DirectoryInfo di = Directory.CreateDirectory(destinationDirectoryName);
                string        destinationDirectoryFullPath = di.FullName;

                foreach (ZipArchiveEntry file in archive.Entries)
                {
                    string completeFileName = Path.GetFullPath(Path.Combine(destinationDirectoryFullPath, file.FullName));

                    if (!completeFileName.StartsWith(destinationDirectoryFullPath, StringComparison.OrdinalIgnoreCase))
                    {
                        throw new IOException("Trying to extract file outside of destination directory. See this link for more info: https://snyk.io/research/zip-slip-vulnerability");
                    }

                    if (file.Name == "")
                    {// Assuming Empty for Directory
                        Directory.CreateDirectory(Path.GetDirectoryName(completeFileName));
                        continue;
                    }
                    file.ExtractToFile(completeFileName, true);
                }
            }
        }
        static string CreateScriptAsset(string pathName, string text)
        {
            string fullPath = Path.GetFullPath(pathName);

            fullPath = fullPath.Replace('\\', '/');
            var assetRelativePath = fullPath;

            if (fullPath.StartsWith(Application.dataPath))
            {
                assetRelativePath = fullPath.Substring(Application.dataPath.Length - 6);
            }
            var directoryPath = Path.GetDirectoryName(fullPath);

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }
            UTF8Encoding encoding     = new UTF8Encoding(true, false);
            StreamWriter streamWriter = null;

            streamWriter = new StreamWriter(fullPath, false, encoding);
            streamWriter.Write(text);
            streamWriter.Close();
            AssetDatabase.ImportAsset(assetRelativePath);
            return(assetRelativePath);
        }
Exemple #11
0
        private void ButtonFfmpegBinaryPath_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog();

            try
            {
                var initial = Path.GetFullPath(TxtBoxFfmpegBinaryPath.Text);
                dialog.InitialDirectory = Path.GetDirectoryName(initial);
            }
            catch
            {
                dialog.InitialDirectory = "";
            }
            dialog.Title    = "Select ffmpeg.exe binary";
            dialog.Filter   = "ffmpeg Executable|*.exe";
            dialog.FileName = "ffmpeg.exe";
            var result = dialog.ShowDialog();

            if (result == true)
            {
                string path = dialog.FileName;
                if (File.Exists(path))
                {
                    Properties.Settings.Default.ffmpegBinaryPath = path;
                    PrefsHaveChanged = true;
                }
            }
        }
Exemple #12
0
        //End of month submission report output
        private void submitButton_Click(object sender, RoutedEventArgs e)
        {
            if (nameTextBox.Text != "" || vehicleNumberTextBox.Text != "")
            {
                Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
                sfd.FileName   = "Sample.pdf";
                sfd.DefaultExt = ".pdf";
                sfd.Filter     = "PDF documents (.pdf)|*.pdf";

                bool?result = sfd.ShowDialog();

                if (result == true)
                {
                    string filename = sfd.FileName;
                    string filePath = Path.GetFullPath(sfd.FileName);
                    createPdfReport(Path.Combine(filePath, filename));
                    displayMessageBox("Information", "Report successfully created!", "");
                    resetInputFields("PDF");
                }
            }
            else
            {
                displayMessageBox("Error", "Input fields cannot be left blanked!", "Error");
            }
        }
 public BitmapImage DecodeTempQRFile(string data)
 {
     try
     {
         BitmapImage bitmapImage   = new BitmapImage();
         string      retrievedPath = Path.GetFullPath(TempFolder + data + @".tmp");
         using (MemoryStream ms = new MemoryStream())
         {
             try
             {
                 byte[] buffer = File.ReadAllBytes(retrievedPath);
                 ms.Write(buffer, 0, buffer.Length);
                 bitmapImage.BeginInit();
                 bitmapImage.StreamSource = ms;
                 bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                 bitmapImage.EndInit();
             }
             catch (Exception e)
             {
                 Console.WriteLine(e);
             }
         }
         return(bitmapImage);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(null);
     }
 }
        public MainWindow()
        {
            InitializeComponent();

            DestinationPathTextBox.Text = DestinationFolder;

            var projects = new List <TemplateProject>();
            //var sourcePath = Environment.GetCommandLineArgs()[1];
            var sourcePath = DefaultSourcePath;
            var folders    = Directory.GetDirectories(sourcePath);
            var files      = Directory.GetFiles(sourcePath);

            foreach (var relativepathtempl in folders)
            {
                projects.Add(new TemplateProject(
                                 Path.GetFileName(relativepathtempl),
                                 Path.GetFullPath(relativepathtempl),
                                 FileOrFolder.Folder));
            }
            foreach (var relativepathtempl in files)
            {
                projects.Add(new TemplateProject(
                                 Path.GetFileName(relativepathtempl),
                                 Path.GetFullPath(relativepathtempl),
                                 FileOrFolder.File));
            }

            ListBoxTest.ItemsSource = projects;
        }
Exemple #15
0
        public static string GetPath(string name)
        {
            var key = name.ToLower();

            if (UserPaths.ContainsKey(key))
            {
                if (Path.IsPathRooted(UserPaths[key]))
                {
                    return(UserPaths[key]);
                }
                return(Path.GetFullPath(RootPath + Path.DirectorySeparatorChar + UserPaths[key]));
            }

            if (Paths.ContainsKey(key))
            {
                if (Path.IsPathRooted(Paths[key]))
                {
                    return(Paths[key]);
                }
                return(Path.GetFullPath(RootPath + Path.DirectorySeparatorChar + Paths[key]));
            }

            var stackTrace = new StackTrace();
            var method     = stackTrace.GetFrame(1).GetMethod();

            Debug.Log("Configuration", "Path \"" + name + "\" is not present. (called by: " + method.DeclaringType.FullName + "::" + method.Name + ")", Debug.Type.Warning);
            return("");
        }
        private static string GetFullPath(string filename)
        {
            if (filename == null)
            {
                return(null);
            }

            try
            {
                return(Path.GetFullPath(filename));
            }
            catch (ArgumentException)
            {
                return(null);
            }
            catch (SecurityException)
            {
                return(null);
            }
            catch (NotSupportedException)
            {
                return(null);
            }
            catch (PathTooLongException)
            {
                return(null);
            }
        }
Exemple #17
0
 static string FindConfiguration(string path)
 {
     path = Path.GetFullPath(path);
     if (File.Exists(path + Path.DirectorySeparatorChar + ConfigurationFile))
     {
         RootPath = path;
         Paths.Add("root", path);
         return(path + Path.DirectorySeparatorChar + ConfigurationFile);
     }
     try
     {
         var newPath = Directory.GetParent(path).FullName;
         if (newPath != path)
         {
             return(FindConfiguration(newPath));
         }
         Debug.Log("Configuration", "Couldn't find configuration.");
         return("");
     }
     catch (Exception ex)
     {
         Debug.Log("Configuration", "Unexpected exception while searching for configuration: " + ex);
         return("");
     }
 }
Exemple #18
0
        public void xTypeArgumentsOnRootElement()
        {
            var xaml   = @"<Layout 
						    xmlns=""http://xamarin.com/schemas/2014/forms""
						    xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
							x:Class=""FooBar"" 
							x:TypeArguments=""x:String""
			/>"            ;
            var reader = new StringReader(xaml);

            var references = string.Join(";",
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Xamarin.Forms.Controls.dll")),
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Xamarin.Forms.Core.dll"))
                                         );

            var generator = new XamlGenerator(null, null, null, null, null, null, references);

            generator.ParseXaml(reader);

            Assert.AreEqual("FooBar", generator.RootType);
            Assert.AreEqual("Xamarin.Forms.Layout`1", generator.BaseType.BaseType);
            Assert.AreEqual(1, generator.BaseType.TypeArguments.Count);
            Assert.AreEqual("System.String", generator.BaseType.TypeArguments[0].BaseType);
        }
Exemple #19
0
        /// <summary>
        /// Rebases file with path fromPath to folder with baseDir.
        /// </summary>
        /// <param name="_fromPath">Full file path (absolute)</param>
        /// <param name="_baseDir">Full base directory path (absolute)</param>
        /// <returns>Relative path to file in respect of baseDir</returns>
        static public String MakeRelative(String _fromPath, String _baseDir)
        {
            String pathSep  = "\\";
            String fromPath = Path.GetFullPath(_fromPath);
            String baseDir  = Path.GetFullPath(_baseDir);           // If folder contains upper folder references, they gets lost here. "c:\test\..\test2" => "c:\test2"

            String[] p1 = Regex.Split(fromPath, "[\\\\/]").Where(x => x.Length != 0).ToArray();
            String[] p2 = Regex.Split(baseDir, "[\\\\/]").Where(x => x.Length != 0).ToArray();
            int      i  = 0;

            for (; i < p1.Length && i < p2.Length; i++)
            {
                if (String.Compare(p1[i], p2[i], true) != 0)    // Case insensitive match
                {
                    break;
                }
            }

            if (i == 0)     // Cannot make relative path, for example if resides on different drive
            {
                return(fromPath);
            }

            String r = String.Join(pathSep, Enumerable.Repeat("..", p2.Length - i).Concat(p1.Skip(i).Take(p1.Length - i)));

            return(r);
        }
        public List <ImageView> GetImageViews(View view, string defectId, Boolean Open)
        {
            string folder = Android.OS.Environment.
                            GetExternalStoragePublicDirectory(
                Android.OS.Environment.DirectoryDocuments).ToString() + Java.IO.File.Separator + defectId + Java.IO.File.Separator + "issueResolvedImages_image";

            if (Open)
            {
                folder = Android.OS.Environment.
                         GetExternalStoragePublicDirectory(
                    Android.OS.Environment.DirectoryDocuments).ToString() + Java.IO.File.Separator + defectId + Java.IO.File.Separator + "issueOpenImages_image";
            }

            List <ImageView> imageViewList = new List <ImageView>();
            //fetch image from server here
            var    filesList = Directory.GetFiles(folder);
            string path      = "";
            Bitmap bmp       = null;

            foreach (var file in filesList)
            {
                var filename = Path.GetFileName(file);
                path = Path.GetFullPath(file);
                bmp  = BitmapFactory.DecodeFile(path);
                ImageView imageView = new ImageView(view.Context);
                imageView.SetImageBitmap(bmp);
                imageViewList.Add(imageView);
            }
            return(imageViewList);
        }
Exemple #21
0
        public void MulipleXTypeArgumentsMulitpleNamespacesOnRootElementWithWhitespace()
        {
            var xaml   = @"<ObservableWrapper 
						    xmlns=""http://xamarin.com/schemas/2014/forms""
						    xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
							x:Class=""FooBar"" 
							x:TypeArguments=""nsone:IDummyInterface, nstwo:IDummyInterfaceTwo""
							xmlns:nsone=""clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests.Bugzilla24258.Interfaces""
							xmlns:nstwo=""clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests.Bugzilla24258.InterfacesTwo""

			/>"            ;
            var reader = new StringReader(xaml);

            var references = string.Join(";",
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.dll")),
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.Controls.dll"))
                                         );

            var generator = new XamlGenerator(null, null, null, null, null, null, references);

            generator.ParseXaml(reader);

            Assert.AreEqual("FooBar", generator.RootType);
            Assert.AreEqual("Microsoft.Maui.Controls.ObservableWrapper`2", generator.BaseType.BaseType);
            Assert.AreEqual(2, generator.BaseType.TypeArguments.Count);
            Assert.AreEqual("Microsoft.Maui.Controls.Xaml.UnitTests.Bugzilla24258.Interfaces.IDummyInterface", generator.BaseType.TypeArguments[0].BaseType);
            Assert.AreEqual("Microsoft.Maui.Controls.Xaml.UnitTests.Bugzilla24258.InterfacesTwo.IDummyInterfaceTwo", generator.BaseType.TypeArguments[1].BaseType);
        }
Exemple #22
0
        /// <summary>
        /// Gets the correct path to the formats directory.
        /// </summary>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        private static string GetFontsDirectory()
        {
            var directories = new List <string> {
                "TestFonts/",                                         // Here for code coverage tests.
                "tests/ImageSharp.Drawing.Tests/TestFonts/",          // from travis/build script
                "../../../../../ImageSharp.Drawing.Tests/TestFonts/", // from Sandbox46
                "../../../../TestFonts/"
            };

            directories = directories.SelectMany(x => new[]
            {
                IOPath.GetFullPath(x)
            }).ToList();

            AddFormatsDirectoryFromTestAssemblyPath(directories);

            string directory = directories.FirstOrDefault(Directory.Exists);

            if (directory != null)
            {
                return(directory);
            }

            throw new System.Exception($"Unable to find Fonts directory at any of these locations [{string.Join(", ", directories)}]");
        }
Exemple #23
0
        public void FieldModifier()
        {
            var xaml = @"
			<ContentPage xmlns=""http://xamarin.com/schemas/2014/forms""
			             xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
			             xmlns:local=""clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests""
			             x:Class=""Microsoft.Maui.Controls.Xaml.UnitTests.FieldModifier"">
				<StackLayout>
			        <Label x:Name=""privateLabel"" />
			        <Label x:Name=""internalLabel"" x:FieldModifier=""NotPublic"" />
			        <Label x:Name=""publicLabel"" x:FieldModifier=""Public"" />
				</StackLayout>
			</ContentPage>"            ;

            using (var reader = new StringReader(xaml))
            {
                var references = string.Join(";",
                                             IOPath.GetFullPath(
                                                 IOPath.Combine(
                                                     TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.dll")),
                                             IOPath.GetFullPath(
                                                 IOPath.Combine(
                                                     TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.Controls.dll"))
                                             );

                var generator = new XamlGenerator(null, null, null, null, null, null, references);
                generator.ParseXaml(reader);

                Assert.That(generator.NamedFields.First(cmf => cmf.Name == "privateLabel").Attributes, Is.EqualTo(MemberAttributes.Private));
                Assert.That(generator.NamedFields.First(cmf => cmf.Name == "internalLabel").Attributes, Is.EqualTo(MemberAttributes.Assembly));
                Assert.That(generator.NamedFields.First(cmf => cmf.Name == "publicLabel").Attributes, Is.EqualTo(MemberAttributes.Public));
            }
        }
Exemple #24
0
        // ExternalTokenHelperPath takes the configured path to a helper and expands it to
        // a full absolute path that can be executed. As of 0.5, the default token
        // helper is internal, to avoid problems running in dev mode (see GH-850 and
        // GH-783), so special assumptions of prepending "vault token-" no longer
        // apply.
        //
        // As an additional result, only absolute paths are now allowed. Looking in the
        // path or a current directory for an arbitrary executable could allow someone
        // to switch the expected binary for one further up the path (or in the current
        // directory), potentially opening up execution of an arbitrary binary.
        //~ func ExternalTokenHelperPath(path string) (string, error) {
        public static string ExternalTokenHelperPath(string path)
        {
            //~ if !filepath.IsAbs(path) {
            //~     var err error
            //~     path, err = filepath.Abs(path)
            //~     if err != nil {
            //~         return "", err
            //~     }
            //~ }
            if (!IOPath.IsPathRooted(path))
            {
                path = IOPath.GetFullPath(path);
            }

            //~ if _, err := os.Stat(path); err != nil {
            //~     return "", fmt.Errorf("unknown error getting the external helper path")
            //~ }
            //~
            //~ return path, nil
            if (File.Exists(path))
            {
                new FileInfo(path);
            }
            else if (Directory.Exists(path))
            {
                new DirectoryInfo(path);
            }
            else
            {
                throw new System.IO.FileNotFoundException();
            }

            return(path);
        }
Exemple #25
0
        public void LoadXaml2009()
        {
            var xaml = @"<View
					xmlns=""http://xamarin.com/schemas/2014/forms""
					xmlns:x=""http://schemas.microsoft.com/winfx/2009/xaml""
					x:Class=""Microsoft.Maui.Controls.Xaml.UnitTests.CustomView"" >
						<Label x:Name=""label0""/>
					</View>"                    ;

            var reader = new StringReader(xaml);

            var references = string.Join(";",
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.dll")),
                                         IOPath.GetFullPath(
                                             IOPath.Combine(
                                                 TestContext.CurrentContext.TestDirectory, "Microsoft.Maui.Controls.dll"))
                                         );

            var generator = new XamlGenerator(null, null, null, null, null, null, references);

            generator.ParseXaml(reader);
            Assert.NotNull(generator.RootType);
            Assert.NotNull(generator.RootClrNamespace);
            Assert.NotNull(generator.BaseType);
            Assert.NotNull(generator.NamedFields);

            Assert.AreEqual("CustomView", generator.RootType);
            Assert.AreEqual("Microsoft.Maui.Controls.Xaml.UnitTests", generator.RootClrNamespace);
            Assert.AreEqual("Microsoft.Maui.Controls.View", generator.BaseType.BaseType);
            Assert.AreEqual(1, generator.NamedFields.Count());
            Assert.AreEqual("label0", generator.NamedFields.First().Name);
            Assert.AreEqual("Microsoft.Maui.Controls.Label", generator.NamedFields.First().Type.BaseType);
        }
Exemple #26
0
        private void UploadFile(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.Multiselect      = true;
            dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            if (dlg.ShowDialog() == true)
            {
                foreach (string filename in dlg.FileNames)
                {
                    FileInfo fi   = new FileInfo(filename);
                    var      size = fi.Length;
                    Trace.Write(size);
                    if (size > 50000000)
                    {
                        MessageBoxEx.Show(new MainWindow().Wind(), "File size ERROR: all files must be under 5MB");
                        return;
                    }
                }
                foreach (string filename in dlg.FileNames)
                {
                    lbFiles.Items.Add(Path.GetFileName(filename));
                    lbFilesPath.Items.Add(Path.GetFullPath(filename));
                    lbFilesName.Items.Add(filename);
                    clear.Visibility = Visibility.Visible;
                }
                Settings.Default.Files1 = JsonConvert.SerializeObject(lbFilesName.Items);
                Settings.Default.Save();
            }
        }
Exemple #27
0
        public static string GetInklecateFilePath()
        {
            if (InkSettings.Instance.customInklecateOptions.inklecate != null)
            {
                return(Path.GetFullPath(AssetDatabase.GetAssetPath(InkSettings.Instance.customInklecateOptions.inklecate)));
            }
            else
            {
                                #if UNITY_EDITOR
                                #if UNITY_EDITOR_WIN
                string inklecateName = "inklecate_win.exe";
                                #endif
                // Unfortunately inklecate's implementation uses newer features of C# that aren't
                // available in the version of mono that ships with Unity, so we can't make use of
                // it. This means that we need to compile the mono runtime directly into it, inflating
                // the size of the executable quite dramatically :-( Hopefully we can improve that
                // when Unity ships with a newer version.
                                #if UNITY_EDITOR_OSX
                string inklecateName = "inklecate_mac";
                                #endif
                // Experimental linux build
                                #if UNITY_EDITOR_LINUX
                string inklecateName = "inklecate_win.exe";
                                #endif
                                #endif

                string[] inklecateDirectories = Directory.GetFiles(Application.dataPath, inklecateName, SearchOption.AllDirectories);
                if (inklecateDirectories.Length == 0)
                {
                    return(null);
                }

                return(Path.GetFullPath(inklecateDirectories[0]));
            }
        }
Exemple #28
0
 public void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(Settings.Default.Name))
     {
         userName.Text = Settings.Default.Name;
     }
     if (!string.IsNullOrWhiteSpace(Settings.Default.Email))
     {
         email.Text = Settings.Default.Email;
     }
     if (!string.IsNullOrWhiteSpace(Settings.Default.Files1))
     {
         var files = JArray.Parse(Settings.Default.Files1);
         for (int i = 0; i < files.Count; i++)
         {
             try
             {
                 lbFiles.Items.Add(Path.GetFileName(files[i].ToString()));
                 lbFilesPath.Items.Add(Path.GetFullPath(files[i].ToString()));
                 lbFilesName.Items.Add(files[i].ToString());
                 clear.Visibility = Visibility.Visible;
             }
             catch (FileNotFoundException)
             {
                 MessageBoxEx.Show(new MainWindow().Wind(), "File " + files[i].ToString() + "\n is broken" +
                                   "or moved");
             }
         }
     }
 }
        internal void WriteFile(string fileName, string commandLine = null)
        {
            this.outputFileWriter = new StreamWriter(Path.GetFullPath(fileName));

            WriteCommandLineArgs(commandLine);

            // Prepopulate the shape-to-obstacle map so we can write children and order by shape Id.
            AssignShapeIds();

            // Input parameters and output summary
            WriteHeader();

            // Input detail
            WriteInputObstacles();
            WritePorts();
            WriteRoutingSpecs();

            // Output detail
            WritePaddedObstacles();
            WriteConvexHulls();
            WriteScanSegments();
            WriteVisibilityGraph();
            WritePaths();

            // Done.
            this.outputFileWriter.Flush();
            this.outputFileWriter.Close();
        }
        static ExecutableFileInfo()
        {
            var executables    = new List <ExecutableFileInfo>();
            var rootPath       = ((App)Application.Current).RootPath;
            var binariesFolder = IOPath.Combine(rootPath, "Engine", "Binaries");

            executables.AddRange(
                Directory.GetFiles(binariesFolder, "UE4*.exe", SearchOption.AllDirectories)
                .Select(
                    file =>
                    new ExecutableFileInfo(file, file.Substring(rootPath.Length + 1),
                                           file.Substring(binariesFolder.Length + 1),
                                           ExecutableType.Editor)));

            foreach (var project in ProjectInfo.Projects)
            {
                var file = IOPath.GetFullPath(IOPath.Combine(project.Path, "..", project.Name + ".exe"));
                if (File.Exists(file))
                {
                    executables.Add(new ExecutableFileInfo(file, file.Substring(rootPath.Length + 1),
                                                           IOPath.GetFileName(file), ExecutableType.Build));
                }
            }

            ExecutableFiles = executables.ToArray();
        }