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

Class: System_Folders

Source Location: /System_Folders-1.0.0/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 42]
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 68]

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

Type:   array


[ Top ]

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

[line 104]

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 131]

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

Type:   array


[ Top ]

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

[line 117]

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 90]

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 143]

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

Type:   array


[ Top ]

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

[line 160]

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 172]

Known paths for the windows directory.
  • Access: protected

Type:   array


[ Top ]

$objCom =  null

[line 213]

COM object used in Windows to get

special folder locations via SpecialFolders() described in http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/14761fa3-19be-4742-9f91-23b48cd9228f.asp

Available folders: AllUsersDesktop AllUsersStartMenu AllUsersPrograms AllUsersStartup Desktop Favorites Fonts MyDocuments NetHood PrintHood Programs Recent SendTo StartMenu Startup Templates

If this variable is NULL, it hasn't been created yet. If it is FALSE, it cannot be created and used (e.g. because COM is not available)

  • Access: protected

Type:   COM


[ Top ]

$sys =  'unknown'

[line 59]

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 221]

System_Folders System_Folders( )

Constructor; initializes the system variable.

[ Top ]

addTrailingSlash   [line 237]

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 258]

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 349]

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 388]

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 327]

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 422]

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 452]

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 483]

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 543]

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 614]

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 636]

string getSys( )

Returns the name of the guesses system.

Can be compared with SYS_* constants.

  • Return: The detected system
  • Access: public

[ Top ]

getTemp   [line 578]

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 659]

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 690]

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 299]

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 279]

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 Thu, 10 Dec 2015 05:42:41 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.