Standard RTL Path Functions across the Supported Target Platforms

From RAD Studio
Jump to: navigation, search

Go Up to Using the RTL in Multi-Device Applications


The following table lists the RTL file path functions that are appropriate for each of the Supported Target Platforms.

For example, if you need to access or reference the home path of your application, this table shows how to construct the reference for each supported platform.

Function \ Platform Windows OSX iOS Android Linux
System.SysUtils.pas

GetHomePath

CSIDL_APPDATA

GetEnvironmentVariable('HOME')

GetEnvironmentVariable('HOME')

GetFilesDir --> Internal Memory

GetEnvironmentVariable('HOME')

System.IOUtils.pas

TPath.GetHomePath

CSIDL_APPDATA

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\Application Data'
  • Vista or later: 'C:\Users\<username>\AppData\Roaming'

A typical result is: '/Users/<username>'

A typical result is:

  • Device: '/private/var/mobile/Applications/<application ID>'

A typical result is: '/data/data/<application ID>/files'

A typical result is: /home/<username>

TPath.GetTempPath

User 'temp' folder

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\Local Settings\Temp\'
  • Vista or later: ' C:\Users\<username>\AppData\Local\Temp\'

A typical result is: '/var/folders/<random folder name>/'

A typical result is:

  • Device: '/private/var/mobile/Applications/<application ID>/tmp'

GetExternalFilesDir+'/tmp/'

A typical result is: '/storage/emulated/0/Android/data/<application ID>/files/tmp'

A typical result is:
/tmp

TPath.GetLibraryPath

Same path of Executable file.

If the .exe file is 'D:\Test\Example1.exe', a typical result is: 'D:\Test\'

NSLibraryDirectory

A typical result is: '/Users/<username>/Library'

NSLibraryDirectory

A typical result is:

  • Device: '/var/mobile/Applications/<application ID>/Library'

GetLibraryPath

A typical result is: '/data/app-lib/<application ID>-1'

A typical result is equal to getcwd()

TPath.GetDocumentsPath

CSIDL_PERSONAL

A typical result is:

  • XP:
  • Vista or later:

NSDocumentDirectory

A typical result is: '/Users/<username>/Documents'

NSDocumentDirectory

A typical result is:

  • Device: '/var/mobile/Applications/<application ID>/Documents'

GetFilesDir -> Internal Memory

A typical result is: $Home/Documents

TPath.GetSharedDocumentsPath

CSIDL_COMMON_DOCUMENTS

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Documents'
  • Vista or later: 'C:\Users\Public\Documents'

NSSharedPublicDirectory

A typical result is: '/Users/<username>/Public'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalFilesDir -> External Memory

If device has external storage (for example, SD card), this method returns path name inside external storage.

If device has no external storage, this method returns somewhere inside internal storage.

A typical result is: '/storage/emulated/0/Documents'

A typical result is: $Home/Documents

TPath.GetCachePath

CSIDL_LOCAL_APPDATA

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\Local Settings\Application Data'
  • Vista or later: 'C:\Users\<username>\AppData\Local'

NSCachesDirectory

A typical result is: '/Users/<username>/Library/Caches'

NSCachesDirectory

A typical result is:

  • Device: '/var/mobile/Applications/<application ID>/Library/Caches'

GetCacheDir -> Internal Memory

A typical result is:
'/data/data/<application ID>/cache'

A typical result is:
$HOME/.cache

TPath.GetPicturesPath

CSIDL_MYPICTURES

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\My Documents\My Pictures'
  • Vista or later: 'C:\Users\<username>\Pictures'

NSPicturesDirectory

A typical result is:
'/Users/<username>/Pictures'

NSPicturesDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalPicturesDir -> External Memory

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files/Pictures'

A typical result is:
$Home/Picture

TPath.GetSharedPicturesPath

CSIDL_COMMON_PICTURES

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Documents\My Pictures'
  • Vista or later: 'C:\Users\Public\Pictures'

NSSharedPublicDirectory

A typical result is:
'/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetSharedPicturesDir -> External Memory Shared

A typical result is:
'/storage/emulated/0/Pictures'

A typical result is:
$Home/Picture

TPath.GetPublicPath

CSIDL_COMMON_APPDATA

A typical result is:

  • XP:

Vista or later: 'C:\ProgramData'

NSSharedPublicDirectory

A typical result is:
'/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalFilesDir -> External

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files'

A typical result is:
$Home/Public.

TPath.GetCameraPath

CSIDL_MYPICTURES

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\My Documents\My Pictures'
  • Vista or later: 'C:\Users\<username>\Pictures'

NSPicturesDirectory

A typical result is:
'/Users/<username>'

NSPicturesDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalCameraDir -> External Memory

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files/DCIM'

A typical result is:
$Home/Picture

TPath.GetSharedCameraPath

CSIDL_COMMON_PICTURES

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Documents\My Pictures'
  • Vista or later: 'C:\Users\Public\Pictures'

NSSharedPublicDirectory

A typical result is:
'/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetSharedCameraDir -> External Memory Shared

A typical result is:
'/storage/emulated/0/DCIM'

A typical result is:
$Home/Picture

TPath.GetMusicPath

CSIDL_MYMUSIC

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\My Documents\My Music'
  • Vista or later: 'C:\Users\<username>\Music'

NSMusicDirectory

A typical result is:
'/Users/<username>'

NSMusicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalMusicDir -> External Memory

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files/Music'

A typical result is:
$Home/Music.

TPath.GetSharedMusicPath

CSIDL_COMMON_MUSIC

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Documents\My Music'
  • Vista or later: 'C:\Users\Public\Music'

NSSharedPublicDirectory

A typical result is:
'/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetSharedMusicDir -> External Memory Shared

A typical result is:
'/storage/emulated/0/Music'

A typical result is:
$Home/Music

TPath.GetMoviesPath

CSIDL_MYVIDEO

A typical result is:

  • XP:
  • Vista or later: 'C:\Users\<username>\Videos'

NSMoviesDirectory

A typical result is: '/Users/<username>'

NSMoviesDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalMoviesDir -> External Memory

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files/Movies'

A typical result is:
$Home/Video.

TPath.GetSharedMoviesPath

CSIDL_COMMON_VIDEO

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Documents\My Videos'
  • Vista or later: 'C:\Users\Public\Videos'

NSSharedPublicDirectory

A typical result is:
'/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetSharedMoviesDir -> External Memory Shared

A typical result is:
'/storage/emulated/0/Movies'

A typical result is:
$Home/Video

TPath.GetAlarmsPath

CSIDL_MYMUSIC

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\My Documents\My Music'
  • Vista or later: 'C:\Users\<username>\Music'

NSMusicDirectory

A typical result is:
'/Users/<username>'

NSMusicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalAlarmsDir -> External Memory

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files/Alarms'

A typical result is:
$Home/Music

TPath.GetSharedAlarmsPath

CSIDL_COMMON_MUSIC

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Documents\My Music'
  • Vista or later: 'C:\Users\Public\Music'

NSSharedPublicDirectory

A typical result is: '/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetSharedAlarmsDir -> External Memory Shared

A typical result is:
'/storage/emulated/0/Alarms'

A typical result is:
$Home/Music.

TPath.GetRingtonesPath (Same as TPath.GetMusicPath)

The file system directory that serves as a common repository for ringtones sound files.

CSIDL_MYMUSIC

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\My Documents\My Music'
  • Vista or later: 'C:\Users\<username>\Music'

NSMusicDirectory

A typical result is:
'/Users/<username>'

NSMusicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalRingtonesDir -> External Memory

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files/Ringtones'

A typical result is:
$Home/Music.

TPath.GetSharedRingTonesPath

CSIDL_COMMON_MUSIC

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Documents\My Music'
  • Vista or later: 'C:\Users\Public\Music'

NSSharedPublicDirectory

A typical result is:
'/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetSharedRingtonesDir -> External Memory Shared

A typical result is:
'/storage/emulated/0/Ringtones'

A typical result is:
$Home/Music.

TPath.GetDownloadsPath

CSIDL_LOCAL_APPDATA

A typical result is:

  • XP: 'C:\Documents and Settings\<username>\Local Settings\Application Data'
  • Vista or later: 'C:\Users\<username>\AppData\Local'

NSDownloadsDirectory

A typical result is:
'/Users/<username>'

NSDownloadsDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetExternalDownloadsDir -> External Memory

A typical result is:
'/storage/emulated/0/Android/data/<application ID>/files/Download'

A typical result is:
$Home/Downloads.

TPath.GetSharedDownloadsPath

CSIDL_COMMON_APPDATA

A typical result is:

  • XP: 'C:\Documents and Settings\All Users\Application Data'
  • Vista or later: 'C:\ProgramData'

NSSharedPublicDirectory

A typical result is:
'/Users/<username>'

NSSharedPublicDirectory

A typical result is:

  • Device: This function returns an empty string as this directory is currently not supported.

GetSharedDownloadsDir -> External Memory Shared

A typical result is:
'/storage/emulated/0/Download'

A typical result is:
$Home/Downloads

See Also