realpath

How can I tune the PHP realpath cache?

大城市里の小女人 提交于 2019-11-30 07:32:16
Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once() and include_once() can take advantage of it. There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how much of that cache we're using. The docs are vague: Determines the size of the realpath cache to be used by PHP. This value should be increased on systems where PHP opens many files, to reflect the quantity of the file operations performed. Yes, I can jack up the

get realPath return null on android marshmallow?

十年热恋 提交于 2019-11-29 14:20:49
问题 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}; cursor = context.getContentResolver().query(contentUri, proj, null, null, null); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); return cursor.getString(column_index); } finally { if (cursor != null) { cursor.close(); } } } the above

PHP find require_once real path

本小妞迷上赌 提交于 2019-11-29 02:38:26
i need to require_once this files main.class.php and functions.php and config.php to admin/test.php . how to php find require real path?! NOTE: main.class.php in class folder , functions.php in includes folder and config.php in root directory and test.php in admin folder . File Directory: root /admin/ ->test.php /class/ ->main.class.php /includes/ ->functions.php /templates config.php phpinfo.php I would add your root folder to the include path and work from there. From admin/test.php set_include_path(implode(PATH_SEPARATOR, array( realpath(__DIR__ . '/..'), get_include_path() ))); require

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

落花浮王杯 提交于 2019-11-29 02:02:23
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 solution should be possible to make in Spring. If you need this in a servlet then use getServletContext().getRealPath("/filepathInContext") ! getServletContext().getRealPath("") - This way will not work if content is being made available from a .war archive. getServletContext() will be null. In this case we can use another way to get real path. This

realpath() without resolving symlinks?

▼魔方 西西 提交于 2019-11-28 11:03:17
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 realpath() ? "/var/", "../etc///././/passwd" => "/etc/passwd" Here is a normalize_path() function: If the given path is relative, the function starts by prepending the current working directory to it. Then the special path components like .. , . or empty components are treated, and the result is returned. For .. , the last component is removed if there

Replace PHP's realpath()

£可爱£侵袭症+ 提交于 2019-11-27 19:11:39
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, it works the first time). Also, it is so buggy in earlier PHP versions, that it is completely unusable. Well...it already is, since it's not consistent. Anyhow, what options do I have? Maybe rewrite it by myself? Is this advisable? Christian Thanks to Sven Arduwie's code ( pointed out by Pekka ) and some modification, I've built a (hopefully)

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

守給你的承諾、 提交于 2019-11-27 16:32:04
问题 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 solution should be possible to make in Spring. 回答1: If you need this in a servlet then use getServletContext().getRealPath("/filepathInContext") ! 回答2: getServletContext().getRealPath("") - This way will not work if content is being made available

realpath() without resolving symlinks?

筅森魡賤 提交于 2019-11-27 05:56:42
问题 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 realpath() ? "/var/", "../etc///././/passwd" => "/etc/passwd" 回答1: Here is a normalize_path() function: If the given path is relative, the function starts by prepending the current working directory to it. Then the special path components like .. , .

Replace PHP's realpath()

二次信任 提交于 2019-11-27 04:21:22
问题 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, it works the first time). Also, it is so buggy in earlier PHP versions, that it is completely unusable. Well...it already is, since it's not consistent. Anyhow, what options do I have? Maybe rewrite it by myself? Is this advisable? 回答1: Thanks to

Example of realpath function in C

邮差的信 提交于 2019-11-27 03:21:23
问题 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. 回答1: The realpath() function is not described in the C Standard. It is however described by POSIX 1997 and POSIX 2008. If that is what you mean, here is an example: #include <limits.h> /* PATH_MAX */ #include <stdio.h> #include <stdlib.h> int main(void) { char buf[PATH_MAX]; /* PATH_MAX incudes the \0 so +1 is not required */ char *res =