System_Folders
[ class tree: System_Folders ] [ index: System_Folders ] [ all elements ]

Class: System_Folders

Source Location: /System_Folders-1.0.5/System/Folders.php

Class Overview


Provides the locations of several system and user directories independent of the operating system used.


Author(s):

Variables

Methods


Child classes:

System_Folders_Cached
Provides a cached version of System_Folders.

Inherited Variables

Inherited Methods


Class Details

[line 47]
Provides the locations of several system and user directories independent of the operating system used.

If a path does not exist or can't be found (error), NULL is returned.

The class uses both $_ENV and $_SERVER to retrieve the environment paths, as this seems to be different between php4 and 5.



[ Top ]


Class Variables

$arAppDataNames = array(
        'Application data',       //english
        'Anwendungsdaten',        //german
        'Toepassingsgegevens',    //dutch
        'Datos de programa',      //spanish
        'Dados de aplicativos',   //portugese
        'Data aplikac√≠',          //czech
        'Programdata',            //norwegian
        'Henkilokohtainen',       //finnish
        'Donnees d\'applications',//french
        'Dati applicazioni',      //italian
        'Dane aplikacji',         //polish
    )

[line 73]

Known names for the application directory in windows.
  • Access: protected

Type:   array


[ Top ]

$arDesktop = array(
        'Desktop' //english, german, italian
    )

[line 109]

Known names for the my Desktop directory.
  • Access: protected

Type:   array


[ Top ]

$arDocsAndSettings = array(
        'C:\\Documents and Settings\\',     //english, italian
        'C:\\Dokumente und Einstellungen\\' //german
    )

[line 136]

Known paths for the documents and settings directory on windows.
  • Access: protected

Type:   array


[ Top ]

$arDocumentsLinux = array(
        'Documents',    //english
        'Dokumente',    //german
        'Documenti',    //italian
    )

[line 122]

Known names for the my documents directory on linux and mac.
  • Access: protected

Type:   array


[ Top ]

$arDocumentsWindows = array(
        'My Documents',   //english
        'Own Files',      //english?
        'Eigene Dateien', //german
        'Documenti',      //italian
    )

[line 95]

Known names for the my documents directory on windows.
  • Access: protected

Type:   array


[ Top ]

$arProgramsWindows = array(
        'C:\\Program Files\\',
        'C:\\Programs\\',
        'C:\\Programme\\',     //german
        'C:\\Programmi\\',     //italian
    )

[line 148]

Known paths for the programs directory on windows.
  • Access: protected

Type:   array


[ Top ]

$arSharedDocumentsWindows = array(
        'Documents', //english
        'Dokumente', //german
        'Documenti', //italian
    )

[line 165]

Known names for the shared documents directory on windows.

Although the explorer shows "Shared documents" or "Gemeinsame Dokumente", the *real* directory is only one of the ones here.

  • Access: protected

Type:   array


[ Top ]

$arWindowsDirs = array(
        'C:\\WINDOWS\\',
        'C:\\WINNT\\',
        'C:\\WIN98\\',
        'C:\\WIN95\\',
        'C:\\WIN2000\\',
        'C:\\WIN2K\\',
        'C:\\WINXP\\'
    )

[line 177]

Known paths for the windows directory.
  • Access: protected

Type:   array


[ Top ]

$objCom =  null

[line 218]

COM object used in Windows to get

special folder locations via SpecialFolders() described in


Type:   COM


[ Top ]

$sys =  'unknown'

[line 64]

The operating system on which we work here Gotten from OS_Guess::getSysname()

Values (are lowercase):

  • windows
  • linux
  • darwin
Use the SYS_* constants to check it

  • Access: protected

Type:   string


[ Top ]



Method Detail

System_Folders (Constructor)   [line 225]

System_Folders System_Folders( )

Constructor; initializes the system variable.

[ Top ]

addTrailingSlash   [line 243]

string addTrailingSlash( string $strPath)

Adds a trailing slash to the given path if there is none.

Uses DIRECTORY_SEPARATOR, so it works with windows and *nix.

  • Return: The path with a trailing slash
  • Access: protected

Parameters:

string   $strPath     The path

[ Top ]

fixWindowsPath   [line 266]

string fixWindowsPath( string $strPath)

Directories in windows environment variables sometimes have a double backslash, and this needs to be fixed.
  • Return: The fixed path
  • Access: protected

Parameters:

string   $strPath     The path

[ Top ]

getAllUsers   [line 363]

string getAllUsers( )

Returns the All Users directory.

Works on windows only, returns NULL if not found.

  • Return: The all users directory
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getAllUsers()
Cached version of getAllUsers().

[ Top ]

getAppData   [line 407]

string getAppData( )

Returns the path to the application data directory.

This is the directory in which applications save their settings.

On Windows, this is an own directory called "Application data", on *nix, the home directory is used. MacOS X has two application settings directories:

  • $HOME/Library/Preferences/<pref_file> for normal settings
  • $HOME/Library/Application Support/<app_name>/ for data files that that the application needs to store
This method returns the latter, as it works for both storing just prefs and files in an application specific subdir. That's not 100% correct for apple, but it will work.

  • Return: The application data directory
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getAppData()
Cached version of getAppData().

[ Top ]

getCOMPath   [line 340]

mixed getCOMPath( string $strType)

Loads a windows path via COM using $objCom.
  • Return: False if no path could be obtained, string otherwise
  • Access: protected

Parameters:

string   $strType     See $objCom for allowed values.

[ Top ]

getDesktop   [line 444]

string getDesktop( )

Returns the path to the user's desktop.
  • Return: The user's desktop
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getDesktop()
Cached version of getDesktop().

[ Top ]

getDocuments   [line 475]

string getDocuments( )

Returns the path to the user's documents directory.

(normally below the home folder)

  • Return: The "documents" directory
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getDocuments()
Cached version of getDocuments().

[ Top ]

getHome   [line 507]

string getHome( )

Returns the path to the user's home directory.
  • Return: The user's home directory
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getHome()
Cached version of getHome().

[ Top ]

getPrograms   [line 572]

string getPrograms( )

Returns the path to the programs directory.

This is the dir where all programs are installed normally.

On windows, it's mostly "C:\Programs\", on linux, the /opt/ directory is returned.

  • Return: The programs directory
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getPrograms()
Cached version of getPrograms().

[ Top ]

getSharedDocuments   [line 649]

string getSharedDocuments( )

Returns the path to the shared documents directory.

Supports windows only (at least for now) as no other operating system seems to have such a folder. Returns NULL on failure (not windows or not found).

  • Return: The shared documents dir
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getSharedDocuments()
Cached version of getSharedDocuments().

[ Top ]

getSys   [line 674]

string getSys( )

Returns the name of the guesses system.

Can be compared with SYS_* constants.

  • Return: The detected system
  • Access: public

[ Top ]

getTemp   [line 610]

string getTemp( )

Returns the path to the directory for temporary files.
  • Return: The temporary directory
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getTemp()
Cached version of getTemp().

[ Top ]

getUserName   [line 698]

string getUserName( )

Returns the name for the user under which name the program runs.

This function returns the *system user name*, not the name with forename and surname On unix, this would be e.g. 'fbar' or so for the user 'Foo Bar'

This method is used my most other methods, so recognizing the user name is really important. Be sure to check this method if the others fail.

  • Return: The user name
  • Access: public

[ Top ]

getWindows   [line 728]

string getWindows( )

Returns the windows directory (if any).

NULL is returned if the system is not Windows.

  • Return: The windows directory, NULL if not on windows
  • Access: public

Overridden in child classes as:

System_Folders_Cached::getWindows()
Cached version of getWindows().

[ Top ]

loadCOM   [line 310]

boolean loadCOM( )

Loads the COM object into the $objCom variable.
  • Return: True if it could be loaded, false if not
  • Access: protected

[ Top ]

tryPaths   [line 289]

string tryPaths( array $arPaths, [string $strBase = ''], [string $strSuffix = ''])

Loops through a list of given paths and checks which of them are correct.
  • Return: The directory that exists. NULL if none of them matched.
  • Access: protected

Parameters:

array   $arPaths     Array with paths to test
string   $strBase     Base directory that shall be prepended to all paths
string   $strSuffix     String appended to the directory path

[ Top ]


Documentation generated on Fri, 21 Dec 2012 15:30:03 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.