DEV Community

Peter + AI
Peter + AI

Posted on

πŸ—‚οΈ Mastering Directory Management in Uniface: The ldirdelete Command

When working with file system operations in Uniface, developers often need to clean up directories programmatically. Today, let's explore the ldirdelete command - a powerful tool for directory deletion that offers more control than its standard counterpart.

πŸ“‹ What is ldirdelete?

The ldirdelete statement is a specialized directory deletion command in Uniface that ignores any file redirections specified in the assignment file. This makes it particularly useful when you need to ensure direct file system operations without interference from redirection settings.

πŸ”§ Syntax and Usage

The syntax is straightforward:

ldirdelete DirPath
Enter fullscreen mode Exit fullscreen mode

Example:

ldirdelete "data/exports"
Enter fullscreen mode Exit fullscreen mode

πŸ“Š Parameters

Parameter Data Type Description
DirPath String Directory name, optionally preceded by the path to the directory, which can be in a zip archive. Must end with a directory separator.

🎯 Return Values

The command returns specific error codes through $procerror:

Value Error Constant Meaning
0 - βœ… Successful
-13 ❌ An error occurred while trying to perform the OS command. Set /pri=64 to display the exact error in the message frame.

πŸ—οΈ Key Differences from dirdelete

While ldirdelete works similarly to the standard dirdelete command, the crucial difference is that ldirdelete bypasses assignment file redirections. This ensures that your directory operations target the actual file system locations rather than redirected paths.

πŸ’‘ Best Practices

  • πŸ” Always check the return value using $procerror to handle errors gracefully
  • πŸ›‘οΈ Use ldirdelete when you need to ensure direct file system access
  • πŸ“ Remember that the directory path must end with a directory separator
  • πŸ› Set /pri=64 for detailed error messages during debugging

βš™οΈ Component Compatibility

The ldirdelete statement is allowed in all Uniface component types, making it versatile for various application scenarios.

πŸš€ Conclusion

The ldirdelete command is an essential tool for Uniface developers who need reliable directory management with direct file system access. By understanding its unique behavior regarding assignment file redirections, you can make informed decisions about when to use it over the standard dirdelete command.

This article is based on the official Uniface documentation 10.4, with AI assistance in structuring the content for better readability.

Top comments (0)