• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
      • Logic Namespace
      • Message Namespace
      • Path Namespace
        • Path Action Invoker Namespace
        • Path.createDirectory Action
        • Path.getDirectoryListing Action
        • Path.getPathInfo Action
        • Path.getSpecialPaths Action
        • Path.selectFile Action
        • Path.showFileDialog Action
      • Settings Namespace
      • Sqlite Namespace
      • System Namespace
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Path.getPathInfo Action

Format
s = CS.Path.getPathInfo(path := ...)
ArgumentDescriptionTypes / Required
pathThe path of a directory or file.string
required
Description
The Path.getPathInfo action returns information about a path, including about whether the path exists. Information about directories is specified without a trailing slash.
The action returns information that can also be retrieved using the following functions: direxist, fileexist, filesize, filetime, Path.getExtension, and Path.getFileName.
The path information for all paths in a directory can be retrieved using the Path.getDirectoryListing action.
Return Value
The action returns an object containing the properties:
PropertyValue
"path"A string containing the fully evaluated path.
"name"A string containing the name of the path (the path with the directory information removed).
"exists"A boolean value indicating if the path exists.
If the path exists, the object also contains:
PropertyValue
"type"A string indicating if the path is a "directory" or "file".
"modifiedTime"A number containing the modified date and time of the path in UNIX time.
If the path exists and is a file, the object also contains:
PropertyValue
"extension"A string containing the file extension without a preceding period.
"contentType"A string with the MIME type of the file (if known).
"size"A number containing the size of the file in bytes.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form.
Example (JavaScript)
// select an image
const imagePath = CS.Path.selectFile({
    title: 
"Select an Image",
    filter: 
"|FileType.Image"
});

if( imagePath !== undefined ) {
   
// ensure that the file size is one megabyte or less
    const imagePathInfo = CS.Path.getPathInfo({
        path: imagePath
    });

   
if( imagePathInfo.size > ( 1024 * 1024 ) ) {
       
throw new Error(`The image '${imagePathInfo.name}' is ${imagePathInfo.size} bytes but the maximum image size is 1 MB.`);
    }
}
See also: Path Action Invoker Namespace, Path.getDirectoryListing Action