w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Hadoop get relative path from absolute path and base path
How about building a String while recursing with getParent() until the current path is equal to the base path? Here is a helper function that might do what you want. (I haven't tested it yet, but the idea might help) private static String absolutePathToRelativeString(final Path path, final Path base) { final StringBuilder builder = new StringBuilder(path.toString().length()); Path curPath = new Path(path); while (curPath != null && curPath.depth() != 0 && !curPath.equals(base)) { if (!curPath.equals(path)) { builder.append('/'); } builder.insert(0, curPath.getName()); curPath = curPath.getParent(); } return builder.toString(); }

Categories : Java

Is it possible to ui:include files from an absolute file path rather than relative webapp path?
On a mac (for example) the path look like this: <ui:include src="file:///Users/Julian/Documents/.../WEB-INF/templates/footer.xhtml" /> On Windows the path looks like this: <ui:include src="file:///C:/Users/.../footer.xhtml" />

Categories : JSF

phantomJS : Absolute path working, but Relative path giving problems
Maybe there is an issue in page.render but I don't think so. The most common case of hangs is unhandled exception. I will suggest you 4 things to investigate the issue : add an handler to phantom.onError and/or to page.OnError encapsulate your code in try/catch blocks (such as for page.render) Once the page is loaded, there is no test on callback status. It's better to check the status ('success' or 'fail') seems to freeze when calling page.render. Have you tried a simpler filename in the current directory? Maybe the freeze is because of the security or invalid filename (invalid characters?) Hope this will help you

Categories : PHP

How to find absolute path within a project
this file will be bundled within the jar. That file is not a stand alone file on the filesystem anymore. It has no unique filesystem path which points it exclusively. Its part of a packaged file(similar to a zip) after packaging. That is the main reason methods like class.getResourceAsStream() and classLoader.getResourceAsStream() are provided.

Categories : Java

Get relative path to file within project in JNI
The jni folder is not added to your APK. If you want files to be bundled with your application, I'd suggest putting them in the assets folder. If the assets folder doesn't already exist, place it at the same level as the jni folder (so they are siblings). If you take this approach you will have to use the Asset Manager. This has a native interface, found in android/asset_manager.h. To open your file use: AAsset *a = AAssetManager_open(pAssetManager, "file.txt", AASSET_MODE_BUFFER); if (a) { const void *res = AAsset_getBuffer(a); //do something with the file! AAsset_close(a); } There are different flags you can pass in instead of AASSET_MODE_BUFFER.

Categories : Java

Combine an absolute path with a relative path
Try this: string abs = "X:/A/B/Q"; string rel = "../../B/W"; var path = Path.GetFullPath(Path.Combine(abs,rel)); It will give you full absolute path http://msdn.microsoft.com/en-us/library/system.io.path.getfullpath.aspx

Categories : C#

How to convert Relative Path into absolute path in c#
try like HostingEnvironment string logDirectory = HostingEnvironment.MapPath("~") + "\" + "App_Data\MakeMyBill.sdf"; or string logDirectory =Server.MapPath("~/App_Data/MakeMyBill.sdf") or on any folder string filePath = @"D:file"; string directoryName = Path.GetDirectoryName(filePath); filePath = directoryName + @"file.xml";

Categories : Asp Net Mvc

Relative path on unit test project c#
The location of Validator should not be relevant. Any relative path should be relative to the directory your test application is executing in, so just set targetFile to be a relative path from there. Then make sure you are running your tests from the same relative location on the bulid server as on your dev machine. Bonus tip: use Assert.IsTrue(actual);

Categories : C#

Find the relative path of a file in a project
You can tweak this code to your needs: (defun java-package-name (file) "Generates package name for FILE, based on path." (let* ((f (file-name-directory file)) (rem (car (sort (delq nil (mapcar (lambda(x) (and (string-match (expand-file-name x) f) (substring f (match-end 0)))) (parse-colon-path (getenv "CLASSPATH")))) (lambda (a b) (< (length a) (length b))))))) (cond ((null rem) "Not on CLASSPATH.") ((= 0 (length rem)) "At root of CLASSPATH") (t (mapconcat #'downcase (delete "" (split-string rem "[\\/]")) ".")))))

Categories : Emacs

How to get absolute path to file in /resources folder in your project
You can create a File object and use getAbsolutePath method: File file = new File("resources/abc.txt"); String absolutePath = file.getAbsolutePath();

Categories : Java

T4 Assembly Directive with Relative Path in Website Project?
I think you can find it using the envDTE (Example here to navigate the project to find the bin directory.

Categories : C#

Find absolute base path of the project directory (after Meteor 0.6.5)
I ran into the same predicament when I updated to 0.6.5. What I'm currently doing is getting the path like this: var meteor_root = Npm.require('fs').realpathSync( process.cwd() + '/../' ); This returns on dev mode: /my/application/.meteor/local/build/programs and on bundled mode: /my/application/build/app/programs So from here I'm getting to my application's "root" path like so: var application_root = Npm.require('fs').realpathSync( meteor_root + '/../' ); // if running on dev mode if( Npm.require('path').basename( Npm.require('fs').realpathSync( meteor_root + '/../../../' ) ) == '.meteor' ){ application_root = Npm.require('fs').realpathSync( meteor_root + '/../../../../' ); } The only case in which this would fail is if you happen to name your application's folder ".met

Categories : Node Js

In php how to replace relative path to absolute path for images and download that php file as a doc file?
You can use html <base> (inside head section) tag and set "root" for your images. For example: <head> .. <base href="http://yourdomain.com/optional_base_folder_to_all_images/" /> .. </head>

Categories : PHP

How do I create an absolute file path from a QDir and a relative file path?
You can use QFileInfo for that, use the constructor that takes a QDir and a QString, then call absoluteFilePath or canonicalFilePath depending on what you want exactly. QDir dir; // ... QString file; // ... QFileInfo fi(dir, file); QString canonical = fi.canonicalFilePath();

Categories : C++

Jquery relative and absolute path
The way JavaScript works it that it loads from the file it was called from and now the file it was written in. In order to do what you need you need to supply the relative path from the current page you're viewing. Example: If current page is http://www.domain.com then you'll need to do: $("#test").load("wp-content/includes/mytheme/index_loader.php"); If current page is http://www.domain.com/wp-content/index.php then you'll need to do: $("#test").load("includes/mytheme/index_loader.php"); As a side note CSS is not the same way and CSS the relative path is based on the file it's written in.

Categories : Javascript

Relative or Absolute path not opening
Try this to avoid ambiguity dirname(__FILE__) OR if you're using PHP 5.3 or higher use this -> __DIR__ . Usage - require dirname(__FILE__) . '/../../filename.php'; OR - require __DIR__ . '/../../../filename.php'; more from manuals - http://php.net/manual/en/language.constants.predefined.php

Categories : PHP

Absolute/relative path in java (jar, ide)
Here's what the javadoc says about the constructor of ImageIcon: Creates an ImageIcon from the specified file. The image will be preloaded by using MediaTracker to monitor the loading state of the image. The specified String can be a file name or a file path. (emphasis mine) Your image is not stored in a file. It isn't in your file system. It's in a jar that is itself in the classpath. And that's where you want to load it from. Wherever the jar file of your application is on the end-user's machine, your program wants to load it from this jar file. And all the resources in this jar file are available from the ClassLoader. So you should use new ImageIcon(MyClass.class.getResource("/res/background.jpg")) or new ImageIcon(MyClass.class.getClassLoader().getResource("res/background

Categories : Java

git: Get absolute path of file, relative to repo
Use git ls-tree: $ cd lib $ git ls-tree --full-name --name-only HEAD test.c lib/test.c This only works for files that have been committed into the repo, but it's better than nothing.

Categories : GIT

How do I use a Java project that requires a 1.7 compliance level on an Android project build path?
Try to clean your project, and fix android properties. Link here and here

Categories : Android

Should I be using a relative or absolute path for best security or best practice in PHP header()
The HTTP spec requires a full URL, so you should always use that. Some implementations (ie browsers) will accept a path without the domain, and assume it refers to the current domain, but you should not count on it. It's easy enough to construct the full path using the available $_SERVER variables, so you should make sure you always do it.

Categories : PHP

included dbconfig.php file failes when using a direct path instead of relative path
You are trying to include file over HTTP. That is not right, you should include files with passing your local filesystem path to include or require. Your root should probably look like so: $root = '/var/www/mywebsite/testing-folder/';

Categories : PHP

How to resolve a relative directory path to canonical path in MATLAB/Octave
The simplest way I know to convert a path to its canonical form is using cd command: oPath = cd(cd(iPath)); Note that this would fail if the path does not exist on your file system.

Categories : Matlab

do relative path in wordpress plugin point to wp-admin path?
I use the following in the main plugin file to define its URL and Path: $this->plugin_url = plugins_url( '/', __FILE__ ); $this->plugin_path = plugin_dir_path( __FILE__ ); Then, print the image like: echo '<img src = "' . $this->plugin_url . 'images-uploads/image.jpg">';

Categories : PHP

Expand a relative path but not follow any symlink in the path in Python
Not sure that's what you're looking for, but... you can write a function that generate the "logical" full path from the relative path and current working directory then check that the generated path really exists on the system. That function could look like: import os def absolute_path(path): wd = os.getcwd() full = os.path.join(wd, path) parts = full.split(os.sep) kept = [] skip = 0 for part in reversed(parts): if part == '..': skip += 1 elif skip == 0: kept.insert(0, part) else: skip -= 1 return os.sep + os.path.join(*kept)

Categories : Python

compare path and get relative path between two files with javascript
Unfortunately, JavaScript has no native method for doing this. But the path module in node.js has! This code has been taken from the node.js path module source code function relative(from, to) { function trim(arr) { var start = 0; for (; start < arr.length; start++) { if (arr[start] !== '') break; } var end = arr.length - 1; for (; end >= 0; end--) { if (arr[end] !== '') break; } if (start > end) return []; return arr.slice(start, end - start + 1); } var fromParts = trim(from.split('/')); var toParts = trim(to.split('/')); var length = Math.min(fromParts.length, toParts.length); var samePartsLength = length; for (var i = 0; i < length; i++) { if (fromParts[i] !== toParts[i]) {

Categories : Javascript

asp.net MVC saving relative path in database as not the full path
If your question is "How to save as full path", please try this string path = Path.Combine(Server.MapPath("~/Content/img/Company/LogoFiles"), filename); If your question is "How to save as relative path", please try this [HttpPost] public ActionResult Save(HttpPostedFileBase myFile) { string filename = myFile.FileName; string relativeFileName = "~/Content/Uploads/" + filename;// relative path return View(); }

Categories : Sql Server

Use absolute full path to the img instead of the local path
Try: my_path = "/images/myimage.jpg"; See Why would a developer place a forward slash at the start of each relative path? to understand the function of the forward slash in this context.

Categories : Javascript

For a packaged app, how do you get the project name and path?
Quoting @ashwoods: If you are just publishing a resusable app, you should let the users manage the packaging, python path, etc... of the project. If you are distributing a functional project, then make your project a python module and have them install that.

Categories : Python

URL path not working, absolute path does
try to change url 'http://mydomain.com/' by a function function selfURL(){ $server1 = $_SERVER['HTTPS']; $server2 = $_SERVER['SERVER_PROTOCOL']; $server3 = $_SERVER['SERVER_PORT']; $server4 = $_SERVER['SERVER_NAME']; $s = empty($server1) ? '' : ($server1 == "on") ? "s" : ""; $protocol = strleft(strtolower($server2), "/").$s; $port = ($server3 == "80") ? "" : (":".$server3); return $protocol."://".$server4.$port; } function strleft($s1, $s2){ return substr($s1, 0, strpos($s1, $s2)); } print(selfURL()); you can replace '$port' if it not used

Categories : PHP

Search Path for C Code Project
Use -I compilation flag to specify the include path. e.g. gcc -I/var/lib curl.c If the #include is #include <curl/curl.h> then the header file will be found in directory /var/lib/curl.

Categories : C

How to set file path to src folder of project
Leave the path off entirely, it will use the directory of the project. Change File f = new File("/Users/S0urceC0ded/Desktop/Code/project/JavaStuffs/src/axmlfile.xml"); To File f = new File("axmlfile.xml");

Categories : Java

Add external jar to web project class-path
ok, jboss is a bit difficult on classloading, but its definitely possible. you need to add a new jboss module for your external jar and then declare your web application to depend on that module. there's a complete guide for this here. its possible to define a module to reference a jar file completely outside the jboss folder (c:mylib.jar in your case) but it'll be easier on you if youre willing to move the jar into /modules see here for complete documentation on how to write module descriptors. you can set the path to lead to your external jar (but its gonna be ugly)

Categories : Java

How to get installation path from setup project
If you want the install folder, then this code should work: //getting the full path including the filename string assemblyPath = Context.Parameters["assemblyPath"]; //removing the filename from the path int i = assemblyPath.Length-1; while (assemblyPath[i] != '\') --i; string path = assemblyPath.Substring(0, i); if you want the full path including the filename it is stored here: Context.Parameters["assemblyPath"]

Categories : C#

Path to file in azure project
Azure is nothing special! It is just IIS! So whatever you do locally and works, will work in Azure too (as a general rule of thumb). Have you tried HttpContext.Current.Server.MapPath("~/bin/name_of_file.xml");? I also wonder why would you set its Copy Local attribute. The correct way of adding XML to a solution is to make it's Build Action to Content and Copy to Output to Do not copy. Then just Server.MapPath("~/name_of_file.xml") should be OK.

Categories : Azure

Ruby and compass path with yeoman project
I had to run this: gem install compass Found here: Angular with Yeoman 1.0 and Grunt (I thought I had Compass installed by following the instructions here but it wasn't sufficient.)

Categories : Ruby

Get project path from POCO migration Seed()
You should use System.Reflection.Assembly.GetEntryAssembly().Location Note that it will return the path of your process exe. You'll have to use System.IO.Path.GetDirectoryName(path) to get the path of the directory containing your process exe. For MSDN : GetCallingAssembly => The assembly of the method that invoked the currently executing method. GetExecutingAssembly => The assembly that contains the code that is currently executing. GetEntryAssembly => The assembly that is the process executable.

Categories : C#

Add eclipse project lib to maven build path?
There is a workaround to use non maven project in maven dependencies, we should not use it, but when we have not the choice, use the "system" scope: <dependency> <groupId>org.yourjar</groupId> <artifactId>yourjar</artifactId> <version>0.1</version> <scope>system</scope> <systemPath>${project.basedir}/lib/yourjar.jar</systemPath> </dependency>

Categories : Android

How can I set a class to always search in its own project folder for a given path?
If you want to access a resource that is in the same package as your class, you can do so as YourClass.class.getResourceAsStream("path/to/other/resource"); There is no preceding / because the path is relative to the package of the class YourClass. This is explained in the javadoc of Class#getResource(String) Before delegation, an absolute resource name is constructed from the given resource name using this algorithm: If the name begins with a '/' ('u002f'), then the absolute name of the resource is the portion of the name following the '/'. Otherwise, the absolute name is of the following form: modified_package_name/name Where the modified_package_name is the package name of this object with '/' substituted for '.' ('u002e'). For example, for the fully qualified

Categories : Java

how to set winston log path to project local folder
Off top of my head, try using 'data.log' instead of './data.log'. You must include the code you used for configuring and logging with Winston in order for us to help. Also exactly what do you mean when you say you installed winston locally? If the file was specified as './data.log' and that was written to your home folder, then the current working directory during runtime was probably your home folder. Did you run the node program from your home folder?

Categories : Node Js

Using a batch file, I need to add a reference path to each project
Not sure if it answers the question the way that you wanted but you could use a CI server such as Jenkins: http://jenkins-ci.org/ and then you wouldn't need to figure out how to create a multi-build .bat script. Each project could still have it's own independent build script and Jenkins can handle building them as a group.

Categories : Visual Studio 2010



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.