public static string GenerateRelativePath(string from, string to) { if(String.IsNullOrWhiteSpace(from) || String.IsNullOrWhiteSpace(to)) { throw new ArgumentNullException("Requires paths"); } Uri fromUri = new Uri(from); Uri toUri = new Uri(to); //The URI schemes have to match in order for the path to be made relative if(fromUri.Scheme != toUri.Scheme) { return to; } Uri relativeUri = fromUri.MakeRelativeUri(toUri); string relative = Uri.UnescapeDataString(relativeUri.ToString()); //If neccessary to do so, normalise the use of slashes to always be the default for this platform if(toUri.Scheme.ToUpperInvariant() == "FILE") { relative = relative.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); } return relative; }
public XDocument Format(IDirectoryTreeNode featureNode, GeneralTree<IDirectoryTreeNode> features, DirectoryInfo rootFolder) { var xmlns = HtmlNamespace.Xhtml; var featureNodeOutputPath = Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot); var featureNodeOutputUri = new Uri(featureNodeOutputPath); var container = new XElement(xmlns + "div", new XAttribute("id", "container")); container.Add(this.htmlHeaderFormatter.Format()); container.Add(this.htmlTableOfContentsFormatter.Format(featureNode.OriginalLocationUrl, features, rootFolder)); container.Add(this.htmlContentFormatter.Format(featureNode, features)); container.Add(this.htmlFooterFormatter.Format()); var body = new XElement(xmlns + "body"); body.Add(container); var head = new XElement(xmlns + "head"); head.Add(new XElement(xmlns + "title", string.Format("{0}", featureNode.Name))); head.Add(new XElement(xmlns + "link", new XAttribute("rel", "stylesheet"), new XAttribute("href", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.MasterStylesheet)), new XAttribute("type", "text/css"))); head.Add(new XElement(xmlns + "link", new XAttribute("rel", "stylesheet"), new XAttribute("href", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.PrintStylesheet)), new XAttribute("type", "text/css"), new XAttribute("media", "print"))); head.Add(new XElement(xmlns + "script", new XAttribute("src", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.jQueryScript)), new XAttribute("type", "text/javascript"), new XText(string.Empty))); head.Add(new XElement(xmlns + "script", new XAttribute("src", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.jQueryDataTablesScript)), new XAttribute("type", "text/javascript"), new XText(string.Empty))); head.Add(new XElement(xmlns + "script", new XAttribute("src", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.AdditionalScripts)), new XAttribute("type", "text/javascript"), new XText(string.Empty))); head.Add(new XElement(xmlns + "script", new XAttribute("type", "text/javascript"), documentReady)); var html = new XElement(xmlns + "html", new XAttribute(XNamespace.Xml + "lang", "en"), head, body); var document = new XDocument( new XDeclaration("1.0", "UTF-8", null), new XDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", string.Empty), html); return document; }
public static void MakRelative() { var from = "e:/cd/abc"; var to = "e:/cd"; var fromUri = new System.Uri(from); var toUri = new System.Uri(to); Console.WriteLine("The difference is {0}", fromUri.MakeRelativeUri(toUri)); var relativePath = System.Uri.UnescapeDataString(fromUri.MakeRelativeUri(toUri).ToString()); Console.WriteLine(relativePath); }
public static string RewriteCssPaths(string outputPath, string sourcePath, string css, ICssAssetsFileHasher cssAssetsFileHasher) { var sourceUri = new Uri(Path.GetDirectoryName(sourcePath) + "/", UriKind.Absolute); var outputUri = new Uri(Path.GetDirectoryName(outputPath) + "/", UriKind.Absolute); var relativePaths = FindDistinctRelativePathsIn(css); foreach (string relativePath in relativePaths) { var resolvedSourcePath = new Uri(sourceUri + relativePath ); var resolvedOutput = outputUri.MakeRelativeUri(resolvedSourcePath); css = css.Replace(relativePath , resolvedOutput.OriginalString); } if (cssAssetsFileHasher != null) { var localRelativePathsThatExist = FindDistinctLocalRelativePathsThatExist(css); foreach (string localRelativePathThatExist in localRelativePathsThatExist) { var localRelativePathThatExistWithFileHash = cssAssetsFileHasher.AppendFileHash(outputPath, localRelativePathThatExist); if (localRelativePathThatExist != localRelativePathThatExistWithFileHash) { css = css.Replace(localRelativePathThatExist, localRelativePathThatExistWithFileHash); } } } return css; }
public void AddTemplateReference(EnvDTE.Project currentProject, EnvDTE.Project selectedProject) { // we need to compute a relative path for the template project Uri currentProjUri = new Uri(currentProject.FullName); Uri selectedProjUri = new Uri(selectedProject.FullName); string relativePath = currentProjUri.MakeRelativeUri(selectedProjUri).ToString(); FileInfo selectedProjFile = new FileInfo(selectedProject.FullName); var curProjObj = ProjectRootElement.Open(currentProject.FullName); var item = curProjObj.AddItem("TemplateReference", selectedProjFile.Name, GetTemplateReferenceMetadata(relativePath)); // Install the TemplateBuilder NuGet pkg into the target project InstallTemplateBuilderPackage(currentProject); // Add the SideWaffle Project Template files into the target project var dte2 = Package.GetGlobalService(typeof(DTE)) as DTE2; Solution2 solution = (Solution2)dte2.Solution; string itemPath = solution.GetProjectItemTemplate("SW-ProjectVSTemplateFile.csharp.zip", "CSharp"); selectedProject.ProjectItems.AddFromTemplate(itemPath, "_project1.vstemplate"); curProjObj.Save(); // Reload the project ReloadProject(dte2, currentProject); }
private string ObterPastaRelativa(string projectFileName, string basePath) { Uri uriProjectPath = new Uri(Path.GetFullPath(projectFileName)); Uri uriBasePath = new Uri(basePath); Uri uriRelativa = uriProjectPath.MakeRelativeUri(uriBasePath); return uriRelativa.ToString(); }
public IEnumerable<string> FindFiles(string baseDir, IEnumerable<string> ignores) { List<string> filesToParse = new List<string>(); List<string> files = new List<string>(); files.AddRange(Directory.GetFiles(baseDir, "*.lua", SearchOption.AllDirectories)); files.AddRange(Directory.GetFiles(baseDir, "*.ns2doc", SearchOption.AllDirectories)); foreach (string path in files) { Uri fileNameUri = new Uri("file://" + path); Uri baseDirUri = new Uri("file://" + baseDir); string fileName = Uri.UnescapeDataString(baseDirUri.MakeRelativeUri(fileNameUri).ToString()); bool skip = false; foreach (string ignore in ignores) { if (ignore.StartsWith("~")) { skip = !fileName.StartsWith(ignore.Substring(1)); } else if (fileName.StartsWith(ignore)) { skip = true; break; } } if (!skip) { filesToParse.Add(path); } } return filesToParse; }
public static string GetRelativePath(string currentDirectory, string filePath) { var uriFile = new Uri(filePath); var uriCurrentDir = new Uri(currentDirectory + (!currentDirectory.EndsWith("\\") ? "\\" : "")); return uriCurrentDir.MakeRelativeUri(uriFile).ToString(); }
private static string MakeRelative(string baseFile, string file) { Uri baseUri = new Uri(baseFile, UriKind.RelativeOrAbsolute); Uri fileUri = new Uri(file, UriKind.RelativeOrAbsolute); return baseUri.MakeRelativeUri(fileUri).ToString(); }
public FormSaveSettings(string saveLocation, FormWorld world) { InitializeComponent(); this.saveLocation = saveLocation; this.world = world; var saveUri = new Uri(saveLocation); foreach (var tileset in world.Tilesets) { string relative = saveUri.MakeRelativeUri(new Uri(tileset.Filename)).ToString(); Node node = new Node(Path.GetFileName(tileset.Filename)) { CheckBoxVisible = true, Checked = tileset.ShouldBuild }; Cell cell = new Cell() { Text = tileset.BuildLocation != null ? tileset.BuildLocation : Path.Combine(Path.GetDirectoryName(relative), Path.GetFileNameWithoutExtension(relative)), Editable = true }; node.Cells[0].Editable = false; node.Cells.Add(cell); tilesetFilesList.Nodes.Add(node); } }
private static string makeRelative(string _filePath, string _referencePath) { var fileUri = new System.Uri(_filePath); var referenceUri = new System.Uri(_referencePath); return(System.Uri.UnescapeDataString(referenceUri.MakeRelativeUri(fileUri).ToString())); }
void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { DTE dte = (DTE)automationObject; string deploymentFolder = String.Empty; string destinationDirectory = replacementsDictionary["$destinationdirectory$"]; if (destinationDirectory.EndsWith("\\", StringComparison.Ordinal) == false) { destinationDirectory = destinationDirectory + "\\"; } string parentFolder = Path.GetDirectoryName(destinationDirectory); DeploymentWizardForm wizardForm = new DeploymentWizardForm(parentFolder); if (wizardForm.ShowDialog(new WindowOwner((IntPtr)dte.MainWindow.HWnd)) == DialogResult.OK) { Uri destinationUri = new Uri(destinationDirectory); Uri deploymentUri = new Uri(wizardForm.DeploymentFolder); Uri relativeUri = destinationUri.MakeRelativeUri(deploymentUri); deploymentFolder = relativeUri.ToString().Replace("/", "\\"); } replacementsDictionary["$deploymentpath$"] = deploymentFolder; }
internal static DirectoryPath MakeRelativePath(this DirectoryPath directoryPath, ICakeEnvironment environment, DirectoryPath rootDirectoryPath) { if (directoryPath == null) { throw new ArgumentNullException(nameof(directoryPath)); } if (environment == null) { throw new ArgumentNullException(nameof(environment)); } if (rootDirectoryPath == null) { throw new ArgumentNullException(nameof(rootDirectoryPath)); } var dirUri = new Uri(directoryPath.MakeAbsolute(environment).FullPath); var rootUri = new Uri($"{rootDirectoryPath.MakeAbsolute(environment).FullPath}/"); var relativeUri = rootUri.MakeRelativeUri(dirUri); var relativePath = Uri.UnescapeDataString(relativeUri.ToString()); var relativeDirectoryPath = new DirectoryPath(relativePath); return relativeDirectoryPath; }
public static string GetRelativePath(string path, string relativeTo) { Uri from = new Uri(path); Uri to = new Uri(relativeTo); Uri result = to.MakeRelativeUri(from); return Uri.UnescapeDataString(result.ToString()); }
/// <summary> /// Make a relative path out of two absolute ones /// </summary> /// <param name="fromPath">The path to be taken as origin for the relative path</param> /// <param name="toPath">The path to be taken as destination for the relative path</param> /// <param name="fromIsDirectory">True if fromPath is a directory path, otherwise false</param> /// <param name="toIsDirectory">True if toPath is a directory path, otherwise false</param> /// <returns> /// A relative path joining the two path specified in parameters, fromPath being the origin /// and toPath being the destination /// </returns> public static string GetRelativePath(string fromPath, string toPath, bool fromIsDirectory = false, bool toIsDirectory = false) { fromPath.ThrowIfNullOrWhiteSpace("fromPath"); toPath.ThrowIfNullOrWhiteSpace("toPath"); // Most likely a hacky quick fix fromPath = fromIsDirectory ? fromPath + Path.DirectorySeparatorChar : fromPath; toPath = toIsDirectory ? toPath + Path.DirectorySeparatorChar : toPath; var fromUri = new Uri(fromPath); var toUri = new Uri(toPath); if (fromUri.Scheme != toUri.Scheme) { // path can't be made relative. return toPath; } var relativeUri = fromUri.MakeRelativeUri(toUri); var relativePath = Uri.UnescapeDataString(relativeUri.ToString()); if (toUri.Scheme.ToUpperInvariant() == "FILE") { relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); } return relativePath; }
public static string MakeRelative(this string filePath, string referencePath) { var fileUri = new Uri(filePath,true); var referenceUri = new Uri(referencePath, true); return referenceUri.MakeRelativeUri(fileUri).ToString(); }
/// <summary> /// Creates a relative path from one file or folder to another. /// </summary> /// <param name="fromPath">Contains the directory that defines the start of the relative path.</param> /// <param name="fromIs">Is the fromPath a File or a Folder</param> /// <param name="toPath">Contains the path that defines the endpoint of the relative path.</param> /// <param name="toIs">Is the toPath a File or a Folder</param> /// <returns>The relative path from the start directory to the end path or <c>toPath</c> if the paths are not related.</returns> /// <exception cref="ArgumentNullException"></exception> /// <exception cref="UriFormatException"></exception> /// <exception cref="InvalidOperationException"></exception> public static String MakeRelativePath(String fromPath, PathIs fromIs, String toPath, PathIs toIs) { if (String.IsNullOrEmpty(fromPath)) throw new ArgumentNullException("fromPath"); if (String.IsNullOrEmpty(toPath)) throw new ArgumentNullException("toPath"); //Slash am Ende anfügen, damit Uri damit klarkommt und weiß, was ein Folder ist, und was nicht if (!fromPath.EndsWith(Path.DirectorySeparatorChar.ToString()) && !fromPath.EndsWith(Path.AltDirectorySeparatorChar.ToString()) && fromIs == PathIs.Folder) fromPath += Path.DirectorySeparatorChar; if (!toPath.EndsWith(Path.DirectorySeparatorChar.ToString()) && !toPath.EndsWith(Path.AltDirectorySeparatorChar.ToString()) && toIs == PathIs.Folder) toPath += Path.DirectorySeparatorChar; Uri fromUri = new Uri(fromPath); Uri toUri = new Uri(toPath); if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative. Uri relativeUri = fromUri.MakeRelativeUri(toUri); String relativePath = Uri.UnescapeDataString(relativeUri.ToString()); if (toUri.Scheme.ToUpperInvariant() == "FILE") { relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); } if (relativePath == string.Empty) relativePath = ".\\"; //ein \ am Ende entfernen, dies macht Probleme, insbesondere in CommandLine wenn quoted //zudem scheint der .Net - Standard zu sein, kein \ am Ende zu haben vgl. Path.GetDirectoryname() return relativePath.TrimEnd(Path.DirectorySeparatorChar); }
public static string MakeRelative(string filePath, string referencePath) { var fileUri = new Uri(filePath); var referenceUri = new Uri(referencePath); return Uri.UnescapeDataString(referenceUri.MakeRelativeUri(fileUri).ToString()); }
string GetPathRelativeTo(string BasePath, string ToPath) { Uri path1 = new Uri(BasePath); Uri path2 = new Uri(ToPath); Uri diff = path1.MakeRelativeUri(path2); return diff.ToString(); }
public void BaseUriValidationTest() { string relativeUriString = "abc/pqr/"; Uri absoluteUri = new Uri("http://odata.org"); Uri relativeUri = absoluteUri.MakeRelativeUri(new Uri(absoluteUri, relativeUriString)); string expectedError = "The base URI '" + relativeUriString + "' specified in ODataMessageWriterSettings.PayloadBaseUri is invalid; it must either be null or an absolute URI."; ODataEntry entry = ObjectModelUtils.CreateDefaultEntry(); var testDescriptors = new [] { new { BaseUri = relativeUri, TestDescriptor = new PayloadWriterTestDescriptor<ODataItem>(this.Settings, entry, testConfiguration => new WriterTestExpectedResults(this.Settings.ExpectedResultSettings) { ExpectedODataExceptionMessage = expectedError }) } }; this.CombinatorialEngineProvider.RunCombinations( testDescriptors, this.WriterTestConfigurationProvider.ExplicitFormatConfigurations, (testDescriptor, testConfiguration) => { // clone the test configuration and set an invalid base Uri ODataMessageWriterSettings settings = testConfiguration.MessageWriterSettings.Clone(); settings.PayloadBaseUri = testDescriptor.BaseUri; WriterTestConfiguration config = new WriterTestConfiguration(testConfiguration.Format, settings, testConfiguration.IsRequest, testConfiguration.Synchronous); TestWriterUtils.WriteAndVerifyODataPayload(testDescriptor.TestDescriptor, config, this.Assert, this.Logger); }); }
static void RefreshAllLuaScripts() { var pathScripts = new System.Uri(Path.Combine(Application.dataPath, "_ScriptLua/")); var pathModules = new System.Uri(Path.Combine(Application.dataPath, "Plugins/Unity3D.Lua/Modules/")); var scripts = Directory.GetFiles(pathScripts.AbsolutePath, "*.lua", SearchOption.AllDirectories) .Select(p => new KeyValuePair <string, string>(pathScripts.MakeRelativeUri(new System.Uri(p)).ToString(), p)) .Union( Directory.GetFiles(pathModules.AbsolutePath, "*.lua", SearchOption.AllDirectories) .Select(p => new KeyValuePair <string, string>(pathModules.MakeRelativeUri(new System.Uri(p)).ToString(), p))); allLuaScripts = new Dictionary <string, List <string> >(); foreach (var kv in scripts) { var basename = kv.Key; basename = basename.ToLower(); basename = basename.Replace(".lua", ""); basename = basename.Replace("/", "."); List <string> flist = null; if (!allLuaScripts.TryGetValue(basename, out flist)) { flist = new List <string>(); allLuaScripts[basename] = flist; } flist.Add(kv.Value); } }
private string MakeRelative(string filePath, string referencePath) { var fileUri = new Uri(filePath); var referenceUri = new Uri(referencePath); return referenceUri.MakeRelativeUri(fileUri).ToString(); }
public static string MakeRelativePath(string relativeDirectory,string filename) { try { if( filename.Length == 0 || IsUNC(filename) || IsRelative(filename) ) return filename; Uri fileUri = new Uri(filename); Uri referenceUri = new Uri(relativeDirectory + "/"); string relativePath = referenceUri.MakeRelativeUri(fileUri).ToString(); relativePath = Uri.UnescapeDataString(relativePath); relativePath = relativePath.Replace('/','\\'); if( relativePath.IndexOf(':') < 0 && relativePath[0] != '.' ) // add a .\ (as CSPro does) relativePath = ".\\" + relativePath; return relativePath; } catch( Exception ) { } return filename; }
public static string AbsoluteUrlToAssets(string absoluteUrl) { Uri fullPath = new Uri (absoluteUrl, UriKind.Absolute); Uri relRoot = new Uri (Application.dataPath, UriKind.Absolute); return relRoot.MakeRelativeUri (fullPath).ToString (); }
public async Task CopyContainer(CloudBlobContainer sourceContainer, string destination) { var uri = new Uri(sourceContainer.Uri.AbsoluteUri.TrimEnd('/') + '/'); destination = Path.Combine(destination, sourceContainer.Name); BlobContinuationToken continuationToken = null; do { var segments = await sourceContainer.ListBlobsSegmentedAsync(prefix: null, useFlatBlobListing: true, blobListingDetails: BlobListingDetails.Metadata, maxResults: MaxParallelDownloads, currentToken: continuationToken, options: null, operationContext: null); var tasks = new BlockingCollection<Task>(MaxParallelDownloads); Parallel.ForEach(segments.Results.Cast<CloudBlockBlob>(), srcFile => { var relativePath = uri.MakeRelativeUri(srcFile.Uri); var destLocation = Path.Combine(destination, relativePath.OriginalString); if (File.Exists(destLocation) && File.GetLastWriteTimeUtc(destLocation) == srcFile.Properties.LastModified) { // If the file looks unchanged, skip it. return; } Directory.CreateDirectory(Path.GetDirectoryName(destLocation)); tasks.Add(srcFile.DownloadToFileAsync(destLocation, FileMode.Create)); }); await Task.WhenAll(tasks); continuationToken = segments.ContinuationToken; } while (continuationToken != null); }
private void buttonAdd_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "Dll Files (.dll)|*.dll|All Files (*.*)|*.*"; dialog.Multiselect = true; if (dialog.ShowDialog() == DialogResult.OK) { string pl = ((PipelineController)MainView._controller).ProjectLocation; if (!pl.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) pl += System.IO.Path.DirectorySeparatorChar; Uri folderUri = new Uri(pl); foreach(string filename in dialog.FileNames) { Uri pathUri = new Uri(filename); string fl = Uri.UnescapeDataString(folderUri.MakeRelativeUri(pathUri).ToString().Replace('/', System.IO.Path.DirectorySeparatorChar)); if (!Lines.Contains(fl)) { Lines.Add(fl); listView1.Items.Add(new ListViewItem(new[] { Path.GetFileName(fl), fl })); } } } }
private static void GenerateBinary(string sheetName, InfoTable infoTable) { try { var filePath = Path.Combine(BinaryDirectoryPath, sheetName + ".bytes"); var fw = new FileWriter(filePath); MemoryStream ms = new MemoryStream(); BinaryFormatter b = new BinaryFormatter(); b.Serialize(ms, infoTable); var bytes = ms.GetBuffer(); fw.Write(bytes); var dataPathUri = new System.Uri(Application.dataPath); var relativeUri = dataPathUri.MakeRelativeUri(new System.Uri(filePath)); var relativePath = System.Uri.UnescapeDataString(relativeUri.ToString()); AssetDatabase.ImportAsset(relativePath, ImportAssetOptions.ForceUpdate); } catch (IOException e) { throw e; } }
/// <summary> /// Retrieve the relative path of a resource (using filesystem module) /// </summary> /// <param name="file"></param> /// <returns></returns> public static string RelativeResourcePath(string file) { var fileUri = new System.Uri(file); var referenceUri = new System.Uri(resources_folder); return(referenceUri.MakeRelativeUri(fileUri).ToString()); }
public XDocument Format(FeatureNode featureNode, GeneralTree<FeatureNode> features) { var xmlns = XNamespace.Get("http://www.w3.org/1999/xhtml"); var featureNodeOutputPath = Path.Combine(this.configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot); var featureNodeOutputUri = new Uri(featureNodeOutputPath); var container = new XElement(xmlns + "div", new XAttribute("id", "container")); container.Add(this.htmlHeaderFormatter.Format()); container.Add(this.htmlTableOfContentsFormatter.Format(featureNode.Url, features)); container.Add(this.htmlContentFormatter.Format(featureNode)); container.Add(this.htmlFooterFormatter.Format()); var body = new XElement(xmlns + "body"); body.Add(container); var head = new XElement(xmlns + "head"); head.Add(new XElement(xmlns + "title", string.Format("{0}", featureNode.Name))); head.Add(new XElement(xmlns + "link", new XAttribute("rel", "stylesheet"), new XAttribute("href", featureNodeOutputUri.MakeRelativeUri(this.htmlResources.MasterStylesheet)), new XAttribute("type", "text/css"))); var html = new XElement(xmlns + "html", new XAttribute(XNamespace.Xml + "lang", "en"), head, body); var document = new XDocument( new XDeclaration("1.0", "UTF-8", null), new XDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", string.Empty), html); return document; }
public static string MakeRelative(string baseFile, string file) { Uri baseUri = new Uri(baseFile, UriKind.RelativeOrAbsolute); Uri fileUri = new Uri(file, UriKind.RelativeOrAbsolute); return Uri.UnescapeDataString(baseUri.MakeRelativeUri(fileUri).ToString()); }
public static string MakeRelative(string basePath, string absolutePath) { Uri baseUri = new Uri(basePath); Uri absoluteUri = new Uri(absolutePath); var result = absoluteUri.MakeRelativeUri(baseUri); return result.OriginalString; }
/// <summary> /// Creates a relative path from one file or folder to another. /// </summary> /// <param name="fromPath">Contains the directory that defines the start of the relative path.</param> /// <param name="toPath">Contains the path that defines the endpoint of the relative path.</param> /// <returns>The relative path from the start directory to the end path.</returns> /// <exception cref="ArgumentNullException"><paramref name="fromPath"/> or <paramref name="toPath"/> is <c>null</c>.</exception> /// <exception cref="UriFormatException"></exception> /// <exception cref="InvalidOperationException"></exception> public static string GetRelativePath(string fromPath, string toPath) { if (string.IsNullOrEmpty(fromPath)) { throw new ArgumentNullException(nameof(fromPath)); } if (string.IsNullOrEmpty(toPath)) { throw new ArgumentNullException(nameof(toPath)); } var fromUri = new Uri(AppendDirectorySeparatorChar(fromPath)); var toUri = new Uri(AppendDirectorySeparatorChar(toPath)); if (fromUri.Scheme != toUri.Scheme) { return toPath; } var relativeUri = fromUri.MakeRelativeUri(toUri); var relativePath = Uri.UnescapeDataString(relativeUri.ToString()); if (string.Equals(toUri.Scheme, Uri.UriSchemeFile, StringComparison.OrdinalIgnoreCase)) { relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); } return relativePath; }
public override void Visit(Document document) { var directoryAttribute = document.Attributes.FirstOrDefault(a => a.Name == "docdir"); if (directoryAttribute != null) { document.Attributes.Remove(directoryAttribute); } // check if this document has generated includes to other files var includeAttribute = document.Attributes.FirstOrDefault(a => a.Name == "includes-from-dirs"); if (includeAttribute != null) { var thisFileUri = new Uri(_destination.FullName); var directories = includeAttribute.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var directory in directories) { foreach (var file in Directory.EnumerateFiles(Path.Combine(Program.OutputDirPath, directory), "*.asciidoc", SearchOption.AllDirectories)) { var fileInfo = new FileInfo(file); var referencedFileUri = new Uri(fileInfo.FullName); var relativePath = thisFileUri.MakeRelativeUri(referencedFileUri); var include = new Include(relativePath.OriginalString); document.Add(include); } } } base.Visit(document); }
///获取相对路径 ///1.fromUri,toUri = new URI(fromPath/toPath) ///2.relativeUri = fromUri.MakeRelativeUri(toUri); ///3.relativePath = System.Uri.UnescapeDataString(relativeUri.ToString()) public static string MakeRelativePath(string fromPath, string toPath) { fromPath += "/fake_depth"; try { if (string.IsNullOrEmpty(fromPath)) { return(toPath); } if (string.IsNullOrEmpty(toPath)) { return(""); } var fromUri = new System.Uri(fromPath); var toUri = new System.Uri(toPath); if (fromUri.Scheme != toUri.Scheme) { return(toPath); } var relativeUri = fromUri.MakeRelativeUri(toUri); //UnescapeDataString:转换为非转义字符串形式 var relativePath = System.Uri.UnescapeDataString(relativeUri.ToString()); return(relativePath); } catch { return(toPath); } }
public static BaseItemView Create (CGRect frame, NodeViewController nodeViewController, TreeNode node, string filePath, UIColor kleur) { var view = BaseItemView.Create(frame, nodeViewController, node, kleur); UIWebView webView = new UIWebView(); string extension = Path.GetExtension (filePath); if (extension == ".odt") { string viewerPath = NSBundle.MainBundle.PathForResource ("over/viewer/index", "html"); Uri fromUri = new Uri(viewerPath); Uri toUri = new Uri(filePath); Uri relativeUri = fromUri.MakeRelativeUri(toUri); String relativePath = Uri.UnescapeDataString(relativeUri.ToString()); NSUrl finalUrl = new NSUrl ("#" + relativePath.Replace(" ", "%20"), new NSUrl(viewerPath, false)); webView.LoadRequest(new NSUrlRequest(finalUrl)); webView.ScalesPageToFit = true; view.ContentView = webView; return view; } else { NSUrl finalUrl = new NSUrl (filePath, false); webView.LoadRequest(new NSUrlRequest(finalUrl)); webView.ScalesPageToFit = true; view.ContentView = webView; return view; } }
/// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public virtual Uri ResolveUri(Uri baseUri, string relativeUri) { if (baseUri == null || (!baseUri.IsAbsoluteUri && baseUri.OriginalString.Length == 0)) { return new Uri(relativeUri, UriKind.RelativeOrAbsolute); } else { if (relativeUri == null || relativeUri.Length == 0) { return baseUri; } // relative base Uri if (!baseUri.IsAbsoluteUri) { // create temporary base for the relative URIs Uri tmpBaseUri = new Uri("tmp:///"); // create absolute base URI with the temporary base Uri absBaseUri = new Uri(tmpBaseUri, baseUri.OriginalString); // resolve the relative Uri into a new absolute URI Uri resolvedAbsUri = new Uri(absBaseUri, relativeUri); // make it relative by removing temporary base Uri resolvedRelUri = tmpBaseUri.MakeRelativeUri(resolvedAbsUri); return resolvedRelUri; } return new Uri(baseUri, relativeUri); } }
public EinzelelementModel(string bezeichnung, string pfadAufbereitetesBild) { Bezeichnung = bezeichnung; PfadAufbereitetesBild = pfadAufbereitetesBild; var uri = new System.Uri(pfadAufbereitetesBild); var uri_curr_dir = new System.Uri("."); var converted = uri.MakeRelativeUri(uri_curr_dir); }
//絶対パスから相対パスを取得 public static string ToRelativePath(string root, string path) { System.Uri u1 = new System.Uri(root); System.Uri u2 = new System.Uri(path); //絶対Uriから相対Uriを取得する System.Uri relativeUri = u1.MakeRelativeUri(u2); return(relativeUri.ToString()); }
public static string GetRelativePath(string fromPath, string toPath) { var path1 = fromPath.Trim('\\', '/'); var path2 = toPath.Trim('\\', '/'); var uri1 = new System.Uri("c:\\" + path1 + "\\"); var uri2 = new System.Uri("c:\\" + path2 + "\\"); return(uri1.MakeRelativeUri(uri2).ToString()); }
public void MakePathRelative(string projectPath) { if (sourceTree.Equals("SDKROOT")) { return; } System.Uri fileUri = new System.Uri(absolutePath); System.Uri projectUri = new System.Uri(projectPath); relativePath = "../" + projectUri.MakeRelativeUri(fileUri).ToString(); }
public static string MakeRelative(string filePath, string referencePath) { if (!referencePath.EndsWith("/")) { referencePath += "/"; } var fileUri = new System.Uri(filePath); var referenceUri = new System.Uri(referencePath); return(referenceUri.MakeRelativeUri(fileUri).ToString()); }
// We support neither recursing into nor bundles contained inside loc folders public bool AddLocFolder(string folderPath, PBXGroup parent = null, string[] exclude = null, bool createBuildFile = true) { DirectoryInfo sourceDirectoryInfo = new DirectoryInfo(folderPath); if (exclude == null) { exclude = new string[] { } } ; if (parent == null) { parent = rootGroup; } // Create group as needed System.Uri projectFolderURI = new System.Uri(projectFileInfo.DirectoryName); System.Uri locFolderURI = new System.Uri(folderPath); var relativePath = projectFolderURI.MakeRelativeUri(locFolderURI).ToString(); PBXGroup newGroup = GetGroup(sourceDirectoryInfo.Name, relativePath, parent); // Add loc region to project string nom = sourceDirectoryInfo.Name; string region = nom.Substring(0, nom.Length - ".lproj".Length); project.AddRegion(region); // Adding files. string regexExclude = string.Format(@"{0}", string.Join("|", exclude)); foreach (string file in Directory.GetFiles(folderPath)) { if (Regex.IsMatch(file, regexExclude)) { continue; } // Add a variant group for the language as well var variant = new PBXVariantGroup(System.IO.Path.GetFileName(file), null, "GROUP"); variantGroups.Add(variant); // The group gets a reference to the variant, not to the file itself newGroup.AddChild(variant); AddFile(file, variant, "GROUP", createBuildFile); } modified = true; return(modified); }
public static string GetRelativePathOfFile(string fileName) { var dataPathDir = new DirectoryInfo(Application.dataPath); var dataPathUri = new System.Uri(Application.dataPath); foreach (var file in dataPathDir.GetFiles(fileName, SearchOption.AllDirectories)) { var relativeUri = dataPathUri.MakeRelativeUri(new System.Uri(file.FullName)); var relativePath = System.Uri.UnescapeDataString(relativeUri.ToString()); return(relativePath); } return(string.Empty); }
static public int MakeRelativeUri(IntPtr l) { try { System.Uri self = (System.Uri)checkSelf(l); System.Uri a1; checkType(l, 2, out a1); var ret = self.MakeRelativeUri(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static int MakeRelativeUri(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); System.Uri obj = (System.Uri)ToLua.CheckObject <System.Uri>(L, 1); System.Uri arg0 = (System.Uri)ToLua.CheckObject <System.Uri>(L, 2); System.Uri o = obj.MakeRelativeUri(arg0); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
private string MakePathRelative(string path, string relativeTo) { try { System.Uri fileUri = new System.Uri(path); System.Uri relativeUri = new System.Uri(relativeTo); string newPath = relativeUri.MakeRelativeUri(fileUri).ToString(); if (newPath.StartsWith("Assets/")) { return(newPath.ToString().Substring(7)); } if (String.IsNullOrEmpty(newPath)) { return(""); } return("../" + newPath); } catch (UriFormatException) { return(path); } }
/// <summary> /// Convert from absolute path to relative path /// </summary> /// <param name="basePath">relative base path</param> /// <param name="filePath">absolute path</param> /// <returns>relative path</returns> public static string ChangeRelativePath(string basePath, string filePath) { //"%"を"%25"に変換しておく(デコード対策) basePath = basePath.Replace("%", "%25"); filePath = filePath.Replace("%", "%25"); //相対パスを取得する System.Uri baseUrl = new System.Uri(basePath); System.Uri fileUrl = new System.Uri(filePath); System.Uri relativeUri = baseUrl.MakeRelativeUri(fileUrl); string relativePath = relativeUri.ToString(); //URLデコードする(エンコード対策) relativePath = System.Uri.UnescapeDataString(relativePath); //"%25"を"%"に戻す relativePath = relativePath.Replace("%25", "%"); return(relativePath); }
private static System.Uri AddSegment(System.Uri baseUri, System.Uri fullUri) { System.Uri uri = null; if (baseUri.AbsolutePath.Length >= fullUri.AbsolutePath.Length) { return(uri); } UriBuilder uriBuilder = new UriBuilder(baseUri); TcpChannelListener.FixIpv6Hostname(uriBuilder, baseUri); if (!uriBuilder.Path.EndsWith("/", StringComparison.Ordinal)) { uriBuilder.Path = uriBuilder.Path + "/"; baseUri = uriBuilder.Uri; } string originalString = baseUri.MakeRelativeUri(fullUri).OriginalString; int index = originalString.IndexOf('/'); string str2 = (index == -1) ? originalString : originalString.Substring(0, index); uriBuilder.Path = uriBuilder.Path + str2; return(uriBuilder.Uri); }
public static string MakeRelativePath(this string absPath, string relativeTo) { System.Uri absUri = new System.Uri(absPath, System.UriKind.Absolute); System.Uri relativeToUri = new System.Uri(relativeTo, System.UriKind.Absolute); return(System.Uri.UnescapeDataString(relativeToUri.MakeRelativeUri(absUri).ToString())); }
public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false) { //Debug.Log("AddFile " + filePath + ", " + parent + ", " + tree + ", " + (createBuildFiles? "TRUE":"FALSE") + ", " + (weak? "TRUE":"FALSE") ); PBXDictionary results = new PBXDictionary(); if (filePath == null) { Debug.LogError("AddFile called with null filePath"); return(results); } string absPath = string.Empty; if (Path.IsPathRooted(filePath)) { Debug.Log("Path is Rooted"); absPath = filePath; } else if (tree.CompareTo("SDKROOT") != 0) { absPath = Path.Combine(Application.dataPath, filePath); } if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0) { Debug.Log("Missing file: " + filePath); return(results); } else if (tree.CompareTo("SOURCE_ROOT") == 0) { Debug.Log("Source Root File"); System.Uri fileURI = new System.Uri(absPath); System.Uri rootURI = new System.Uri((projectRootPath + "/.")); filePath = rootURI.MakeRelativeUri(fileURI).ToString(); } else if (tree.CompareTo("GROUP") == 0) { Debug.Log("Group File"); filePath = System.IO.Path.GetFileName(filePath); } if (parent == null) { parent = _rootGroup; } //Check if there is already a file //PBXFileReference fileReference = GetFile( System.IO.Path.GetFileName( filePath ) ); PBXFileReference fileReference = GetFileByPath(filePath); if (fileReference != null) { Debug.Log("File already exists: " + filePath); //not a warning, because this is normal for most builds! return(null); } fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree)); parent.AddChild(fileReference); fileReferences.Add(fileReference); results.Add(fileReference.guid, fileReference); //Create a build file for reference if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles) { switch (fileReference.buildPhase) { case "PBXFrameworksBuildPhase": foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases) { BuildAddFile(fileReference, currentObject, weak); } if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0)) { string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath)); if (File.Exists(absPath)) { this.AddLibrarySearchPaths(new PBXList(libraryPath)); } else { this.AddFrameworkSearchPaths(new PBXList(libraryPath)); } } break; case "PBXResourcesBuildPhase": foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases) { Debug.Log("Adding Resources Build File"); BuildAddFile(fileReference, currentObject, weak); } break; case "PBXShellScriptBuildPhase": foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases) { Debug.Log("Adding Script Build File"); BuildAddFile(fileReference, currentObject, weak); } break; case "PBXSourcesBuildPhase": foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases) { Debug.Log("Adding Source Build File"); BuildAddFile(fileReference, currentObject, weak); } break; case "PBXCopyFilesBuildPhase": foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases) { Debug.Log("Adding Copy Files Build Phase"); BuildAddFile(fileReference, currentObject, weak); } break; case null: Debug.LogWarning("File Not Supported: " + filePath); break; default: Debug.LogWarning("File Not Supported."); return(null); } } return(results); }
internal static string CreateRelativePath(string absolutePath) { System.Uri projectRootURI = new System.Uri(Application.dataPath); System.Uri fileURI = new System.Uri(absolutePath); return(projectRootURI.MakeRelativeUri(fileURI).ToString()); }
public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string[] compilerFlags = null) { PBXDictionary results = new PBXDictionary(); string absPath = string.Empty; if (Path.IsPathRooted(filePath)) { absPath = filePath; } else if (tree.CompareTo("SDKROOT") != 0) { absPath = Path.Combine(Application.dataPath, filePath); } if (tree.CompareTo("SOURCE_ROOT") == 0) { System.Uri fileURI = new System.Uri(absPath); System.Uri rootURI = new System.Uri((projectRootPath + "/.")); try { filePath = rootURI.MakeRelativeUri(fileURI).ToString(); } catch (UriFormatException exception) { Debug.LogWarning(string.Format("Cannot create relative URI for path: {0}, error: {1}", filePath, exception)); absPath = filePath; } } if (parent == null) { parent = _rootGroup; } // TODO: Aggiungere controllo se file già presente String filename = System.IO.Path.GetFileName(filePath); if (filename.Contains("+")) { filename = string.Format("\"{0}\"", filename); } PBXFileReference fileReference = GetFile(filename); if (fileReference != null) { //Weak references always taks precedence over strong reference if (weak) { PBXBuildFile buildFile = GetBuildFile(fileReference.guid); if (buildFile != null) { buildFile.SetWeakLink(weak); } } // Dear future me: If they ever invent a time machine, please don't come back in time to hunt me down. // From Unity 5, AdSupport is loaded dinamically, meaning that there will be a reference to the // file in the project and it won't add it to the linking libraries. And we need that. // TODO: The correct solution would be to check inside each phase if that file is already present. if (filename.Contains("AdSupport.framework")) { if (string.IsNullOrEmpty(fileReference.buildPhase)) { fileReference.buildPhase = "PBXFrameworksBuildPhase"; } } else { return(null); } } if (fileReference == null) { if (tree.CompareTo("SOURCE_ROOT") == 0) { System.Uri projectRootURI = new System.Uri(Application.dataPath); System.Uri fileURI = new System.Uri(absPath); String relativePath = projectRootURI.MakeRelativeUri(fileURI).ToString(); String newFilePath = Path.Combine(projectRootPath, relativePath); Directory.CreateDirectory(Path.GetDirectoryName(newFilePath)); File.Copy(absPath, newFilePath); filePath = relativePath; } fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree)); parent.AddChild(fileReference); fileReferences.Add(fileReference); results.Add(fileReference.guid, fileReference); } //Create a build file for reference if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles) { PBXBuildFile buildFile; switch (fileReference.buildPhase) { case "PBXFrameworksBuildPhase": foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases) { PBXBuildFile newBuildFile = GetBuildFile(fileReference.guid); if (newBuildFile == null) { newBuildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(newBuildFile); } if (currentObject.Value.HasBuildFile(newBuildFile.guid)) { continue; } currentObject.Value.AddBuildFile(newBuildFile); } if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0) && File.Exists(absPath)) { string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath)); this.AddLibrarySearchPaths(new PBXList(libraryPath)); } break; case "PBXResourcesBuildPhase": foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXShellScriptBuildPhase": foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXSourcesBuildPhase": foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); foreach (string flag in compilerFlags) { buildFile.AddCompilerFlag(flag); } buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXCopyFilesBuildPhase": foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case null: Debug.LogWarning("null value for build phase is not supported"); break; default: Debug.LogWarning("default value for build phase is not supported"); return(null); } } return(results); }
public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false, string[] compilerFlags = null) { PBXDictionary results = new PBXDictionary(); string absPath = string.Empty; if (Path.IsPathRooted(filePath)) { absPath = filePath; } else if (tree.CompareTo("SDKROOT") != 0) { absPath = Path.Combine(Application.dataPath, filePath); } if (tree.CompareTo("SOURCE_ROOT") == 0) { System.Uri fileURI = new System.Uri(absPath); System.Uri rootURI = new System.Uri((projectRootPath + "/.")); filePath = rootURI.MakeRelativeUri(fileURI).ToString(); } if (parent == null) { parent = _rootGroup; } // TODO: Aggiungere controllo se file già presente String filename = System.IO.Path.GetFileName(filePath); if (filename.Contains("+")) { filename = string.Format("\"{0}\"", filename); } PBXFileReference fileReference = GetFile(filename); if (fileReference != null) { //Srong reference always taks precedence over weak reference if (!weak) { PBXBuildFile buildFile = GetBuildFile(fileReference.guid); if (buildFile != null) { buildFile.SetWeakLink(weak); } } return(null); } fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree)); parent.AddChild(fileReference); fileReferences.Add(fileReference); results.Add(fileReference.guid, fileReference); //Create a build file for reference if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles) { PBXBuildFile buildFile; switch (fileReference.buildPhase) { case "PBXFrameworksBuildPhase": foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } if (!string.IsNullOrEmpty(absPath) && (tree.CompareTo("SOURCE_ROOT") == 0) && File.Exists(absPath)) { string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath)); this.AddLibrarySearchPaths(new PBXList(libraryPath)); } break; case "PBXResourcesBuildPhase": foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXShellScriptBuildPhase": foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXSourcesBuildPhase": foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); foreach (string flag in compilerFlags) { buildFile.AddCompilerFlag(flag); } buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXCopyFilesBuildPhase": foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case null: Debug.LogWarning("fase non supportata null"); break; default: Debug.LogWarning("fase non supportata def"); return(null); } } return(results); }
public PBXDictionary AddFile(string filePath, PBXGroup parent = null, string tree = "SOURCE_ROOT", bool createBuildFiles = true, bool weak = false) { PBXDictionary results = new PBXDictionary(); string absPath = string.Empty; if (Path.IsPathRooted(filePath)) { absPath = filePath; // UnityEngine.Debug.Log( "Is rooted: " + absPath ); } else if (tree.CompareTo("SDKROOT") != 0) { absPath = Path.Combine(Application.dataPath.Replace("Assets", ""), filePath); // UnityEngine.Debug.Log( "RElative: " + absPath ); } if (!(File.Exists(absPath) || Directory.Exists(absPath)) && tree.CompareTo("SDKROOT") != 0) { // UnityEngine.Debug.Log( "Missing file: " + absPath + " > " + filePath ); return(results); } else if (tree.CompareTo("SOURCE_ROOT") == 0 || tree.CompareTo("GROUP") == 0) { System.Uri fileURI = new System.Uri(absPath); System.Uri rootURI = new System.Uri((projectRootPath + "/.")); filePath = rootURI.MakeRelativeUri(fileURI).ToString(); } // UnityEngine.Debug.Log( "Add file result path: " + filePath ); if (parent == null) { parent = _rootGroup; } // TODO: Aggiungere controllo se file già presente PBXFileReference fileReference = GetFile(System.IO.Path.GetFileName(filePath)); if (fileReference != null) { // UnityEngine.Debug.Log( "File già presente." ); return(null); } fileReference = new PBXFileReference(filePath, (TreeEnum)System.Enum.Parse(typeof(TreeEnum), tree)); parent.AddChild(fileReference); fileReferences.Add(fileReference); results.Add(fileReference.guid, fileReference); //Create a build file for reference if (!string.IsNullOrEmpty(fileReference.buildPhase) && createBuildFiles) { // PBXDictionary<PBXBuildPhase> currentPhase = GetBuildPhase( fileReference.buildPhase ); PBXBuildFile buildFile; switch (fileReference.buildPhase) { case "PBXFrameworksBuildPhase": foreach (KeyValuePair <string, PBXFrameworksBuildPhase> currentObject in frameworkBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } if (!string.IsNullOrEmpty(absPath) && File.Exists(absPath) && tree.CompareTo("SOURCE_ROOT") == 0) { // UnityEngine.Debug.LogError(absPath); string libraryPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath)); this.AddLibrarySearchPaths(new PBXList(libraryPath)); } else if (!string.IsNullOrEmpty(absPath) && Directory.Exists(absPath) && absPath.EndsWith(".framework") && tree.CompareTo("GROUP") == 0) // Annt: Add framework search path for FacebookSDK { string frameworkPath = Path.Combine("$(SRCROOT)", Path.GetDirectoryName(filePath)); this.AddFrameworkSearchPaths(new PBXList(frameworkPath)); } break; case "PBXResourcesBuildPhase": foreach (KeyValuePair <string, PBXResourcesBuildPhase> currentObject in resourcesBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXShellScriptBuildPhase": foreach (KeyValuePair <string, PBXShellScriptBuildPhase> currentObject in shellScriptBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXSourcesBuildPhase": foreach (KeyValuePair <string, PBXSourcesBuildPhase> currentObject in sourcesBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case "PBXCopyFilesBuildPhase": foreach (KeyValuePair <string, PBXCopyFilesBuildPhase> currentObject in copyBuildPhases) { buildFile = new PBXBuildFile(fileReference, weak); buildFiles.Add(buildFile); currentObject.Value.AddBuildFile(buildFile); } break; case null: #if SHOW_DEBUG UnityEngine.Debug.LogWarning("fase non supportata null"); #endif break; default: #if SHOW_DEBUG UnityEngine.Debug.LogWarning("fase non supportata def"); #endif return(null); } } return(results); }