DOS RENAME with System Function Behaves Incorrectly in C

ID Number: Q43893

4.00 5.00 5.10

MS-DOS

buglist5.10

Summary:

The DOS RENAME command returns an "invalid parameter" error message

when you attempt to rename a file with an invalid name. However, using

the RENAME command in conjunction with the "system" run-time library

function generates an interesting side effect if the file is not in

the current working directory and its new name is not valid.

Trying to rename a file with an invalid name using the "system"

function still yields the "invalid parameter" message, but the current

working directory is changed to the directory where the file does

reside. The following program demonstrates the problem:

/* assume this program is run from a directory other than c:\subdir */

#include <process.h>

#include <stdlib.h>

void main(void)

{

system("rename c:\\subdir\\SPA.EXE c:\\subdir\\*.*");

system("dir");

}

The program generates the "invalid parameter" message when trying to

rename SPA.EXE to *.* and then gives a directory listing of c:\subdir.

The program terminates with the current directory being c:\subdir if

compiled using the Microsoft C Optimizing Compiler. Under QuickC, the

current working directory also is changed to c:\subdir (as seen by

shelling out to DOS). However, exiting out of the QuickC environment

returns you to the original working directory.

Microsoft has confirmed this to be a problem with C Version 5.10. We

are researching this problem and will post new information as it

becomes available.