KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Filesystem pathnames for File and Folder
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: May 9, 2025

The 4D Folder and File commands offer various options to interact with files and directories on the system where the database application is running. These commands use classes and functions to provide their functionality.

To use these commands, you must pass a path to initialize the class object. A notable feature of these commands is support for filesystem path names, which can be used in place of full paths.
For example:

  • Full Path: C:/User/Documents/4D_Data/
  • Filesystem Path Name: /DATA
The following filesystem pathnames are available for directories relative to the current database:
  • Current data folder - "/DATA"
  • Log folder - "/LOGS"
  • Project rool folder - "/PACKAGE"
  • Project folder - "/PROJECT"
  • Current project resources folder - "/RESOURCES"
  • Current project sources folder - "/SOURCES"
When passed to the Folder command, both paths create a folder object representing the same directory. However, there are key differences:
  • The .parent property is Null when using the filesystem path name, adding a layer of security by hiding parent directory information if needed.
  • Certain properties reference /SOURCES/ instead of providing values derived from the full path.
When using filesystem path names:
  • The path format must be POSIX-compliant.
  • The filesystem portion must be in uppercase.
  • Subfile and subdirectory names do not require uppercase and are case-insensitive.
For instance, an Images folder within the Resources directory of the database could be referenced as:
  • /RESOURCES/Images
  • /RESOURCES/images
  • /RESOURCES/IMAGES
  • /RESOURCES/ImAgEs
As such, it is recommended to use the filesystem path names to utilize some of the following benefits
  • They simplify code by reducing the character count compared to full paths.
  • They improve code security by obfuscating the full directory structure.
  • They make the code more generic and adaptable.