2007/07/11(Wed)
○ 現場
省エネの為定時以降空調止まるのに忙しくて残業続きでもうイヤン。
○[Cygwin] rename(2)
多分Cygwinの中の人とかWindows詳しい人には常識なんだろけど、rename(2)の挙動がちとアレだ。
int
main(void)
{
int fd, tmp;
char path[] = "/tmp/test.XXXXXX";
fd = open("test.txt", O_RDONLY);
tmp = mkstemp(path);
...
if (rename(path, "test.txt") < 0)
abort();
close(fd);
return 0;
}
open(2)なんかで掴んでるファイルをrenameしようとするとEACCESになるもより。
まあWindowsだしなー、VC6でもfopen(3)してるファイルはrename(2)できないしな。
ちなみにunlink(2)もVC6だと無理なんだが、Cygwinだと可能なのね。