blob: 705ca23b9189df1d5a3456114982c9f91f500ef0 [file] [log] [blame]
Derek Jones8ede1a22011-10-05 13:34:52 -05001###########
2Path Helper
3###########
4
5The Path Helper file contains functions that permits you to work with
6file paths on the server.
7
Derek Jones6851be12013-07-19 16:47:12 -07008.. contents::
9 :local:
10
11.. raw:: html
12
13 <div class="custom-index container"></div>
Derek Jones8ede1a22011-10-05 13:34:52 -050014
15Loading this Helper
16===================
17
Andrey Andreev53b8ef52012-11-08 21:38:53 +020018This helper is loaded using the following code::
Derek Jones8ede1a22011-10-05 13:34:52 -050019
20 $this->load->helper('path');
21
Derek Jones6851be12013-07-19 16:47:12 -070022Available Functions
23===================
24
Derek Jones8ede1a22011-10-05 13:34:52 -050025The following functions are available:
26
Derek Jones8ede1a22011-10-05 13:34:52 -050027
Derek Jones6851be12013-07-19 16:47:12 -070028.. function:: set_realpath($path[, $check_existance = FALSE])
Derek Jones8ede1a22011-10-05 13:34:52 -050029
Andrey Andreev53b8ef52012-11-08 21:38:53 +020030 :param string $path: Path
31 :param bool $check_existance: Whether to check if the path actually exists
Andrey Andreev3de130c2014-02-07 23:31:49 +020032 :returns: An absolute path
33 :rtype: string
Andrey Andreev53b8ef52012-11-08 21:38:53 +020034
Derek Jones6851be12013-07-19 16:47:12 -070035 This function will return a server path without symbolic links or
36 relative directory structures. An optional second argument will
37 cause an error to be triggered if the path cannot be resolved.
Andrey Andreev53b8ef52012-11-08 21:38:53 +020038
Derek Jones6851be12013-07-19 16:47:12 -070039 Examples::
Derek Jones8ede1a22011-10-05 13:34:52 -050040
Derek Jones6851be12013-07-19 16:47:12 -070041 $file = '/etc/php5/apache2/php.ini';
42 echo set_realpath($file); // Prints '/etc/php5/apache2/php.ini'
Taufan Adityaf2915f22012-03-14 00:02:39 +070043
Derek Jones6851be12013-07-19 16:47:12 -070044 $non_existent_file = '/path/to/non-exist-file.txt';
45 echo set_realpath($non_existent_file, TRUE); // Shows an error, as the path cannot be resolved
46 echo set_realpath($non_existent_file, FALSE); // Prints '/path/to/non-exist-file.txt'
Taufan Adityaf2915f22012-03-14 00:02:39 +070047
Derek Jones6851be12013-07-19 16:47:12 -070048 $directory = '/etc/php5';
49 echo set_realpath($directory); // Prints '/etc/php5/'
Derek Jonesb8c283a2013-07-19 16:02:53 -070050
Derek Jones6851be12013-07-19 16:47:12 -070051 $non_existent_directory = '/path/to/nowhere';
52 echo set_realpath($non_existent_directory, TRUE); // Shows an error, as the path cannot be resolved
53 echo set_realpath($non_existent_directory, FALSE); // Prints '/path/to/nowhere'