Delfile

Delfile deletes a file.

It returns a status 0 on success or a negative code.

Syntax

RETURN_VALUE=delFile(PATH)
  • RETURN_VALUEis an integer variable that contains the information returned by the call.
  • PATHis a string variable that contains path to the file you want to delete.

Example

# Procedure that deletes a log file
Subprog DELETE_LOG_FILE(LOGFILE_NAME, ERR_CODE)
 Const Char LOGFILE_NAME()
 Local Char PATH(GDIMFIC)
 Variable Integer ERR_CODE
  PATH = filpath('TMP', LOGFILE_NAME, 'tra')  
  # Delete the file
  # The file is supposed to be located in TMP directory on the application server with a tra extension
  ERR_CODE=delFile(PATH)
  End ERR_CODE

Return values

Value Explanation
0 Operation succeeded.
-20 File does not exist.
-27 Access denied.

Notes

  • On UNIX this function performs an unlink so the file may still exist if referenced by several hard links.
  • This function superseeds System "del"-PATH on Windows and System "rm"-PATH on Unix. It is faster because it does not fork a process.

See also

Copfile
Movfile
RenameFile