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
Example:
ldirdelete "data/exports"
π 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
$procerrorto handle errors gracefully - π‘οΈ Use
ldirdeletewhen you need to ensure direct file system access - π Remember that the directory path must end with a directory separator
- π Set
/pri=64for 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)