dirdelete

Delete the specified directory.

dirdelete  DirPath

Example: dirdelete "data/exports"

Parameters

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

Values returned by $procerror
Value  Error constant Meaning
0

 

Successful
-13 <UIOSERR_OS_COMMAND> An error occurred while trying to perform the OS command. Set /pri=64 to display the exact error in the message frame.

Use

Allowed in all component types.

Description

The dirdelete statement deletes the specified directory DirPath, using any file redirections in the assignment file.

Specifying the Directory

  • Each specification can be a string, a field (or indirect reference to a field), a variable, or a function that evaluates to a string.
  • The total length of any path (or file name or directory name) must not exceed 255 bytes.
  • Valid generic directory separators are the backward slash (\), the forward slash (/) , and the period (.) in combination with square brackets ([a.b]). These are translated to the platform-specific separators.
  • No wildcards are allowed in any path, except for $ldirlist and $dirlist, which allows the Uniface wildcards ? (GOLD ?) and * (GOLD *) in the directory name, for example ab?, or in its suffix, for example abc\*.txt.

For more information, see Syntax of File and Directory Names.

Operation Failure

The operation fails if DirPath:

  • Is not a directory
  • Is the current directory or root
  • Is not empty
  • Is in use (locked)
  • Does not permit user-deletion due to insufficient authorization level
  • Has invalid syntax

Using dirdelete

The following ProcScript deletes the directory tea if it is empty and the user confirms that it may be deleted:

$dir$ = "drinks\tea\"
; or $dir$ = "drinks/tea/"
; or $dir$ = "[drinks.tea]"
if ($dirlist($dir$,"dir") = "" & $dirlist($dir$,"file") = "")
   askmess/warning "Do you want to delete '%%$dir$'?", "Yes, No"
   if ($status = 1) 
      ldirdelete $dir$
   else
   message/error "Directory '%%$dir$' is not empty!"
endif

iSeries

When used without the IFS prefix, deleting libraries is only possible for libraries that are not in use and not on your own or somebody else’s library list. The same applies for files in libraries. Negative return values can be expected.

When used with an IFS prefix, directories are deleted as expected.

For more information, see File-Naming Considerations on iSeries.

History
VersionChange
9.1.01Introduced

Related Topics