Renamefile
Renamefile
renames a file.
It returns a status: 0 on success; otherwise, it returns a negative code.
Syntax
RETURN_VALUE=RenameFile(PATH, RENAMED_PATH)
RETURN_VALUE
is an integer variable that contains the information returned by the call.PATH
is a string variable that contains the path to the file you want to rename.RENAMED_PATH
is a string variable that contains the path of the renamed file.
Example
# Procedure to rename a log file
Subprog RENAME_LOG_FILE(LOGFILE_NAME, ERR_CODE)
Const Char LOGFILE_NAME()
Local Char Path(GDIMFIC)
Local Char RENAMED_PATH(GDIMFIC)
Variable Integer ERR_CODE
PATH = filpath('TMP',LOGFILE_NAME,'tra')
RENAMED_PATH = filpath('TMP',LOGFILE_NAME,'old')
# Rename the file
ERR_CODE = RenameFile(PATH, RENAMED_PATH)
End ERR_CODE
Return values
Value | Explanation |
---|---|
0 | Operation succeeded |
-20 | File does not exist |
-27 | Access denied |
Notes
This function supersedes System "ren"-PATH-PATH1
on Windows and System "mv"-PATH-PATH1
on Unix. It is faster because it does not fork a process.