Get 4D folder

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 11.2 (Modified)


Get 4D folder ({folder}{; }{*}) String

ParameterTypeDescription
folderLongintFolder type (if omitted = active 4D folder)
**Return folder of host database
Function resultStringPathname to 4D Folder

Description

The Get 4D folder command returns the pathname to the active 4D folder of the current application, or to the 4D environment folder specified by the folder parameter, if passed. This command allows you to get the actual pathname of the folders used by the 4D application. By using this command, you ensure that your code will work on any platform running any localized system.

In folder, you can pass one of the following constants, which are located in the "4D Environment" theme:

ConstantTypeValue
Active 4D FolderLongint0 (default)
Licenses FolderLongint1
Extras FolderLongint2
4D Client Database FolderLongint3
Database FolderLongint4
Database Folder Unix SyntaxLongint5
Current Resources folderLongint6
Logs FolderLongint7
HTML Root FolderLongint8

You will find below a description of each folder:

Preliminary notes about folder names:

{Disk} is the disk where the system is installed.

The word User represents the name of the user that opened the session.

Active 4D Folder

The 4D environment uses the 4D folder to store the following information:

Preferences files used by the 4D environment applications

Shortcuts.xml file (custom keyboard shortcuts)

Macros v2 folder (macro commands of Method editor)

Favorites v11 folder (pathnames for local and remote databases that have been opened)

The 4D folder is created by default at the following location:

OnWindows Vista: {Disk}:\Users\Current user\AppData\Roaming\4D

On Windows XP: {Disk}:\Documents and Settings\Current user\Application Data\4D

On Mac OS: {Disk}:Users:Current user:Library:Preferences:4D

Licenses Folder

Folder containing the Licenses files of the machine.

The Licenses folder is placed at the following location:

On Windows Vista: {Disk}:\ProgramData\4D\Licenses

On Windows XP: {Disk}:\Documents and Settings\All Users\Application Data\4D\Licenses

On Mac OS: {Disk}:Library:Application Support:4D:Licenses

Notes:

In the case of an application merged with 4D Volume Desktop, the licenses folder is included in the package of the application.

If the licenses folder cannot be created in the system because of a lack of authorization, it is created at the following locations:

- On Windows Vista: {Disk}:\Users\Current user\AppData\Roaming\4D\Licenses

- On Windows XP: {Disk}:\Documents and Settings\Current user\Application Data\4D\Licenses

- On Mac OS: {Disk}:Users:Current user:Library:Application Support:4D:Licenses

Extras Folder (obsolete)

Folder with customized contents downloaded to each client machine.

Compatibility Note: Beginning with version 11.2 of 4D v11 SQL, it is no longer advisable to use the Extras folder for customized communication between the server and remote machines. It is now recommended to use the Resources folder for this purpose (see the description of the current Resources folder below). The Extras folder is nevertheless still supported by 4D Server so as to maintain the compatibility of existing applications.

Note: If the Extras folder does not exist for the database, executing the Get 4D folder command with the Extras Folder constant will create it.

4D Client Database Folder (Client machines)

4D database folder created on each 4D client machine for storing files and folders related to the database (resources, plug-ins, Resources folder, etc.).

The 4D Client Database Folder is placed at the following location on each client machine:

On Windows Vista: {Disk}:\Users\Current user\AppData\Local\4D\DatabaseName_Address

On Windows XP: {Disk}:\Documents and Settings\Current user\Local Settings\Application Data\DatabaseName_Address

On Mac OS: {Disk}:Users:User:Library:Caches:4D:DatabaseName_Address:

Database Folder

Folder containing the database structure file. The pathname is expressed using the standard syntax of the current platform.

With the 4D Client application, this constant is strictly equivalent to the previous 4D Client Database Folder constant: the command returns the pathname of the folder created locally.

Database Folder Unix Syntax

Folder containing the database structure file. This constant designates the same folder as the previous one but the pathname returned is expressed using the Unix syntax (Posix), of the type /Users/... This syntax is mainly used when you use the LAUNCH EXTERNAL PROCESS command under Mac OS or the SET CGI EXECUTABLE command.

Current Resources folder

Resources folder of the database. This folder contains the additional items (pictures, texts) used for the database interface. A component can have its own Resources folder. The Resources folder is located next to the database structure file.

In client/server mode, this folder can be used to organize the transfer of custom data (pictures, files, subfolders, etc.) between the server machine and the client machines. The contents of this folder are automatically updated on each client machine when it connects. All referencing mechanisms associated with the Resources folder are supported in client/server mode (.lproj folder, XLIFF, pictures, and so on). In addition, 4D v11 SQL provides various tools that can be used to manage and update this folder dynamically, more particularly a resources explorer.

Note: If the Resources folder does not exist for the database, executing the Get 4D folder command with the Current Resources folder constant will create it.

Logs Folder

The Logs folder of the database. This folder centralizes the log files of the current database. It is created at the same level as the structure file and contains the following log files:

database conversion,

Web server requests,

data verification and repair,

structure verification and repair,

backup/restore activities journal,

command debugging,

4D Server requests (generated on client machines and on the server).

Note: If the Logs folder does not exist for the database, executing the Get 4D folder command with the Logs Folder constant will create it.

HTML Root Folder

Current HTML root folder of the database. The pathname returned is expressed with the standard syntax of the current platform. The HTML root folder is the folder in which the 4D Web server looks for the requested Web pages and files. By default, it is named WebFolder and is placed next to the structure file. Its location can be set on theWeb/Configuration page of the Preferences or dynamically via the SET HTML ROOT command.

If the Get 4D folder command is called from a remote 4D, the path returned is that of the remote machine, not that of 4D Server.

The optional * parameter is useful in the case of an architecture using components: it can be used to determine the database (host or component) for which you want to get the folder pathname. This parameter is only valid for Database Folder, Database Folder Unix Syntax and Current Resources folder folders. It is ignored in all other cases.

When the command is called from a component:

If the * parameter is passed, the command returns the pathname of the host database folder,

If the * parameter is not passed, the command returns the pathname of the component folder.

The database folder (Database Folder and Database Folder Unix Syntax) returned differs according to the type of the component architecture:

- In the case of a .4dbase folder/package, the command returns the pathname of the .4dbase folder/package,

- In the case of a .4db or .4dc file, the command returns the pathname of the "Components" folder,

- In the case of an alias or shortcut, the command returns the pathname of the folder containing the original matrix database. The result differs according to the format of this database (.4dbase folder/package or .4db/.4dc file), as described above.

When the command is called from the host database, it always returns the pathname of the host database folder, regardless of whether or not the * parameter is passed.

Examples

1. During the startup of a single-user database, you want to load (or create) your own settings in a file located in the 4D folder. To do so, in the On Startup Database Method, you can write code similar to this:

   MAP FILE TYPES("PREF";"PRF";"Preferences file")
      ` Map PREF Mac OS file type to .PRF Windows file extension
   $vsPrefDocName:=Get 4D folder+"MyPrefs"   ` Build pathname to the Preferences file
      ` Check if the file exists
   If (Test path name($vsPrefDocName+(".PRF"*Num(On Windows)))#Is a document) 
      $vtPrefDocRef:=Create document($vsPrefDocName;"PREF") ` If not, create it
   Else
      $vtPrefDocRef:=Open document($vsPrefDocName;"PREF") ` If so, open it
   End if
   If (OK=1)
         ` Process document contents
      CLOSE DOCUMENT($vtPrefDocRef)
   Else
         ` Handle error
   End if

2. This example illustrates the use of the Database Folder Unix Syntax constant under Mac OS to list the contents of the database folder:

   $posixpath:="\""+Get 4D folder(Database Folder Unix Syntax)+"\""
   $myfolder:="ls -l "+$posixpath
   $in:=""
   $out:=""
   $err:=""
   LAUNCH EXTERNAL PROCESS($myfolder;$in;$out;$err)

Note: Under Mac OS, it is necessary to put pathnames in quotes when they contain the names of files or folders with spaces in them. The escape sequence "\" can be used to insert the quotation mark character into the string. You can also use the statement Char(Double quote).

See Also

COMPONENT LIST, SET HTML ROOT, System folder, Temporary folder, Test path name.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next