summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/helpers/path_helper.rst
blob: 6efd93cc121aad9faa2c8124ee385d85a706973e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
###########
Path Helper
###########

The Path Helper file contains functions that permits you to work with
file paths on the server.

.. contents:: Page Contents

Loading this Helper
===================

This helper is loaded using the following code

::

	$this->load->helper('path');

The following functions are available:

set_realpath()
==============

Checks to see if the path exists. This function will return a server
path without symbolic links or relative directory structures. An
optional second argument will cause an error to be triggered if the path
cannot be resolved.

::

	$file = '/etc/php5/apache2/php.ini'; 
	echo set_realpath($file); // returns "/etc/php5/apache2/php.ini"  
	$non_existent_file = '/path/to/non-exist-file.txt'; 
	echo set_realpath($non_existent_file, TRUE); // returns an error, as the path could not be resolved  
	echo set_realpath($non_existent_file, FALSE); // returns "/path/to/non-exist-file.txt"   
	$directory = '/etc/passwd'; 
	echo set_realpath($directory); // returns "/etc/passwd/"  
	$non_existent_directory = '/path/to/nowhere'; 
	echo set_realpath($non_existent_directory, TRUE); // returns an error, as the path could not be resolved  
	echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere"