include "inc/cmdsys.plh"
include "inc/args.plh"
include "inc/fileio.plh"

var arg
char[64] oldfilename, newfilename
res[t_fileinfo] fileinfo
//
// Check arguments and file types
//
arg = argNext(argFirst)
if ^arg
    strcpy(@oldfilename, arg)
    if fileio:getfileinfo(@oldfilename, @fileinfo) <> FILE_ERR_OK
        //
        // File not found
        //
        puts("File not found: "); puts(@oldfilename); putln
        return
    fin
    arg = argNext(arg)
    if ^arg
        strcpy(@newfilename, arg)
        //
        // Rename file
        //
        if fileio:rename(@oldfilename, @newfilename) <> FILE_ERR_OK
            puts("Unable to rename: "); puts(@oldfilename); puts(" --> "); puts(@newfilename); putln
        fin
        return
    fin
fin
puts("Usage: +REN OLDNAME NEWNAME\n")
done
