Questions tagged [realpath]

The canonical path of the specified filename.

The canonical path of the specified filename, eliminating any symbolic links encountered in the path (if they are supported by the operating system)

127 questions
70
votes
4 answers

What does servletcontext.getRealPath("/") mean and when should I use it

In the following snippet: ServletContext context = request.getServletContext(); String path = context.getRealPath("/"); What does / in the method getRealPath() represent? When should I use it?
saplingPro
  • 20,769
  • 53
  • 137
  • 195
24
votes
3 answers

How to translate the wslpath /home/user/ to windows path

I use Linux subsystem of windows 10(windows 10 version 1803) I can use command line: user@laptop:~$ wslpath -w /c/ C:\ But when I try to use user@laptop:~$ wslpath -w ~ wslpath: /home/user: Result not representable Even I use: user@laptop:~$…
user504909
  • 9,119
  • 12
  • 60
  • 109
20
votes
3 answers

Example of realpath function in C

I'm looking for an example of how to use the realpath function in a C program. I can't seem to find one on the web or in any of my C programming books.
Ralph
  • 6,249
  • 7
  • 23
  • 19
18
votes
2 answers

How to save generated file temporarily in servlet based web application

I am trying to generate a XML file and save it in /WEB-INF/pages/. Below is my code which uses a relative path: File folder = new File("src/main/webapp/WEB-INF/pages/"); StreamResult result = new StreamResult(new File(folder, fileName)); It's…
sjohnson
  • 315
  • 1
  • 3
  • 7
13
votes
3 answers

realpath() without resolving symlinks?

I already read about realpath(), but is there a function that I can pass a base directory and a filename that would give me the following result without resolving symlinks or checking whether files actually exist? Or do I have to use a modified…
thejh
  • 44,854
  • 16
  • 96
  • 107
12
votes
3 answers

realpath returns empty string

I use MediaWiki but there is an error. I found it in the files. There is line with this code: $IP = realpath( '.' ); But $IP returns an empty string, so the path to the files in the system is not working. (for example if $IP would be . or…
Jordy
  • 4,719
  • 11
  • 47
  • 81
12
votes
6 answers

Alternative to 'realpath' to resolve "../" and "./" in a path

realpath does what I need, but only works if the files in the path actually exist. I need a function which returns a normalized path from a string (e.g. ../some/./directory/a/b/c/../d to some/directory/a/b/d), regardless of whether the…
Silverlan
  • 2,783
  • 3
  • 31
  • 66
11
votes
9 answers

How can I get real path for file in my WebContent folder?

I need to get real path for file in my WebContent directory, so that framework that I use can access that file. It only takes String file as attribute, so I need to get the real path to this file in WebContent directory. I use Spring Framework, so…
newbie
  • 24,286
  • 80
  • 201
  • 301
10
votes
6 answers

Replace PHP's realpath()

Apparently, realpath is very buggy. In PHP 5.3.1, it causes random crashes. In 5.3.0 and less, realpath randomly fails and returns false (for the same string of course), plus it always fails on realpath-ing the same string twice/more (and of course,…
Christian
  • 27,509
  • 17
  • 111
  • 155
10
votes
2 answers

How does PHP realpath cache work under the hood?

I have been unable to figure out what the realpath cache is actually doing. Here are some of the questions I have: When exactly is a path cached, and under what criteria might it not be cached? How is it cached? In memory, on the file system,…
Gerard Roche
  • 6,162
  • 4
  • 43
  • 69
7
votes
1 answer

get realPath return null on android marshmallow?

I am using this function to get the image path from uri: private static String getRealPathFromURI(Context context, Uri contentUri) { Cursor cursor = null; try { String[] proj = {MediaStore.Images.Media.DATA}; …
david
  • 3,310
  • 7
  • 36
  • 59
6
votes
1 answer

python os.path.realpath not working properly

I have following code: os.chdir(os.path.dirname(os.path.realpath(__file__)) + "/../test") path.append(os.getcwd()) os.chdir(os.path.dirname(os.path.realpath(__file__))) Which should add /../test to python path, and it does so, and it all runs…
jj.
  • 105
  • 1
  • 1
  • 5
6
votes
2 answers

How to get canonicalized path (realpath) of nonexistent file in PHP?

script.php $filename = realpath(sprintf("%s/%s", getcwd(), $argv[1])); var_dump($filename); Let's try some things [/foo/bar/bof] $ php script.php ../foo.txt string(16) "/foo/bar/foo.txt" [/foo/bar/bof] $ php script.php…
Mulan
  • 129,518
  • 31
  • 228
  • 259
5
votes
1 answer

Android Q - How to get real path of Downloads folder

With Intent.ACTION_OPEN_DOCUMENT_TREE I get this uri : content://com.android.providers.downloads.documents/tree/downloads How can I convert it to /storage/emulated/0/Download - the real path? I don't want use…
user1063364
  • 791
  • 6
  • 21
5
votes
2 answers

Cross-platform alternative to this realpath definition?

So, someone recently submitted some bug fixes to my project, and they also included this: #ifdef _MSC_VER #ifndef PATH_MAX #define PATH_MAX _MAX_PATH #endif #define realpath(N,R) _fullpath((R),(N),_MAX_PATH) #endif The problem is…
Kelvin Shadewing
  • 303
  • 2
  • 16
1
2 3
8 9