blob: 61877d75bddfd1519c94529ad11045e6c6d8cdd6 [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
32 :returns: string
33
Derek Jones6851be12013-07-19 16:47:12 -070034 This function will return a server path without symbolic links or
35 relative directory structures. An optional second argument will
36 cause an error to be triggered if the path cannot be resolved.
Andrey Andreev53b8ef52012-11-08 21:38:53 +020037
Derek Jones6851be12013-07-19 16:47:12 -070038 Examples::
Derek Jones8ede1a22011-10-05 13:34:52 -050039
Derek Jones6851be12013-07-19 16:47:12 -070040 $file = '/etc/php5/apache2/php.ini';
41 echo set_realpath($file); // Prints '/etc/php5/apache2/php.ini'
Taufan Adityaf2915f22012-03-14 00:02:39 +070042
Derek Jones6851be12013-07-19 16:47:12 -070043 $non_existent_file = '/path/to/non-exist-file.txt';
44 echo set_realpath($non_existent_file, TRUE); // Shows an error, as the path cannot be resolved
45 echo set_realpath($non_existent_file, FALSE); // Prints '/path/to/non-exist-file.txt'
Taufan Adityaf2915f22012-03-14 00:02:39 +070046
Derek Jones6851be12013-07-19 16:47:12 -070047 $directory = '/etc/php5';
48 echo set_realpath($directory); // Prints '/etc/php5/'
Derek Jonesb8c283a2013-07-19 16:02:53 -070049
Derek Jones6851be12013-07-19 16:47:12 -070050 $non_existent_directory = '/path/to/nowhere';
51 echo set_realpath($non_existent_directory, TRUE); // Shows an error, as the path cannot be resolved
52 echo set_realpath($non_existent_directory, FALSE); // Prints '/path/to/nowhere'